/** * Send {@link Operation} using randomly chosen {@link ServiceHost} */ public void sendRequest(Operation op) { getHost().sendRequest(op); }
/** * Attempt to login one of the host in the node group, and expect it to fail. */ public static void loginExpectFailure(TestNodeGroupManager nodeGroup, String username, String password) { ServiceHost peer = nodeGroup.getHost(); loginExpectFailure(peer, username, password); }
/** * Login to one of the node in the node group. * * The nodes in the node group should have same auth policy in order for the login to work * seamlessly on all nodes. * * @return auth token */ public static String login(TestNodeGroupManager nodeGroup, String username, String password) { ServiceHost peer = nodeGroup.getHost(); return login(peer, username, password, true); }
/** * Login to one of the node in the node group. * * The nodes in the node group should have same auth policy in order for the login to work * seamlessly on all nodes. * * @return auth token */ public static String login(TestNodeGroupManager nodeGroup, String username, String password) { ServiceHost peer = nodeGroup.getHost(); return login(peer, username, password, true); }
/** * Attempt to login one of the host in the node group, and expect it to fail. */ public static void loginExpectFailure(TestNodeGroupManager nodeGroup, String username, String password) { ServiceHost peer = nodeGroup.getHost(); loginExpectFailure(peer, username, password); }
/** * Send {@link Operation} using randomly chosen {@link ServiceHost} */ public void sendRequest(Operation op) { getHost().sendRequest(op); }
private TestRequestSender getTestRequestSender() { ServiceHost peer = getHost(); return new TestRequestSender(peer); }
private TestRequestSender getTestRequestSender() { ServiceHost peer = getHost(); return new TestRequestSender(peer); }
/** * Login and set the auth token to be used by {@link TestRequestSender}. * * NOTE: * Auth token is only used by {@link TestRequestSender}. * * @return auth token */ public static String loginAndSetToken(TestNodeGroupManager nodeGroup, String username, String password) { ServiceHost peer = nodeGroup.getHost(); String authToken = login(peer, username, password); TestRequestSender.setAuthToken(authToken); return authToken; }
/** * Login and set the auth token to be used by {@link TestRequestSender}. * * NOTE: * Auth token is only used by {@link TestRequestSender}. * * @return auth token */ public static String loginAndSetToken(TestNodeGroupManager nodeGroup, String username, String password) { ServiceHost peer = nodeGroup.getHost(); String authToken = login(peer, username, password); TestRequestSender.setAuthToken(authToken); return authToken; }
private void verifyCurrentQuorum(TestNodeGroupManager manager, int expectedQuorum) { ServiceHost node = manager.getHost(); TestRequestSender sender = new TestRequestSender(node); String nodeGroupPath = UriUtils.buildUriPath(ServiceUriPaths.NODE_GROUP_FACTORY, manager.getNodeGroupName()); Operation op = Operation.createGet(node, nodeGroupPath); NodeGroupState nodeGroupState = sender.sendAndWait(op, NodeGroupState.class); nodeGroupState.nodes.values().forEach( nodeState -> assertEquals("quorum on host=" + nodeState.id, expectedQuorum, nodeState.membershipQuorum)); }
private void verifyCurrentQuorum(TestNodeGroupManager manager, int expectedQuorum) { ServiceHost node = manager.getHost(); TestRequestSender sender = new TestRequestSender(node); String nodeGroupPath = UriUtils.buildUriPath(ServiceUriPaths.NODE_GROUP_FACTORY, manager.getNodeGroupName()); Operation op = Operation.createGet(node, nodeGroupPath); NodeGroupState nodeGroupState = sender.sendAndWait(op, NodeGroupState.class); nodeGroupState.nodes.values().forEach( nodeState -> assertEquals("quorum on host=" + nodeState.id, expectedQuorum, nodeState.membershipQuorum)); }
ServiceHost peer = nodeGroup.getHost(); TestRequestSender sender = new TestRequestSender(peer);
ServiceHost peer = getHost();
@Test public void testExternalAuthenticationMultinode() throws Throwable { VerificationHost host1 = createAndStartHost(true, false, new TestAuthenticationService()); VerificationHost host2 = createAndStartHost(true, false, new TestAuthenticationService()); VerificationHost host3 = createAndStartHost(true, false, new TestAuthenticationService()); TestNodeGroupManager nodeGroup = new TestNodeGroupManager(); nodeGroup.addHost(host1); nodeGroup.addHost(host2); nodeGroup.addHost(host3); // perform lambda under system auth context AuthTestUtils.executeWithSystemAuthContext(nodeGroup, () -> { nodeGroup.joinNodeGroupAndWaitForConvergence(); // wait the service to be available in cluster nodeGroup.waitForFactoryServiceAvailable("/core/examples"); }); ServiceHost host = nodeGroup.getHost(); // test external auth redirect host1.log("Testing auth service redirect in multi-node"); testExternalAuthRedirectMultinode(host); host1.log("Auth service redirect in multi-node working as expected"); // test external auth token request host1.log("Testing auth service token request in multi-node"); testExternalAuthTokenRequestMultinode(host); host1.log("AuthenticationService token request is working in multi-node"); // test replication with external auth host1.log("Testing replication with external auth in multi-node"); testExternalAuthReplicationMultinode(host); host1.log("Replication with external auth in multi-node is working"); }
@Test public void testExternalAuthenticationMultinode() throws Throwable { VerificationHost host1 = createAndStartHost(true, false, new TestAuthenticationService()); VerificationHost host2 = createAndStartHost(true, false, new TestAuthenticationService()); VerificationHost host3 = createAndStartHost(true, false, new TestAuthenticationService()); TestNodeGroupManager nodeGroup = new TestNodeGroupManager(); nodeGroup.addHost(host1); nodeGroup.addHost(host2); nodeGroup.addHost(host3); // perform lambda under system auth context AuthTestUtils.executeWithSystemAuthContext(nodeGroup, () -> { nodeGroup.joinNodeGroupAndWaitForConvergence(); // wait the service to be available in cluster nodeGroup.waitForFactoryServiceAvailable("/core/examples"); }); ServiceHost host = nodeGroup.getHost(); // test external auth redirect host1.log("Testing auth service redirect in multi-node"); testExternalAuthRedirectMultinode(host); host1.log("Auth service redirect in multi-node working as expected"); // test external auth token request host1.log("Testing auth service token request in multi-node"); testExternalAuthTokenRequestMultinode(host); host1.log("AuthenticationService token request is working in multi-node"); // test replication with external auth host1.log("Testing replication with external auth in multi-node"); testExternalAuthReplicationMultinode(host); host1.log("Replication with external auth in multi-node is working"); }