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

Test Improvements + Readme changes #919

Merged
merged 8 commits into from
Jan 4, 2019
Merged
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
36 changes: 28 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ Starting from version 7.0.0, the driver Jars (jre10 and above) will expose 'Auto
This project has following dependencies:

Compile Time:
- `azure-keyvault` : Azure Key Vault Provider for Always Encrypted Azure Key Vault feature (optional)
- `adal4j` : Azure ActiveDirectory Library for Java for Azure Active Directory Authentication feature and Azure Key Vault feature (optional)
- `com.microsoft.azure:azure-keyvault` : Azure Key Vault Provider for Always Encrypted Azure Key Vault feature (optional)
- `com.microsoft.azure:azure-keyvault-webkey` : Azure Key Vault Provider for Always Encrypted Azure Key Vault feature (optional)
- `com.microsoft.azure:adal4j` : Azure Active Directory Library for Java for Azure Active Directory Authentication feature and Azure Key Vault feature (optional)
- `com.microsoft.rest:client-runtime` : Azure Active Directory Library for Java for Azure Active Directory Authentication feature and Azure Key Vault feature (optional)

Test Time:
- `junit:jar` : For Unit Test cases.
Expand All @@ -117,7 +119,7 @@ mvn dependency:tree
### Azure Key Vault and Azure Active Directory Authentication Dependencies
Projects that require either of the two features need to explicitly declare the dependency in their pom file.

***For Example:*** If you are using *Azure Active Directory Authentication feature* then you need to redeclare *adal4j* dependency in your project's pom file. Please see the following snippet:
***For Example:*** If you are using *Azure Active Directory Authentication feature* then you need to redeclare *adal4j* and *client-runtime* dependency in your project's pom file. Please see the following snippet:

```xml
<dependency>
Expand All @@ -130,11 +132,17 @@ Projects that require either of the two features need to explicitly declare the
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>1.6.0</version>
<version>1.6.3</version>
</dependency>

<dependency>
<groupId>com.microsoft.rest</groupId>
<artifactId>client-runtime</artifactId>
<version>1.6.5</version>
</dependency>
```

***For Example:*** If you are using *Azure Key Vault feature* then you need to redeclare *azure-keyvault* dependency and *adal4j* dependency in your project's pom file. Please see the following snippet:
***For Example:*** If you are using *Azure Key Vault feature* then you need to redeclare *azure-keyvault*, *azure-keyvault-webkey* dependency and *adal4j*, *client-runtime* dependency in your project's pom file. Please see the following snippet:

```xml
<dependency>
Expand All @@ -147,13 +155,25 @@ Projects that require either of the two features need to explicitly declare the
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>1.6.0</version>
<version>1.6.3</version>
</dependency>

<dependency>
<groupId>com.microsoft.rest</groupId>
<artifactId>client-runtime</artifactId>
<version>1.6.5</version>
</dependency>

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault</artifactId>
<version>1.0.0</version>
<version>1.2.0</version>
</dependency>

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>zure-keyvault-webkey</artifactId>
<version>1.2.0</version>
</dependency>
```

