} else if (u instanceof AuthenticationException) { log.warn("Token check failed while being written by {} on segment {}.", writerId, segment, u); connection.send(new WireCommands.AuthTokenCheckFailed(requestId, clientReplyStackTrace)); connection.close(); } else if (u instanceof UnsupportedOperationException) {
@Override public void authTokenCheckFailed(WireCommands.AuthTokenCheckFailed authTokenCheckFailed) { result.completeExceptionally( new WireCommandFailedException(new AuthenticationException(authTokenCheckFailed.toString()), type, WireCommandFailedException.Reason.AuthFailed)); } };
} else if (u instanceof AuthenticationException) { log.warn(requestId, "Authentication error during '{}'.", operation); invokeSafely(connection::send, new AuthTokenCheckFailed(requestId, clientReplyStackTrace), failureHandler); connection.close(); } else if (u instanceof UnsupportedOperationException) {
@Test public void testAuthTokenCheckFalied() throws IOException { testCommand(new WireCommands.AuthTokenCheckFailed(l, "")); AtomicReference<Boolean> authTokenCheckFailedCalled = new AtomicReference<>(false); ReplyProcessor rp = new FailingReplyProcessor() { @Override public void connectionDropped() { } @Override public void processingFailure(Exception error) { } @Override public void authTokenCheckFailed(WireCommands.AuthTokenCheckFailed authTokenCheckFailed) { authTokenCheckFailedCalled.set(true); } }; new WireCommands.AuthTokenCheckFailed(0, "").process(rp); assertTrue("Process should call the corresponding API", authTokenCheckFailedCalled.get()); }
@Test public void readSegment() { processor.readSegment(new WireCommands.ReadSegment("segment", 0, 10, "")); verify(connection).send(new WireCommands.AuthTokenCheckFailed(0, "")); }
private void validateAuthTokenCheckFailed(MockConnectionFactory factory, Supplier<CompletableFuture<?>> futureSupplier) { CompletableFuture<?> future = futureSupplier.get(); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", future::join, ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException); }
@Test public void commitTransaction() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Controller.TxnStatus> retVal = helper.commitTransaction("", "", 0L, 0L, new UUID(0, 0L), new MockHostControllerStore(), factory, ""); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void deleteSegment() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Boolean> retVal = helper.deleteSegment("", "", 0L, new MockHostControllerStore(), factory, "", System.nanoTime()); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void createSegment() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Boolean> retVal = helper.createSegment("", "", 0, ScalingPolicy.fixed(2), new MockHostControllerStore(), factory, "", Long.MIN_VALUE); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Override public void authTokenCheckFailed(WireCommands.AuthTokenCheckFailed authTokenCheckFailed) { result.completeExceptionally( new WireCommandFailedException(new AuthenticationException(authTokenCheckFailed.toString()), type, WireCommandFailedException.Reason.AuthFailed)); } };
@Override public void authTokenCheckFailed(WireCommands.AuthTokenCheckFailed authTokenCheckFailed) { result.completeExceptionally( new WireCommandFailedException(new AuthenticationException(authTokenCheckFailed.toString()), type, WireCommandFailedException.Reason.AuthFailed)); } };
@Override public void authTokenCheckFailed(WireCommands.AuthTokenCheckFailed authTokenCheckFailed) { result.completeExceptionally(new AuthenticationException(authTokenCheckFailed.toString())); } };
@Override public void authTokenCheckFailed(WireCommands.AuthTokenCheckFailed authTokenCheckFailed) { log.warn("Auth failed {}", authTokenCheckFailed); failConnection(new AuthenticationException(authTokenCheckFailed.toString())); } }
@Test public void testCompatibilityAuthTokenCheckFailedV5() throws IOException { // Test that we are able to decode a message with a previous version ByteArrayOutputStream bout = new ByteArrayOutputStream(); AuthTokenCheckFailedV5 commandV5 = new AuthTokenCheckFailedV5(l); commandV5.writeFields(new DataOutputStream(bout)); testCommandFromByteArray(bout.toByteArray(), new WireCommands.AuthTokenCheckFailed(l, "")); }
@Test public void updateSegmentPolicy() { processor.updateSegmentPolicy(new WireCommands.UpdateSegmentPolicy(100L, "segment", (byte) 0, 0, "token")); verify(connection).send(new WireCommands.AuthTokenCheckFailed(100L, "")); } }
@Test public void truncateSegment() { processor.truncateSegment(new WireCommands.TruncateSegment(100L, "segment", 0, "token")); verify(connection).send(new WireCommands.AuthTokenCheckFailed(100L, "")); }
@Test public void sealSegment() { processor.sealSegment(new WireCommands.SealSegment(100L, "segment", "token")); verify(connection).send(new WireCommands.AuthTokenCheckFailed(100L, "")); }
@Test public void updateSegmentAttribute() { processor.updateSegmentAttribute(new WireCommands.UpdateSegmentAttribute(100L, "segment", null, 0, 0, "token")); verify(connection).send(new WireCommands.AuthTokenCheckFailed(100L, "")); }
@Test public void updatePolicy() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Void> retVal = helper.updatePolicy("", "", ScalingPolicy.fixed(1), 0L, new MockHostControllerStore(), factory, "", System.nanoTime()); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void createTransaction() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<UUID> retVal = helper.createTransaction("", "", 0L, new UUID(0, 0L), new MockHostControllerStore(), factory, ""); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }