Skip to content

Commit

Permalink
Test change
Browse files Browse the repository at this point in the history
  • Loading branch information
muskan124947 committed Jan 24, 2025
1 parent a398694 commit 5691df0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ private void initAuthInit() throws SQLServerException {
}

if (null == currentSubject) {
lc = new LoginContext(configName, null, callback, new JaasConfiguration(Configuration.getConfiguration()));
if (useDefaultJaas) {
lc = new LoginContext(configName, null, callback, new JaasConfiguration(null));
} else {
lc = new LoginContext(configName, callback);
}
lc.login();
// per documentation LoginContext will instantiate a new subject.
currentSubject = lc.getSubject();
Expand Down
32 changes: 11 additions & 21 deletions src/test/java/com/microsoft/sqlserver/jdbc/KerberosTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,20 @@ public class KerberosTest extends AbstractTest {

@BeforeAll
public static void setupTests() throws Exception {
setJaasConfiguration();
configureJaas();
setConnection();
}

private static void setJaasConfiguration() {
AppConfigurationEntry[] entries = new AppConfigurationEntry[]{
new AppConfigurationEntry(
"com.sun.security.auth.module.Krb5LoginModule",
AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
new HashMap<String, Object>() {{
put("useTicketCache", "true");
put("renewTGT", "true");
}}
)
};
Configuration.setConfiguration(new Configuration() {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
if ("SQLJDBCDriver".equals(name)) {
return entries;
}
return null;
}
});
/**
* Configures JAAS for the test environment.
*/
private static void configureJaas() {
AppConfigurationEntry kafkaClientConfigurationEntry = new AppConfigurationEntry(
"com.sun.security.auth.module.Krb5LoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
new HashMap<>());
Map<String, AppConfigurationEntry[]> configurationEntries = new HashMap<>();
configurationEntries.put("SQLJDBCDriver", new AppConfigurationEntry[] {kafkaClientConfigurationEntry});
Configuration.setConfiguration(new InternalConfiguration(configurationEntries));
}

@Test
Expand Down

0 comments on commit 5691df0

Please sign in to comment.