setUp(this.nodeCount); authHelper = new AuthorizationHelper(this.host);
setUp(this.nodeCount); authHelper = new AuthorizationHelper(this.host);
@Before public void setupRoles() throws Throwable { this.host.setSystemAuthorizationContext(); this.authHelper = new AuthorizationHelper(this.host); this.userServicePath = this.authHelper.createUserService(this.host, "jane@doe.com"); this.authHelper.createRoles(this.host, "jane@doe.com"); this.host.resetAuthorizationContext(); }
@Before public void setupRoles() throws Throwable { this.host.setSystemAuthorizationContext(); this.authHelper = new AuthorizationHelper(this.host); this.userServicePath = this.authHelper.createUserService(this.host, "jane@doe.com"); this.authHelper.createRoles(this.host, "jane@doe.com"); this.host.resetAuthorizationContext(); }
@Before public void setupRoles() throws Throwable { this.host.setSystemAuthorizationContext(); AuthorizationHelper authHelper = new AuthorizationHelper(this.host); this.userServiceJane = authHelper.createUserService(this.host, USER_JANE_EMAIL); authHelper.createRoles(this.host, USER_JANE_EMAIL); this.userServiceJohn = authHelper.createUserService(this.host, USER_JOHN_EMAIL); authHelper.createRoles(this.host, USER_JOHN_EMAIL); this.host.resetAuthorizationContext(); }
@Before public void setupRoles() throws Throwable { this.host.setSystemAuthorizationContext(); AuthorizationHelper authHelper = new AuthorizationHelper(this.host); this.userServiceJane = authHelper.createUserService(this.host, USER_JANE_EMAIL); authHelper.createRoles(this.host, USER_JANE_EMAIL); this.userServiceJohn = authHelper.createUserService(this.host, USER_JOHN_EMAIL); authHelper.createRoles(this.host, USER_JOHN_EMAIL); this.host.resetAuthorizationContext(); }
private String createUsers(VerificationHost host, String userName, String email) throws Throwable { AuthorizationHelper authHelper = new AuthorizationHelper(host); String userServiceLink = authHelper.createUserService(host, email); authHelper.createRoles(host, email); AuthCredentialsServiceState authServiceState = new AuthCredentialsServiceState(); authServiceState.userEmail = email; authServiceState.privateKey = email; URI authUri = UriUtils.buildUri(host, AuthCredentialsService.FACTORY_LINK); TestRequestSender sender = new TestRequestSender(host); sender.sendAndWait(Operation.createPost(authUri).setBody(authServiceState)); return userServiceLink; }
private String createUsers(VerificationHost host, String userName, String email) throws Throwable { AuthorizationHelper authHelper = new AuthorizationHelper(host); String userServiceLink = authHelper.createUserService(host, email); authHelper.createRoles(host, email); AuthCredentialsServiceState authServiceState = new AuthCredentialsServiceState(); authServiceState.userEmail = email; authServiceState.privateKey = email; URI authUri = UriUtils.buildUri(host, AuthCredentialsService.FACTORY_LINK); TestRequestSender sender = new TestRequestSender(host); sender.sendAndWait(Operation.createPost(authUri).setBody(authServiceState)); return userServiceLink; }
try { this.host.setSystemAuthorizationContext(); AuthorizationHelper authsetupHelper = new AuthorizationHelper(this.host); String email = "foo@foo.com"; String userLink = authsetupHelper.createUserService(this.host, email);
try { this.host.setSystemAuthorizationContext(); AuthorizationHelper authsetupHelper = new AuthorizationHelper(this.host); String email = "foo@foo.com"; String userLink = authsetupHelper.createUserService(this.host, email);
AuthorizationHelper authsetupHelper = new AuthorizationHelper(this.host); String email = "foo@foo.com"; String userLink = authsetupHelper.createUserService(this.host, email);
@Test public void testInvalidUserAndResourceGroup() throws Throwable { OperationContext.setAuthorizationContext(this.host.getSystemAuthorizationContext()); AuthorizationHelper authsetupHelper = new AuthorizationHelper(this.host); String email = "foo@foo.com"; String userLink = authsetupHelper.createUserService(this.host, email); Query userGroupQuery = Query.Builder.create().addFieldClause(UserState.FIELD_NAME_EMAIL, email).build(); String userGroupLink = authsetupHelper.createUserGroup(this.host, email, userGroupQuery); authsetupHelper.createRole(this.host, userGroupLink, "foo", EnumSet.allOf(Action.class)); // Assume identity this.host.assumeIdentity(userLink); this.host.sendAndWaitExpectSuccess( Operation.createGet(UriUtils.buildUri(this.host, ExampleService.FACTORY_LINK))); // set an invalid userGroupLink for the user OperationContext.setAuthorizationContext(this.host.getSystemAuthorizationContext()); UserState patchUserState = new UserState(); patchUserState.userGroupLinks = Collections.singleton("foo"); this.host.sendAndWaitExpectSuccess( Operation.createPatch(UriUtils.buildUri(this.host, userLink)).setBody(patchUserState)); this.host.assumeIdentity(userLink); this.host.sendAndWaitExpectSuccess( Operation.createGet(UriUtils.buildUri(this.host, ExampleService.FACTORY_LINK))); }
AuthorizationHelper authsetupHelper = new AuthorizationHelper(this.host); String email = "foo@foo.com"; String userLink = authsetupHelper.createUserService(this.host, email);
@Test public void testInvalidUserAndResourceGroup() throws Throwable { OperationContext.setAuthorizationContext(this.host.getSystemAuthorizationContext()); AuthorizationHelper authsetupHelper = new AuthorizationHelper(this.host); String email = "foo@foo.com"; String userLink = authsetupHelper.createUserService(this.host, email); Query userGroupQuery = Query.Builder.create().addFieldClause(UserState.FIELD_NAME_EMAIL, email).build(); String userGroupLink = authsetupHelper.createUserGroup(this.host, email, userGroupQuery); authsetupHelper.createRole(this.host, userGroupLink, "foo", EnumSet.allOf(Action.class)); // Assume identity this.host.assumeIdentity(userLink); this.host.sendAndWaitExpectSuccess( Operation.createGet(UriUtils.buildUri(this.host, ExampleService.FACTORY_LINK))); // set an invalid userGroupLink for the user OperationContext.setAuthorizationContext(this.host.getSystemAuthorizationContext()); UserState patchUserState = new UserState(); patchUserState.userGroupLinks = Collections.singleton("foo"); this.host.sendAndWaitExpectSuccess( Operation.createPatch(UriUtils.buildUri(this.host, userLink)).setBody(patchUserState)); this.host.assumeIdentity(userLink); this.host.sendAndWaitExpectSuccess( Operation.createGet(UriUtils.buildUri(this.host, ExampleService.FACTORY_LINK))); }
@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())); }
makeUsersWithAuthSetupHelper(); AuthorizationHelper authHelper = new AuthorizationHelper(this.host);
makeUsersWithAuthSetupHelper(); AuthorizationHelper authHelper = new AuthorizationHelper(this.host);
@Test public void testAuthzUtils() throws Throwable { this.host.setSystemAuthorizationContext(); AuthorizationHelper authHelperForFoo = new AuthorizationHelper(this.host); String email = "foo@foo.com"; String fooUserLink = authHelperForFoo.createUserService(this.host, email);
@Test public void testAuthzUtils() throws Throwable { this.host.setSystemAuthorizationContext(); AuthorizationHelper authHelperForFoo = new AuthorizationHelper(this.host); String email = "foo@foo.com"; String fooUserLink = authHelperForFoo.createUserService(this.host, email);