-
Notifications
You must be signed in to change notification settings - Fork 426
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
New connection property: sslProtocol #422
Conversation
@ulvii, |
Replace tabs with spaces
Codecov Report
@@ Coverage Diff @@
## dev #422 +/- ##
============================================
+ Coverage 45.92% 46.13% +0.21%
- Complexity 2198 2206 +8
============================================
Files 108 108
Lines 25210 25246 +36
Branches 4164 4169 +5
============================================
+ Hits 11577 11647 +70
+ Misses 11711 11678 -33
+ Partials 1922 1921 -1
Continue to review full report at Codecov.
|
@@ -117,6 +117,46 @@ else if (value.toLowerCase(Locale.US).equalsIgnoreCase(ColumnEncryptionSetting.D | |||
} | |||
} | |||
|
|||
enum SSLProtocol { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like enum... Good One.
* @throws Exception | ||
*/ | ||
@Test | ||
public void testConnectWithWrongProtocols() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUGGESTION: You can use JUnit's ability of parametrized test.
In future JUnit might give (or may be available) to pass parameters from some configuration file so no need to touch test code to add extra tests just like TestNG
@DisplayName("TestForWrongValues")
@ParameterizedTest
@ValueSource(strings={"SSLv1111","SSLv2222","SSLv3111", "SSLv2Hello1111","TLSv1.11","TLSv2.4","HTTPS"})
public void testConnectWithWrongProtocol(String sslProtocol) throws Exception {
testWithUnSupportedProtocols(sslProtocol);
}
You need to upgrade JUnit 1.0.0-M4 & add following dependency
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.0.0-M4</version>
<scope>test</scope>
</dependency>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nsidhaye,
Thank you for suggestion. I modified the test a bit to not introduce a new dependency and make it compatible with previous JUnit versions. I also agree that, we should consider using new JUnit features.
Link to Wiki page: https://github.com/Microsoft/mssql-jdbc/wiki/SSLProtocol |
static SSLProtocol valueOfString(String value) throws SQLServerException { | ||
SSLProtocol protocol = null; | ||
|
||
if (value.toLowerCase(Locale.ENGLISH).equalsIgnoreCase(SSLProtocol.TLS.toString())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The toLowerCase(Locale.ENGLISH) is unnecesary since equalsIgnoreCase is used.
Adding a new connection property to let the users specify TLS protocol keyword. Possible values: "TLS", "TLSv1", "TLSv1.1", "TLSv1.2". The default is "TLS". These keywords might behave differently depending on JRE( Oracle, IBM, SAP ), so the users should read the documentation before using them.
Example use-case:
When Suite B or SP800-131a standards are used, only TLSv1.2 must be enabled.