Service authService = authProvider.getAuthenticationService(); addPrivilegedService(authService.getClass()); setAuthenticationService(authService); authProvider.getAuthenticationServiceSelfLink(), authProvider.getAuthenticationServiceUserLinkBuilder()); Collection<FactoryService> authServiceFactories = authProvider.createServiceFactories(); if ((authServiceFactories != null && !authServiceFactories.isEmpty())) { startFactoryServicesSynchronously(authServiceFactories.toArray(new Service[] {})); Collection<Service> authServices = authProvider.createServices(); if ((authServices != null && !authServices.isEmpty())) { startCoreServicesSynchronously(authServices.toArray(new Service[] {})); .getPrivilegedServices(); if (privilegeServices != null && !privilegeServices.isEmpty()) {
protected ManagementHost startHost(ManagementHost host, URI sandboxUri, List<String> peers) throws Throwable { String hostname = host.getUri().toString() + ":" + host.getSecurePort(); System.out.println("Starting host '" + hostname + "'..."); host = setUpHost(host.getSecurePort(), sandboxUri, peers); TestContext ctx = new TestContext(1, Duration.ofSeconds(DEFAULT_WAIT_SECONDS_FOR_AUTH_SERVICES)); AuthUtil.getPreferredAuthConfigProvider().waitForInitBootConfig(host, host.localUsers, ctx::completeIteration, ctx::failIteration); ctx.await(); System.out.println("Sleep for a while, until the host starts..."); Thread.sleep(4000); System.out.println("Host '" + hostname + "' started."); return host; }
@Test public void testInitConfig() { AuthConfigProvider provider = new LocalAuthConfigProvider(); assertNull(provider.getAuthenticationService()); assertEquals(BasicAuthenticationService.SELF_LINK, provider.getAuthenticationServiceSelfLink()); Function<Claims, String> userLinkBuilder = provider .getAuthenticationServiceUserLinkBuilder(); assertNotNull(userLinkBuilder); Claims claims = new Claims.Builder().setSubject("test@admiral.com").getResult(); String userLink = userLinkBuilder.apply(claims); assertEquals(UserService.FACTORY_LINK + "/test@admiral.com", userLink); Function<Claims, String> userFactoryLinkBuilder = provider .getAuthenticationServiceUserFactoryLinkBuilder(); assertNotNull(userFactoryLinkBuilder); String userFactoryLink = userFactoryLinkBuilder.apply(claims); assertEquals(UserService.FACTORY_LINK, userFactoryLink); assertTrue(provider.createServiceFactories().isEmpty()); } }
@Override public void handleStart(Operation post) { AuthConfigProvider provider = AuthUtil.getPreferredAuthConfigProvider(); if (!ServiceHost.isServiceCreate(post)) { // do not perform bootstrap logic when the post is NOT from direct client, eg: node // restart provider.initConfig(getHost(), post, null); post.complete(); return; } provider.initBootConfig(getHost(), post, null); provider.initConfig(getHost(), post, null); post.complete(); }
@BeforeClass public static void setUp() throws Throwable { sandbox.create(); String configFile = ManagementHostTest.class.getResource(LOCAL_USERS_FILE).toURI() .getPath(); host = ManagementHostBaseTest.createManagementHost(new String[] { CommandLineArgumentParser.ARGUMENT_PREFIX + HostInitDockerAdapterServiceConfig.FIELD_NAME_START_MOCK_HOST_ADAPTER_INSTANCE + CommandLineArgumentParser.ARGUMENT_ASSIGNMENT + Boolean.TRUE.toString(), CommandLineArgumentParser.ARGUMENT_PREFIX + AuthUtil.LOCAL_USERS_FILE + CommandLineArgumentParser.ARGUMENT_ASSIGNMENT + configFile, CommandLineArgumentParser.ARGUMENT_PREFIX + "sandbox" + CommandLineArgumentParser.ARGUMENT_ASSIGNMENT // generate a random sandbox + sandbox.getRoot().toPath(), CommandLineArgumentParser.ARGUMENT_PREFIX + "port" + CommandLineArgumentParser.ARGUMENT_ASSIGNMENT // ask runtime to pick a random port + "0" }); TestContext ctx = new TestContext(1, Duration.ofSeconds(DEFAULT_WAIT_SECONDS_FOR_AUTH_SERVICES)); AuthUtil.getPreferredAuthConfigProvider().waitForInitBootConfig(host, host.localUsers, ctx::completeIteration, ctx::failIteration); ctx.await(); }
@Before public void beforeForAuthBase() throws Throwable { AuthUtil.resetProviders(); host.setSystemAuthorizationContext(); startServices(host); waitForServiceAvailability(AuthInitialBootService.SELF_LINK); waitForInitialBootServiceToBeSelfStopped(AuthInitialBootService.SELF_LINK); waitForDefaultRoles(); waitForDefaultUsersAndGroups(); TestContext ctx = new TestContext(1, Duration.ofSeconds(DEFAULT_WAIT_SECONDS_FOR_AUTH_SERVICES)); AuthUtil.getPreferredAuthConfigProvider().waitForInitBootConfig(host, ((CustomizationVerificationHost) host).localUsers, ctx::completeIteration, ctx::failIteration); ctx.await(); privilegedTestService = host.startServiceAndWait(PrivilegedTestService.class, PrivilegedTestService.SELF_LINK); host.resetAuthorizationContext(); testService = new TestService(); testService.setSelfLink(TestService.SELF_LINK); testService.setHost(host); }
TestContext ctx = new TestContext(1, Duration.ofSeconds(DEFAULT_WAIT_SECONDS_FOR_AUTH_SERVICES)); AuthUtil.getPreferredAuthConfigProvider().waitForInitBootConfig(host, ((CustomizationVerificationHost) host).localUsers, ctx::completeIteration, ctx::failIteration);