Expand Down Expand Up @@ -189,7 +209,7 @@ Preview releases happen approximately monthly between stable releases. This give
You can see what is going into a future release by monitoring [Milestones](https://github.com/Microsoft/mssql-jdbc/milestones) in the repository.

### Versioning convention
Starting with 6.0, stable versions have an even minor version. For example, 6.0, 6.2, 6.4, 7.0. Preview versions have an odd minor version. For example, 6.1, 6.3, 6.5, 7.1.
Starting with 6.0, stable versions have an even minor version. For example, 6.0, 6.2, 6.4, 7.0, 7.2. Preview versions have an odd minor version. For example, 6.1, 6.3, 6.5, 7.1.

## Contributors
Special thanks to everyone who has contributed to the project.
Expand Down
24 changes: 12 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ repositories {
}

dependencies {
compileOnly 'com.microsoft.azure:azure-keyvault:1.1.1',
'com.microsoft.azure:azure-keyvault-webkey:1.1.1',
'com.microsoft.rest:client-runtime:1.6.2',
'com.microsoft.azure:adal4j:1.6.2'
testCompile 'org.junit.platform:junit-platform-console:1.3.1',
'org.junit.platform:junit-platform-commons:1.3.1',
'org.junit.platform:junit-platform-engine:1.3.1',
'org.junit.platform:junit-platform-launcher:1.3.1',
'org.junit.platform:junit-platform-runner:1.3.1',
'org.junit.platform:junit-platform-surefire-provider:1.3.1',
'org.junit.jupiter:junit-jupiter-api:5.3.1',
'org.junit.jupiter:junit-jupiter-engine:5.3.1',
compileOnly 'com.microsoft.azure:azure-keyvault:1.2.0',
'com.microsoft.azure:azure-keyvault-webkey:1.2.0',
'com.microsoft.rest:client-runtime:1.6.5',
'com.microsoft.azure:adal4j:1.6.3'
testCompile 'org.junit.platform:junit-platform-console:1.3.2',
'org.junit.platform:junit-platform-commons:1.3.2',
'org.junit.platform:junit-platform-engine:1.3.2',
'org.junit.platform:junit-platform-launcher:1.3.2',
'org.junit.platform:junit-platform-runner:1.3.2',
'org.junit.platform:junit-platform-surefire-provider:1.3.2',
'org.junit.jupiter:junit-jupiter-api:5.3.2',
'org.junit.jupiter:junit-jupiter-engine:5.3.2',
'com.zaxxer:HikariCP:3.2.0',
'org.apache.commons:commons-dbcp2:2.5.0',
'org.slf4j:slf4j-nop:1.7.25'
Expand Down
26 changes: 12 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.platform.version>1.3.1</junit.platform.version>
<junit.jupiter.version>5.3.1</junit.jupiter.version>
<junit.platform.version>1.3.2</junit.platform.version>
<junit.jupiter.version>5.3.2</junit.jupiter.version>
<testGroup></testGroup>
<osgi.version>4.3.1</osgi.version>
</properties>
Expand All @@ -49,23 +49,29 @@
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault</artifactId>
<version>1.1.1</version>
<version>1.2.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault-webkey</artifactId>
<version>1.1.1</version>
<version>1.2.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>1.6.2</version>
<version>1.6.3</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.microsoft.rest</groupId>
<artifactId>client-runtime</artifactId>
<version>1.6.5</version>
<optional>true</optional>
</dependency>

<!-- dependecies provided by an OSGi-Framework -->
<!-- dependencies provided by an OSGi-Framework -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
Expand All @@ -79,14 +85,6 @@
<scope>provided</scope>
</dependency>

<!-- dependencies for running tests -->
<dependency>
<groupId>com.microsoft.rest</groupId>
<artifactId>client-runtime</artifactId>
<version>1.6.2</version>
<optional>true</optional>
</dependency>

<!-- dependencies for running tests -->
<dependency>
<groupId>org.junit.platform</groupId>
Expand Down
44 changes: 22 additions & 22 deletions src/test/java/com/microsoft/sqlserver/jdbc/JDBC43Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,18 @@ public void connectionPoolDataSourceTest() throws TestAbortedException, SQLExcep
@Test
public void setShardingKeyIfValidTest() throws TestAbortedException, SQLException {
assumeTrue(TestUtils.supportJDBC43(connection));
SQLServerConnection connection43 = (SQLServerConnection43) DriverManager.getConnection(connectionString);
try {
connection43.setShardingKeyIfValid(shardingKey, 10);
} catch (SQLException e) {
assert (e.getMessage().contains(TestResource.getResource("R_operationNotSupported")));
}
try {
connection43.setShardingKeyIfValid(shardingKey, superShardingKey, 10);
} catch (SQLException e) {
assert (e.getMessage().contains(TestResource.getResource("R_operationNotSupported")));
try (SQLServerConnection connection43 = (SQLServerConnection43) DriverManager.getConnection(connectionString)) {
try {
connection43.setShardingKeyIfValid(shardingKey, 10);
} catch (SQLException e) {
assert (e.getMessage().contains(TestResource.getResource("R_operationNotSupported")));
}
try {
connection43.setShardingKeyIfValid(shardingKey, superShardingKey, 10);
} catch (SQLException e) {
assert (e.getMessage().contains(TestResource.getResource("R_operationNotSupported")));
}
}

}

/**
Expand All @@ -165,18 +165,18 @@ public void setShardingKeyIfValidTest() throws TestAbortedException, SQLExceptio
@Test
public void setShardingKeyTest() throws TestAbortedException, SQLException {
assumeTrue(TestUtils.supportJDBC43(connection));
SQLServerConnection connection43 = (SQLServerConnection43) DriverManager.getConnection(connectionString);
try {
connection43.setShardingKey(shardingKey);
} catch (SQLException e) {
assert (e.getMessage().contains(TestResource.getResource("R_operationNotSupported")));
}
try {
connection43.setShardingKey(shardingKey, superShardingKey);
} catch (SQLException e) {
assert (e.getMessage().contains(TestResource.getResource("R_operationNotSupported")));
try (SQLServerConnection connection43 = (SQLServerConnection43) DriverManager.getConnection(connectionString)) {
try {
connection43.setShardingKey(shardingKey);
} catch (SQLException e) {
assert (e.getMessage().contains(TestResource.getResource("R_operationNotSupported")));
}
try {
connection43.setShardingKey(shardingKey, superShardingKey);
} catch (SQLException e) {
assert (e.getMessage().contains(TestResource.getResource("R_operationNotSupported")));
}
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,133 +39,99 @@ public void testValidateServerName() throws Exception {
Object hsoObject = constructor.newInstance(null, tdsc, null, serverName);
Method method = hsoObject.getClass().getDeclaredMethod("validateServerName", String.class);
method.setAccessible(true);

/*
* Server Name = msjdbc.database.windows.net
* SAN = msjdbc.database.windows.net
* Expected result: true
* Server Name = msjdbc.database.windows.net SAN = msjdbc.database.windows.net Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "msjdbc.database.windows.net"));

/*
* Server Name = msjdbc.database.windows.net
* SAN = msjdbc***.database.windows.net
* Expected result: true
* Server Name = msjdbc.database.windows.net SAN = msjdbc***.database.windows.net Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "msjdbc***.database.windows.net"));

/*
* Server Name = msjdbc.database.windows.net
* SAN = ms*bc.database.windows.net
* Expected result: true
* Server Name = msjdbc.database.windows.net SAN = ms*bc.database.windows.net Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "ms*bc.database.windows.net"));

/*
* Server Name = msjdbc.database.windows.net
* SAN = *bc.database.windows.net
* Expected result: true
* Server Name = msjdbc.database.windows.net SAN = *bc.database.windows.net Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "*bc.database.windows.net"));

/*
* Server Name = msjdbc.database.windows.net
* SAN = ms*.database.windows.net
* Expected result: true
* Server Name = msjdbc.database.windows.net SAN = ms*.database.windows.net Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "ms*.database.windows.net"));

/*
* Server Name = msjdbc.database.windows.net
* SAN = *jd*.database.windows.net
* Expected result: true
* Server Name = msjdbc.database.windows.net SAN = *jd*.database.windows.net Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "*jd*.database.windows.net"));

/*
* Server Name = msjdbc.database.windows.net
* SAN = ms.*.net
* Expected result: false
* Server Name = msjdbc.database.windows.net SAN = ms.*.net Expected result: false
*/
assertFalse((boolean) method.invoke(hsoObject, "ms.*.net"));

/*
* Server Name = msjdbc.database.windows.net
* SAN = msjdbc.asd*dsa.windows.net
* Expected result: false
* Server Name = msjdbc.database.windows.net SAN = msjdbc.asd*dsa.windows.net Expected result: false
*/
assertFalse((boolean) method.invoke(hsoObject, "msjdbc.asd*dsa.windows.net"));

/*
* Server Name = msjdbc.database.windows.net
* SAN = *.*.windows.net
* Expected result: false
* Server Name = msjdbc.database.windows.net SAN = *.*.windows.net Expected result: false
*/
assertFalse((boolean) method.invoke(hsoObject, ".*.windows.net"));

/*
* Server Name = msjdbc.database.windows.net
* SAN = msjdbc.*.windows.net
* Expected result: false
* Server Name = msjdbc.database.windows.net SAN = msjdbc.*.windows.net Expected result: false
*/
assertFalse((boolean) method.invoke(hsoObject, "msjdbc.*.windows.net"));

/*
* Server Name = msjdbc.database.windows.net
* SAN = *.*.windows.net
* Expected result: false
* Note: multiple wildcards are not allowed, so this case shouldn't happen, but we still make sure to fail this.
* Server Name = msjdbc.database.windows.net SAN = *.*.windows.net Expected result: false Note: multiple
* wildcards are not allowed, so this case shouldn't happen, but we still make sure to fail this.
*/
assertFalse((boolean) method.invoke(hsoObject, "*.*.windows.net"));

/*
* Server Name = msjdbc.database.windows.net
* SAN = *.com
* Expected result: false
* A cert with * plus a top-level domain is not allowed.
* Server Name = msjdbc.database.windows.net SAN = *.com Expected result: false A cert with * plus a top-level
* domain is not allowed.
*/
assertFalse((boolean) method.invoke(hsoObject, "*.com"));

/*
* Server Name = msjdbc.database.windows.net
* SAN = xn--ms*.database.windows.net
* Expected result: false
* Server Name = msjdbc.database.windows.net SAN = xn--ms*.database.windows.net Expected result: false
*/
assertFalse((boolean) method.invoke(hsoObject, "xn--ms*.database.windows.net"));

/*
* Server Name = msjdbc.database.windows.net
* SAN = *
* Expected result: false
* Server Name = msjdbc.database.windows.net SAN = * Expected result: false
*/
assertFalse((boolean) method.invoke(hsoObject, "*"));

/*
* Server Name = msjdbc.database.windows.net
* SAN = ms*atabase.windows.net
* Expected result: false
* Server Name = msjdbc.database.windows.net SAN = ms*atabase.windows.net Expected result: false
*/
assertFalse((boolean) method.invoke(hsoObject, "ms*atabase.windows.net"));

hsoObject = constructor.newInstance(null, tdsc, null, serverName2);
method = hsoObject.getClass().getDeclaredMethod("validateServerName", String.class);
method.setAccessible(true);

/*
* Server Name = bbbbuuzzuzzzzzz.example.net
* SAN = b*zzz.example.net
* Expected result: true
* Server Name = bbbbuuzzuzzzzzz.example.net SAN = b*zzz.example.net Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "b*zzz.example.net"));

hsoObject = constructor.newInstance(null, tdsc, null, serverName3);
method = hsoObject.getClass().getDeclaredMethod("validateServerName", String.class);
method.setAccessible(true);

/*
* Server Name = xn--ms.database.windows.net
* SAN = xn--ms.database.windows.net
* Expected result: true
* Server Name = xn--ms.database.windows.net SAN = xn--ms.database.windows.net Expected result: true
*/
assertTrue((boolean) method.invoke(hsoObject, "xn--ms.database.windows.net"));
}
Expand Down
Loading