Repository: nifi Updated Branches: refs/heads/master 1752a5719 -> d600b065b
NIFI-2618 Added logic to unit test to handle default TLS version for Java <= 7. This closes #955. Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/d600b065 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/d600b065 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/d600b065 Branch: refs/heads/master Commit: d600b065bbc33d0624b241eee4a6b937546f580b Parents: 1752a57 Author: Andy LoPresto <alopre...@apache.org> Authored: Thu Aug 25 19:17:10 2016 -0700 Committer: Andy LoPresto <alopre...@apache.org> Committed: Tue Aug 30 08:25:38 2016 -0700 ---------------------------------------------------------------------- .../processors/standard/TestPostHTTPGroovy.groovy | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/d600b065/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/groovy/org/apache/nifi/processors/standard/TestPostHTTPGroovy.groovy ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/groovy/org/apache/nifi/processors/standard/TestPostHTTPGroovy.groovy b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/groovy/org/apache/nifi/processors/standard/TestPostHTTPGroovy.groovy index 3270e9b..a27f7ce 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/groovy/org/apache/nifi/processors/standard/TestPostHTTPGroovy.groovy +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/groovy/org/apache/nifi/processors/standard/TestPostHTTPGroovy.groovy @@ -261,12 +261,28 @@ class TestPostHTTPGroovy extends GroovyTestCase { assert response == MSG.reverse() } + /** + * This test asserts the default TLS version is TLSv1.2, but this only accurate for Java 8 and above. For Java 7, the default is TLSv1. + */ @Test public void testDefaultShouldPreferTLSv1_2() { // Arrange final String MSG = "This is a test message" final String url = "${HTTPS_URL}/ReverseHandler.groovy?string=${URLEncoder.encode(MSG, "UTF-8")}" + // Determine expected default TLS version based on Java version + logger.info("System Java Version: ${System.getProperty("java.version")}") + logger.info("Implementation version: ${Runtime.getPackage().getImplementationVersion()}") + logger.info("Specification version: ${Runtime.getPackage().getSpecificationVersion()}") + String EXPECTED_TLS_VERSION + if ((Runtime.getPackage().getSpecificationVersion() as double) > 1.7) { + logger.info("Java 8 or above; default TLS version is TLSv1.2") + EXPECTED_TLS_VERSION = TLSv1_2 + } else { + logger.info("Java 7 or below; default TLS version is TLSv1") + EXPECTED_TLS_VERSION = TLSv1 + } + // Configure server with all TLS protocols server = createServer() @@ -288,7 +304,7 @@ class TestPostHTTPGroovy extends GroovyTestCase { logger.info("Selected protocol: ${selectedProtocol}") // Assert - assert selectedProtocol == TLSv1_2 + assert selectedProtocol == EXPECTED_TLS_VERSION } private static void enableContextServiceProtocol(TestRunner runner, String protocol) {