Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for Active Directory Integrated #2557

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 85 additions & 48 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,26 @@
<properties>
<!-- Allowed values for excluded Groups here - - - - - - - - - - - - -
xJDBC42 - - - - - - For tests not compatible with JDBC 42 Specifications
xGradle - - - - - - For tests not compatible with Gradle Script - - - - -
xSQLv11 - - - - - - For tests not compatible with SQL Server 2012 - - - -
xSQLv12 - - - - - - For tests not compatible with SQL Server 2008 R2 - 2014
xGradle - - - - - - For tests not compatible with Gradle Script
xSQLv11 - - - - - - For tests not compatible with SQL Server 2012
xSQLv12 - - - - - - For tests not compatible with SQL Server 2008 R2 - 2014
xSQLv14 - - - - - - For tests not compatible with SQL Server 2016 - 2017
xSQLv15 - - - - - - For tests not compatible with SQL Server 2019 - - - -
xSQLv16 - - - - - - For tests not compatible with SQL Server 2022 - - - -
xAzureSQLDB - - - - For tests not compatible with Azure SQL Database - -
xAzureSQLDW - - - - For tests not compatible with Azure Data Warehouse -
xSQLv15 - - - - - - For tests not compatible with SQL Server 2019
xSQLv16 - - - - - - For tests not compatible with SQL Server 2022
xAzureSQLDB - - - - For tests not compatible with Azure SQL Database
xAzureSQLDW - - - - For tests not compatible with Azure Data Warehouse
xAzureSQLMI - - - - For tests not compatible with Azure SQL Managed Instance
NTLM - - - - - - - For tests using NTLM Authentication mode (excluded by default)
kerberos - - - - - For tests using Kerberos authentication (excluded by default)
reqExternalSetup - For tests requiring external setup (excluded by default)
clientCertAuth - - For tests requiring client certificate authentication
setup (excluded by default) - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Default testing enabled with SQL Server 2019 (SQLv15) -->
<excludedGroups>xSQLv12,xSQLv15,NTLM,MSI,reqExternalSetup,clientCertAuth,fedAuth,kerberos</excludedGroups>

