/** * Perform give lambda code block under system auth context. * * see {@link #setSystemAuthorizationContext} and {@link #resetAuthorizationContext} for descriptively * perform logic under system auth context. * * @see #setSystemAuthorizationContext * @see #resetAuthorizationContext */ public static void executeWithSystemAuthContext(ServiceHost host, ExecutableBlock block) { executeWithSystemAuthContext(Arrays.asList(host), block); }
/** * Perform give lambda code block under system auth context. * * see {@link #setSystemAuthorizationContext} and {@link #resetAuthorizationContext} for descriptively * perform logic under system auth context. * * @see #setSystemAuthorizationContext * @see #resetAuthorizationContext */ public static void executeWithSystemAuthContext(ServiceHost host, ExecutableBlock block) { executeWithSystemAuthContext(Arrays.asList(host), block); }
public static void executeWithSystemAuthContext(Collection<ServiceHost> hosts, ExecutableBlock block) { // currently this method does not keep track of existing auth context. // If we need to recover existing auth context, retrieve and set them back in this method. Set<ServiceHost> authEnabledHosts = hosts.stream() .filter(ServiceHost::isAuthorizationEnabled) .collect(toSet()); authEnabledHosts.forEach(AuthTestUtils::setSystemAuthorizationContext); ExceptionTestUtils.executeSafely(block); authEnabledHosts.forEach(AuthTestUtils::resetAuthorizationContext); } }
public static void executeWithSystemAuthContext(Collection<ServiceHost> hosts, ExecutableBlock block) { // currently this method does not keep track of existing auth context. // If we need to recover existing auth context, retrieve and set them back in this method. Set<ServiceHost> authEnabledHosts = hosts.stream() .filter(ServiceHost::isAuthorizationEnabled) .collect(toSet()); authEnabledHosts.forEach(AuthTestUtils::setSystemAuthorizationContext); ExceptionTestUtils.executeSafely(block); authEnabledHosts.forEach(AuthTestUtils::resetAuthorizationContext); } }
@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"); }
AuthTestUtils.executeWithSystemAuthContext(nodeGroup, () -> { nodeGroup.joinNodeGroupAndWaitForConvergence(); nodeGroup.waitForFactoryServiceAvailable(ExampleService.FACTORY_LINK);
AuthTestUtils.executeWithSystemAuthContext(nodeGroup, () -> { nodeGroup.joinNodeGroupAndWaitForConvergence(); nodeGroup.waitForFactoryServiceAvailable(ExampleService.FACTORY_LINK);