@Override protected void setPrivilegedServices(VerificationHost host) { host.addPrivilegedService(SessionService.class); host.addPrivilegedService(PrincipalService.class); host.addPrivilegedService(ProjectService.class); host.addPrivilegedService(ProjectFactoryService.class); host.addPrivilegedService(PrivilegedTestService.class); }
/** * This is needed for photon-model testing to make sure reflection is working. */ @Override public void addPrivilegedService(Class<? extends Service> serviceType) { super.addPrivilegedService(serviceType); }
@Override protected void setPrivilegedServices(VerificationHost host) { host.addPrivilegedService(SessionService.class); host.addPrivilegedService(PrincipalService.class); host.addPrivilegedService(ProjectService.class); host.addPrivilegedService(ProjectFactoryService.class); }
@Before public void beforeForComputeBase() throws Throwable { host.addPrivilegedService(ContainerHostDataCollectionService.class); startServices(host); waitForInitialBootServiceToBeSelfStopped(ComputeInitialBootService.SELF_LINK); }
@Override public void beforeHostStart(VerificationHost host) throws Throwable { host.setMaintenanceIntervalMicros(TimeUnit.MILLISECONDS.toMicros( VerificationHost.FAST_MAINT_INTERVAL_MILLIS)); this.host.addPrivilegedService(InMemoryLuceneDocumentIndexService.class); this.host.startServiceAndWait(InMemoryLuceneDocumentIndexService.class, InMemoryLuceneDocumentIndexService.SELF_LINK); this.host.startFactory(InMemoryExampleService.class, InMemoryExampleService::createFactory); this.host.startFactory(ExampleODLService.class, ExampleODLService::createFactory); }
@Override public void beforeHostStart(VerificationHost host) throws Throwable { host.setMaintenanceIntervalMicros(TimeUnit.MILLISECONDS.toMicros( VerificationHost.FAST_MAINT_INTERVAL_MILLIS)); this.host.addPrivilegedService(InMemoryLuceneDocumentIndexService.class); this.host.startServiceAndWait(InMemoryLuceneDocumentIndexService.class, InMemoryLuceneDocumentIndexService.SELF_LINK); this.host.startFactory(InMemoryExampleService.class, InMemoryExampleService::createFactory); this.host.startFactory(ExampleODLService.class, ExampleODLService::createFactory); }
private boolean checkCacheInAllPeers(String token, boolean expectEntries) throws Throwable { for (VerificationHost peer : this.host.getInProcessHostMap().values()) { peer.setSystemAuthorizationContext(); MinimalTestService s = new MinimalTestService(); peer.addPrivilegedService(MinimalTestService.class); peer.startServiceAndWait(s, UUID.randomUUID().toString(), null); peer.resetSystemAuthorizationContext(); boolean contextFound = peer.getAuthorizationContext(s, token) != null; if ((expectEntries && !contextFound) || (!expectEntries && contextFound)) { return false; } } return true; }
private boolean checkCacheInAllPeers(String token, boolean expectEntries) throws Throwable { for (VerificationHost peer : this.host.getInProcessHostMap().values()) { peer.setSystemAuthorizationContext(); MinimalTestService s = new MinimalTestService(); peer.addPrivilegedService(MinimalTestService.class); peer.startServiceAndWait(s, UUID.randomUUID().toString(), null); peer.resetSystemAuthorizationContext(); boolean contextFound = peer.getAuthorizationContext(s, token) != null; if ((expectEntries && !contextFound) || (!expectEntries && contextFound)) { return false; } } return true; }
private VerificationHost restartHost(VerificationHost hostToRestart) throws Throwable { this.host.stopHostAndPreserveState(hostToRestart); this.host.waitForNodeGroupConvergence(this.nodeCount - 1, this.nodeCount - 1); hostToRestart.setPort(0); VerificationHost.restartStatefulHost(hostToRestart, false); // Start in-memory index service, and in-memory example factory. hostToRestart.addPrivilegedService(InMemoryLuceneDocumentIndexService.class); hostToRestart.startFactory(InMemoryExampleService.class, InMemoryExampleService::createFactory); hostToRestart.startServiceAndWait(InMemoryLuceneDocumentIndexService.class, InMemoryLuceneDocumentIndexService.SELF_LINK); hostToRestart.addPrivilegedService(ExampleODLService.class); hostToRestart.startFactory(ExampleODLService.class, ExampleODLService::createFactory); this.host.addPeerNode(hostToRestart); this.host.joinNodesAndVerifyConvergence(this.nodeCount); return hostToRestart; }
private VerificationHost restartHost(VerificationHost hostToRestart) throws Throwable { this.host.stopHostAndPreserveState(hostToRestart); this.host.waitForNodeGroupConvergence(this.nodeCount - 1, this.nodeCount - 1); hostToRestart.setPort(0); VerificationHost.restartStatefulHost(hostToRestart, false); // Start in-memory index service, and in-memory example factory. hostToRestart.addPrivilegedService(InMemoryLuceneDocumentIndexService.class); hostToRestart.startFactory(InMemoryExampleService.class, InMemoryExampleService::createFactory); hostToRestart.startServiceAndWait(InMemoryLuceneDocumentIndexService.class, InMemoryLuceneDocumentIndexService.SELF_LINK); hostToRestart.addPrivilegedService(ExampleODLService.class); hostToRestart.startFactory(ExampleODLService.class, ExampleODLService::createFactory); this.host.addPeerNode(hostToRestart); this.host.joinNodesAndVerifyConvergence(this.nodeCount); return hostToRestart; }
@Before public void setUp() throws Throwable { host.addPrivilegedService(ContainerHostDataCollectionService.class); startServices(host); setUpDockerHostAuthentication(); // setup Docker Host: createResourcePool(); // setup Group Placement: groupPlacementState = createGroupResourcePlacement(resourcePool); dockerHostDesc = createDockerHostDescription(); createDockerHost(dockerHostDesc, resourcePool); createHostPortProfile(); // setup Container desc: createContainerDescription(); // setup Container Network description. createContainerNetworkDescription(UUID.randomUUID().toString()); // setup Container Volume description. createContainerVolumeDescription(UUID.randomUUID().toString()); }
private VerificationHost createVerificationHost() throws Throwable { VerificationHost host = VerificationHost.create(0); host.start(); // in-memory index related services host.addPrivilegedService(InMemoryLuceneDocumentIndexService.class); InMemoryLuceneDocumentIndexService inMemoryIndexService = new InMemoryLuceneDocumentIndexService(); Service inMemoryExampleFactory = InMemoryExampleService.createFactory(); host.startService(Operation.createPost(host, ServiceUriPaths.CORE_IN_MEMORY_DOCUMENT_INDEX), inMemoryIndexService); host.startService(Operation.createPost(host, InMemoryExampleService.FACTORY_LINK), inMemoryExampleFactory); host.waitForServiceAvailable(ServiceUriPaths.CORE_IN_MEMORY_DOCUMENT_INDEX, InMemoryExampleService.FACTORY_LINK); return host; }
private VerificationHost createVerificationHost() throws Throwable { VerificationHost host = VerificationHost.create(0); host.start(); // in-memory index related services host.addPrivilegedService(InMemoryLuceneDocumentIndexService.class); InMemoryLuceneDocumentIndexService inMemoryIndexService = new InMemoryLuceneDocumentIndexService(); Service inMemoryExampleFactory = InMemoryExampleService.createFactory(); host.startService(Operation.createPost(host, ServiceUriPaths.CORE_IN_MEMORY_DOCUMENT_INDEX), inMemoryIndexService); host.startService(Operation.createPost(host, InMemoryExampleService.FACTORY_LINK), inMemoryExampleFactory); host.waitForServiceAvailable(ServiceUriPaths.CORE_IN_MEMORY_DOCUMENT_INDEX, InMemoryExampleService.FACTORY_LINK); return host; }
this.host.addPrivilegedService(PrivilegedStopOrderTestService.class); List<PrivilegedStopOrderTestService> pServices = new ArrayList<>(); this.host.testStart(serviceCount);
private void setUpMultiNode() throws Throwable { this.host.setUpPeerHosts(this.nodeCount); this.host.joinNodesAndVerifyConvergence(this.nodeCount); URI exampleFactoryUri = UriUtils.buildUri( this.host.getPeerServiceUri(ExampleService.FACTORY_LINK)); this.host.waitForReplicatedFactoryServiceAvailable(exampleFactoryUri); // expire node that went away quickly to avoid alot of log spam from gossip failures NodeGroupService.NodeGroupConfig cfg = new NodeGroupService.NodeGroupConfig(); cfg.nodeRemovalDelayMicros = TimeUnit.SECONDS.toMicros(1); this.host.setNodeGroupConfig(cfg); for (VerificationHost h : this.host.getInProcessHostMap().values()) { h.addPrivilegedService(InMemoryLuceneDocumentIndexService.class); h.startCoreServicesSynchronously(new InMemoryLuceneDocumentIndexService()); h.startFactory(new InMemoryExampleService()); h.startFactory(new ExampleODLService()); } URI inMemoryExampleFactoryUri = UriUtils.buildUri( this.host.getPeerServiceUri(InMemoryExampleService.FACTORY_LINK)); this.host.waitForReplicatedFactoryServiceAvailable(inMemoryExampleFactoryUri); URI ODLExampleFactoryUri = UriUtils.buildUri( this.host.getPeerServiceUri(ExampleODLService.FACTORY_LINK)); this.host.waitForReplicatedFactoryServiceAvailable(ODLExampleFactoryUri); }
private void setUpMultiNode() throws Throwable { this.host.setUpPeerHosts(this.nodeCount); this.host.joinNodesAndVerifyConvergence(this.nodeCount); URI exampleFactoryUri = UriUtils.buildUri( this.host.getPeerServiceUri(ExampleService.FACTORY_LINK)); this.host.waitForReplicatedFactoryServiceAvailable(exampleFactoryUri); // expire node that went away quickly to avoid alot of log spam from gossip failures NodeGroupService.NodeGroupConfig cfg = new NodeGroupService.NodeGroupConfig(); cfg.nodeRemovalDelayMicros = TimeUnit.SECONDS.toMicros(1); this.host.setNodeGroupConfig(cfg); for (VerificationHost h : this.host.getInProcessHostMap().values()) { h.addPrivilegedService(InMemoryLuceneDocumentIndexService.class); h.startCoreServicesSynchronously(new InMemoryLuceneDocumentIndexService()); h.startFactory(new InMemoryExampleService()); h.startFactory(new ExampleODLService()); } URI inMemoryExampleFactoryUri = UriUtils.buildUri( this.host.getPeerServiceUri(InMemoryExampleService.FACTORY_LINK)); this.host.waitForReplicatedFactoryServiceAvailable(inMemoryExampleFactoryUri); URI ODLExampleFactoryUri = UriUtils.buildUri( this.host.getPeerServiceUri(ExampleODLService.FACTORY_LINK)); this.host.waitForReplicatedFactoryServiceAvailable(ODLExampleFactoryUri); }
@Test public void authCacheClearToken() throws Throwable { this.host.setSystemAuthorizationContext(); AuthorizationHelper authHelperForFoo = new AuthorizationHelper(this.host); String email = "foo@foo.com"; String fooUserLink = authHelperForFoo.createUserService(this.host, email); // spin up a privileged service to query for auth context MinimalTestService s = new MinimalTestService(); this.host.addPrivilegedService(MinimalTestService.class); this.host.startServiceAndWait(s, UUID.randomUUID().toString(), null); this.host.resetSystemAuthorizationContext(); AuthorizationContext authContext1 = assumeIdentityAndGetContext(fooUserLink, s, true); AuthorizationContext authContext2 = assumeIdentityAndGetContext(fooUserLink, s, true); assertNotNull(authContext1); assertNotNull(authContext2); this.host.setSystemAuthorizationContext(); Operation clearAuthOp = new Operation(); clearAuthOp.setUri(UriUtils.buildUri(this.host, fooUserLink)); TestContext ctx = this.host.testCreate(1); clearAuthOp.setCompletion(ctx.getCompletion()); AuthorizationCacheUtils.clearAuthzCacheForUser(s, clearAuthOp); clearAuthOp.complete(); this.host.testWait(ctx); this.host.resetSystemAuthorizationContext(); assertNull(this.host.getAuthorizationContext(s, authContext1.getToken())); assertNull(this.host.getAuthorizationContext(s, authContext2.getToken())); }
@Test public void authCacheClearToken() throws Throwable { this.host.setSystemAuthorizationContext(); AuthorizationHelper authHelperForFoo = new AuthorizationHelper(this.host); String email = "foo@foo.com"; String fooUserLink = authHelperForFoo.createUserService(this.host, email); // spin up a privileged service to query for auth context MinimalTestService s = new MinimalTestService(); this.host.addPrivilegedService(MinimalTestService.class); this.host.startServiceAndWait(s, UUID.randomUUID().toString(), null); this.host.resetSystemAuthorizationContext(); AuthorizationContext authContext1 = assumeIdentityAndGetContext(fooUserLink, s, true); AuthorizationContext authContext2 = assumeIdentityAndGetContext(fooUserLink, s, true); assertNotNull(authContext1); assertNotNull(authContext2); this.host.setSystemAuthorizationContext(); Operation clearAuthOp = new Operation(); clearAuthOp.setUri(UriUtils.buildUri(this.host, fooUserLink)); TestContext ctx = this.host.testCreate(1); clearAuthOp.setCompletion(ctx.getCompletion()); AuthorizationCacheUtils.clearAuthzCacheForUser(s, clearAuthOp); clearAuthOp.complete(); this.host.testWait(ctx); this.host.resetSystemAuthorizationContext(); assertNull(this.host.getAuthorizationContext(s, authContext1.getToken())); assertNull(this.host.getAuthorizationContext(s, authContext2.getToken())); }
@Test public void testExpiredAuthorizationContext() throws Throwable { this.host.setSystemAuthorizationContext(); this.host.addPrivilegedService(SetAuthorizationContextTestService.class); this.host.startServiceAndWait(SetAuthorizationContextTestService.class, SetAuthorizationContextTestService.SELF_LINK);
@Test public void testExpiredAuthorizationContext() throws Throwable { this.host.setSystemAuthorizationContext(); this.host.addPrivilegedService(SetAuthorizationContextTestService.class); this.host.startServiceAndWait(SetAuthorizationContextTestService.class, SetAuthorizationContextTestService.SELF_LINK);