- - - The following test groups are that are excluded by default - - - - - - -
NTLM - For tests using NTLM Authentication mode
kerberos - - - - - For tests using Kerberos authentication
clientCertAuth - - - For tests requiring external setup
fedAuth - - - - - - For tests requiring FedAuth setup
aadIntegrated - - - For tests requiring AAD Integrated setup
reqExternalSetup - - For misc tests requiring external setup
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<excludedGroups>
xSQLv12,xSQLv15,NTLM,MSI,reqExternalSetup,clientCertAuth,fedAuth,kerberos,aadIntegrated</excludedGroups>
<!-- Use -preview for preview release, leave empty for official release. -->
<releaseExt>-preview</releaseExt>
<!-- Driver Dependencies -->
Expand Down Expand Up @@ -228,7 +231,8 @@
<repositories>
<repository>
<id>central</id>
<url>https://sqlclientdrivers.pkgs.visualstudio.com/public/_packaging/mssql-jdbc/maven/v1</url>
<url>
https://sqlclientdrivers.pkgs.visualstudio.com/public/_packaging/mssql-jdbc/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
Expand All @@ -240,7 +244,8 @@
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://sqlclientdrivers.pkgs.visualstudio.com/public/_packaging/mssql-jdbc/maven/v1</url>
<url>
https://sqlclientdrivers.pkgs.visualstudio.com/public/_packaging/mssql-jdbc/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
Expand All @@ -253,22 +258,29 @@
<profile>
<id>jre8</id>
<build>
<finalName>${project.artifactId}-${project.version}.jre8${releaseExt}</finalName>
<finalName>
${project.artifactId}-${project.version}.jre8${releaseExt}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<excludes>
<exclude>**/com/microsoft/sqlserver/jdbc/ISQLServerConnection43.java</exclude>
<exclude>**/com/microsoft/sqlserver/jdbc/SQLServerConnection43.java</exclude>
<exclude>**/com/microsoft/sqlserver/jdbc/SQLServerJdbc43.java</exclude>
<exclude>
**/com/microsoft/sqlserver/jdbc/ISQLServerConnection43.java</exclude>
<exclude>
**/com/microsoft/sqlserver/jdbc/SQLServerConnection43.java</exclude>
<exclude>
**/com/microsoft/sqlserver/jdbc/SQLServerJdbc43.java</exclude>
</excludes>
<testExcludes>
<exclude>**/com/microsoft/sqlserver/jdbc/connection/ConnectionWrapper43Test.java</exclude>
<exclude>**/com/microsoft/sqlserver/jdbc/connection/RequestBoundaryMethodsTest.java</exclude>
<exclude>**/com/microsoft/sqlserver/jdbc/JDBC43Test.java</exclude>
<exclude>
**/com/microsoft/sqlserver/jdbc/connection/ConnectionWrapper43Test.java</exclude>
<exclude>
**/com/microsoft/sqlserver/jdbc/connection/RequestBoundaryMethodsTest.java</exclude>
<exclude>
**/com/microsoft/sqlserver/jdbc/JDBC43Test.java</exclude>
</testExcludes>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -287,7 +299,8 @@
<version>3.1.1</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestFile>
${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
Expand All @@ -296,7 +309,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<!-- Exclude [xJDBC42] For tests not compatible with JDBC 4.2 Specifications -->
<!-- Exclude [xJDBC42] For tests not compatible with
JDBC 4.2 Specifications -->
<excludedGroups>${excludedGroups}, xJDBC42</excludedGroups>
</configuration>
</plugin>
Expand All @@ -306,15 +320,17 @@
<profile>
<id>jre11</id>
<build>
<finalName>${project.artifactId}-${project.version}.jre11${releaseExt}</finalName>
<finalName>
${project.artifactId}-${project.version}.jre11${releaseExt}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<excludes>
<exclude>**/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java</exclude>
<exclude>
**/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java</exclude>
</excludes>
<source>11</source>
<target>11</target>
Expand All @@ -326,9 +342,11 @@
<version>3.1.1</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestFile>
${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestEntries>
<Automatic-Module-Name>com.microsoft.sqlserver.jdbc</Automatic-Module-Name>
<Automatic-Module-Name>
com.microsoft.sqlserver.jdbc</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
Expand All @@ -339,15 +357,17 @@
<profile>
<id>jre17</id>
<build>
<finalName>${project.artifactId}-${project.version}.jre17${releaseExt}</finalName>
<finalName>
${project.artifactId}-${project.version}.jre17${releaseExt}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<excludes>
<exclude>**/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java</exclude>
<exclude>
**/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java</exclude>
</excludes>
<source>17</source>
<target>17</target>
Expand All @@ -359,9 +379,11 @@
<version>3.1.1</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestFile>
${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestEntries>
<Automatic-Module-Name>com.microsoft.sqlserver.jdbc</Automatic-Module-Name>
<Automatic-Module-Name>
com.microsoft.sqlserver.jdbc</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
Expand All @@ -372,15 +394,17 @@
<profile>
<id>jre21</id>
<build>
<finalName>${project.artifactId}-${project.version}.jre21${releaseExt}</finalName>
<finalName>
${project.artifactId}-${project.version}.jre21${releaseExt}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<excludes>
<exclude>**/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java</exclude>
<exclude>
**/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java</exclude>
</excludes>
<source>21</source>
<target>21</target>
Expand All @@ -392,9 +416,11 @@
<version>3.1.1</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestFile>
${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestEntries>
<Automatic-Module-Name>com.microsoft.sqlserver.jdbc</Automatic-Module-Name>
<Automatic-Module-Name>
com.microsoft.sqlserver.jdbc</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
Expand All @@ -408,15 +434,17 @@
<activeByDefault>true</activeByDefault>
</activation>
<build>
<finalName>${project.artifactId}-${project.version}.jre23${releaseExt}</finalName>
<finalName>
${project.artifactId}-${project.version}.jre23${releaseExt}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<excludes>
<exclude>**/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java</exclude>
<exclude>
**/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java</exclude>
</excludes>
<source>23</source>
<target>23</target>
Expand All @@ -428,9 +456,11 @@
<version>3.1.1</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestFile>
${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestEntries>
<Automatic-Module-Name>com.microsoft.sqlserver.jdbc</Automatic-Module-Name>
<Automatic-Module-Name>
com.microsoft.sqlserver.jdbc</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
Expand Down Expand Up @@ -477,12 +507,16 @@
<configuration>
<rules>
<bannedPlugins>
<!-- will only display a warning but does not fail the build. -->
<!-- will only display a warning but does
not fail the build. -->
<level>WARN</level>
<excludes>
<exclude>org.apache.maven.plugins:maven-verifier-plugin</exclude>
<exclude>
org.apache.maven.plugins:maven-verifier-plugin</exclude>
</excludes>
<message>Please consider using the maven-invoker-plugin
<message>
Please consider using the
maven-invoker-plugin
(http://maven.apache.org/plugins/maven-invoker-plugin/)!</message>
</bannedPlugins>
<requireMavenVersion>
Expand Down Expand Up @@ -535,8 +569,10 @@
com.microsoft.sqlserver.jdbc.dataclassification,
microsoft.sql
</_exportcontents>
<Import-Package>!microsoft.sql,jdk.net;resolution:=optional,*</Import-Package>
<Bundle-Activator>com.microsoft.sqlserver.jdbc.osgi.Activator</Bundle-Activator>
<Import-Package>
!microsoft.sql,jdk.net;resolution:=optional,*</Import-Package>
<Bundle-Activator>
com.microsoft.sqlserver.jdbc.osgi.Activator</Bundle-Activator>
</instructions>
</configuration>
<executions>
Expand Down Expand Up @@ -573,7 +609,8 @@
<inherited>true</inherited>
<configuration>
<outputFile>outdated-dependencies.txt</outputFile>
<rulesUri>file:///${session.executionRootDirectory}/maven-version-rules.xml</rulesUri>
<rulesUri>
file:///${session.executionRootDirectory}/maven-version-rules.xml</rulesUri>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,13 @@ public void testConcurrentLogin() throws Exception {

t1.start();
t2.start();
if (enableADIntegrated) {
Thread t3 = new Thread(r3);
t3.setUncaughtExceptionHandler(handler);
t3.start();
t3.join();
}
t1.join();
t2.join();

Throwable throwable = (Throwable) throwableRef.get();
if (throwable != null) {
fail(throwable.getMessage());
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ public void testAccessTokenExpiredThenCreateNewStatementADPassword() throws SQLE
testAccessTokenExpiredThenCreateNewStatement(SqlAuthentication.ActiveDirectoryPassword);
}

@Test
public void testAccessTokenExpiredThenCreateNewStatementADIntegrated() throws SQLException {
org.junit.Assume.assumeTrue(enableADIntegrated);

testAccessTokenExpiredThenCreateNewStatement(SqlAuthentication.ActiveDirectoryIntegrated);
}

private void testAccessTokenExpiredThenCreateNewStatement(SqlAuthentication authentication) throws SQLException {
long secondsPassed = 0;
long start = System.currentTimeMillis();
Expand Down Expand Up @@ -114,13 +107,6 @@ public void testAccessTokenExpiredThenExecuteUsingSameStatementADPassword() thro
testAccessTokenExpiredThenExecuteUsingSameStatement(SqlAuthentication.ActiveDirectoryPassword);
}

@Test
public void testAccessTokenExpiredThenExecuteUsingSameStatementADIntegrated() throws SQLException {
org.junit.Assume.assumeTrue(enableADIntegrated);

testAccessTokenExpiredThenExecuteUsingSameStatement(SqlAuthentication.ActiveDirectoryIntegrated);
}

private void testAccessTokenExpiredThenExecuteUsingSameStatement(
SqlAuthentication authentication) throws SQLException {
long secondsPassed = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,6 @@ public void testAuthenticationAgainstSQLServerWithActivedirectorypassword() thro
}
}

@Test
public void testAuthenticationAgainstSQLServerWithActivedirectoryIntegrated() throws SQLException {
org.junit.Assume.assumeTrue(enableADIntegrated);

java.util.Properties info = new Properties();
info.put("TrustServerCertificate", "true");
info.put("Authentication", SqlAuthentication.ActiveDirectoryIntegrated.toString());

try (Connection connection = DriverManager.getConnection(connectionUrl, info)) {} catch (Exception e) {
fail(e.getMessage());
}
}

@Test
public void testNotSpecifiedWithConnectionStringUserName() throws SQLException {
boolean retry = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ public class FedauthCommon extends AbstractTest {
static String azurePassword = null;
static String azureGroupUserName = null;

static boolean enableADIntegrated = false;

static String hostNameInCertificate = null;
static String applicationName = null;
static String kustoServer = null;
Expand Down Expand Up @@ -183,9 +181,6 @@ public static void getConfigs() throws Exception {
// password for service principal certificate
certificatePassword = getConfiguredProperty("certificatePassword");

String prop = getConfiguredProperty("enableADIntegrated");
enableADIntegrated = (null != prop && prop.equalsIgnoreCase("true")) ? true : false;

adPasswordConnectionStr = "jdbc:sqlserver://" + azureServer + ";database=" + azureDatabase + ";user="
+ azureUserName + ";password=" + azurePassword + ";Authentication="
+ SqlAuthentication.ActiveDirectoryPassword.toString();
Expand Down
Loading
Loading