flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/test/java/org/apache/flink/runtime/net/SSLUtilsTest.java
/**
	 * Tests if SSLUtils set the right ssl version and cipher suites for SSLEngine.
	 */
Tests if SSLUtils set the right ssl version and cipher suites for SSLEngine.
Tests if SSLUtils set the right ssl version and cipher suites for SSLEngine .
@Test
	public void testSetSSLVersionAndCipherSuitesForSSLEngine() throws Exception {
		Configuration serverConfig = new Configuration();
		serverConfig.setBoolean(SecurityOptions.SSL_ENABLED, true);
		serverConfig.setString(SecurityOptions.SSL_KEYSTORE, "src/test/resources/local127.keystore");
		serverConfig.setString(SecurityOptions.SSL_KEYSTORE_PASSWORD, "password");
		serverConfig.setString(SecurityOptions.SSL_KEY_PASSWORD, "password");
		serverConfig.setString(SecurityOptions.SSL_PROTOCOL, "TLSv1");
		serverConfig.setString(SecurityOptions.SSL_ALGORITHMS, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256");
		SSLContext serverContext = SSLUtils.createSSLServerContext(serverConfig);
		SSLEngine engine = serverContext.createSSLEngine();
		String[] protocols = engine.getEnabledProtocols();
		String[] algorithms = engine.getEnabledCipherSuites();
		Assert.assertNotEquals(1, protocols.length);
		Assert.assertNotEquals(2, algorithms.length);
		SSLUtils.setSSLVerAndCipherSuites(engine, serverConfig);
		protocols = engine.getEnabledProtocols();
		algorithms = engine.getEnabledCipherSuites();
		Assert.assertEquals(1, protocols.length);
		Assert.assertEquals("TLSv1", protocols[0]);
		Assert.assertEquals(2, algorithms.length);
		Assert.assertTrue(algorithms[0].equals("TLS_DHE_RSA_WITH_AES_128_CBC_SHA") || algorithms[0].equals("TLS_DHE_RSA_WITH_AES_128_CBC_SHA256"));
		Assert.assertTrue(algorithms[1].equals("TLS_DHE_RSA_WITH_AES_128_CBC_SHA") || algorithms[1].equals("TLS_DHE_RSA_WITH_AES_128_CBC_SHA256"));
	}
@ Test public void testSetSSLVersionAndCipherSuitesForSSLEngine ( ) throws Exception { Configuration serverConfig = new Configuration ( ) ; serverConfig . setBoolean ( SecurityOptions . SSL_ENABLED , true ) ; serverConfig . setString ( SecurityOptions . SSL_KEYSTORE , "src/test/resources/local127.keystore" ) ; serverConfig . setString ( SecurityOptions . SSL_KEYSTORE_PASSWORD , "password" ) ; serverConfig . setString ( SecurityOptions . SSL_KEY_PASSWORD , "password" ) ; serverConfig . setString ( SecurityOptions . SSL_PROTOCOL , "TLSv1" ) ; serverConfig . setString ( SecurityOptions . SSL_ALGORITHMS , "TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256" ) ; SSLContext serverContext = SSLUtils . createSSLServerContext ( serverConfig ) ; SSLEngine engine = serverContext . createSSLEngine ( ) ; String [ ] protocols = engine . getEnabledProtocols ( ) ; String [ ] algorithms = engine . getEnabledCipherSuites ( ) ; Assert . assertNotEquals ( 1 , protocols . length ) ; Assert . assertNotEquals ( 2 , algorithms . length ) ; SSLUtils . setSSLVerAndCipherSuites ( engine , serverConfig ) ; protocols = engine . getEnabledProtocols ( ) ; algorithms = engine . getEnabledCipherSuites ( ) ; Assert . assertEquals ( 1 , protocols . length ) ; Assert . assertEquals ( "TLSv1" , protocols [ 0 ] ) ; Assert . assertEquals ( 2 , algorithms . length ) ; Assert . assertTrue ( algorithms [ 0 ] . equals ( "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" ) || algorithms [ 0 ] . equals ( "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256" ) ) ; Assert . assertTrue ( algorithms [ 1 ] . equals ( "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" ) || algorithms [ 1 ] . equals ( "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256" ) ) ; }
Tests if SSLUtils set the right ssl version and cipher suites for SSLEngine.
Tests if SSLUtils set the right ssl version and cipher suites for SSLEngine .