Files.write(data, file); ctx = new SaslTestCtx(rpcHandler, true, false, testConf); file.delete(); if (ctx != null) { ctx.close();
Files.write(data, file); ctx = new SaslTestCtx(rpcHandler, true, false, testConf); file.delete(); if (ctx != null) { ctx.close();
.receive(any(TransportClient.class), any(ByteBuffer.class), any(RpcResponseCallback.class)); SaslTestCtx ctx = new SaslTestCtx(rpcHandler, encrypt, false); try { ByteBuffer response = ctx.client.sendRpcSync(JavaUtils.stringToBytes("Ping"), assertEquals("Pong", JavaUtils.bytesToString(response)); } finally { ctx.close();
.createClient(TestUtils.getLocalHost(), server.getPort()); } catch (Exception e) { close(); throw e;
.receive(any(TransportClient.class), any(ByteBuffer.class), any(RpcResponseCallback.class)); SaslTestCtx ctx = new SaslTestCtx(rpcHandler, encrypt, false); try { ByteBuffer response = ctx.client.sendRpcSync(JavaUtils.stringToBytes("Ping"), assertEquals("Pong", JavaUtils.bytesToString(response)); } finally { ctx.close();
.createClient(TestUtils.getLocalHost(), server.getPort()); } catch (Exception e) { close(); throw e;
@Test public void testDataEncryptionIsActuallyEnabled() throws Exception { // This test sets up an encrypted connection but then, using a client bootstrap, removes // the encryption handler from the client side. This should cause the server to not be // able to understand RPCs sent to it and thus close the connection. SaslTestCtx ctx = null; try { ctx = new SaslTestCtx(mock(RpcHandler.class), true, true); ctx.client.sendRpcSync(JavaUtils.stringToBytes("Ping"), TimeUnit.SECONDS.toMillis(10)); fail("Should have failed to send RPC to server."); } catch (Exception e) { assertFalse(e.getCause() instanceof TimeoutException); } finally { if (ctx != null) { ctx.close(); } } }
@Test public void testDataEncryptionIsActuallyEnabled() throws Exception { // This test sets up an encrypted connection but then, using a client bootstrap, removes // the encryption handler from the client side. This should cause the server to not be // able to understand RPCs sent to it and thus close the connection. SaslTestCtx ctx = null; try { ctx = new SaslTestCtx(mock(RpcHandler.class), true, true); ctx.client.sendRpcSync(JavaUtils.stringToBytes("Ping"), TimeUnit.SECONDS.toMillis(10)); fail("Should have failed to send RPC to server."); } catch (Exception e) { assertFalse(e.getCause() instanceof TimeoutException); } finally { if (ctx != null) { ctx.close(); } } }
@Test public void testServerAlwaysEncrypt() throws Exception { SaslTestCtx ctx = null; try { ctx = new SaslTestCtx(mock(RpcHandler.class), false, false, ImmutableMap.of("spark.network.sasl.serverAlwaysEncrypt", "true")); fail("Should have failed to connect without encryption."); } catch (Exception e) { assertTrue(e.getCause() instanceof SaslException); } finally { if (ctx != null) { ctx.close(); } } }
@Test public void testServerAlwaysEncrypt() throws Exception { SaslTestCtx ctx = null; try { ctx = new SaslTestCtx(mock(RpcHandler.class), false, false, ImmutableMap.of("spark.network.sasl.serverAlwaysEncrypt", "true")); fail("Should have failed to connect without encryption."); } catch (Exception e) { assertTrue(e.getCause() instanceof SaslException); } finally { if (ctx != null) { ctx.close(); } } }