@Test public void deleteUserRoleTest() { Session mockSession = mock(Session.class); when(mappingMapager.getSession()).thenReturn(mockSession); com.intuit.wasabi.authorizationobjects.UserRole userRole = com.intuit.wasabi.authorizationobjects.UserRole .newInstance(Application.Name.valueOf("TestApp"), Role.ADMIN) .withUserID(com.intuit.wasabi.authenticationobjects.UserInfo.Username.valueOf("testuser")) .withLastName("lastname") .withFirstName("firstname") .build(); repository.deleteUserRole(userRole.getUserID(), userRole.getApplicationName()); verify(userRoleAccessor, times(1)).deleteUserRoleStatement(eq("testuser"), eq("TestApp")); verify(appRoleAccessor, times(1)).deleteAppRoleStatement(eq("TestApp"), eq("testuser")); verify(mockSession, times(1)).execute(any(Statement.class)); }
@Override public void deleteUserRole(UserInfo.Username userID, Application.Name applicationName) { BatchStatement batch = new BatchStatement(); batch.add(userRoleAccessor.deleteUserRoleStatement( userID.getUsername(), applicationName.toString() )); batch.add(appRoleAccessor.deleteAppRoleStatement( applicationName.toString(), userID.getUsername() )); manager.getSession().execute(batch); }
CassandraAuthorizationRepository implements AuthorizationRepository { @Override public void deleteUserRole(UserInfo.Username userID, Application.Name applicationName) { BatchStatement batch = new BatchStatement(); batch.add(userRoleAccessor.deleteUserRoleStatement( userID.getUsername(), applicationName.toString() )); batch.add(appRoleAccessor.deleteAppRoleStatement( applicationName.toString(), userID.getUsername() )); manager.getSession().execute(batch); } }
CassandraAuthorizationRepository implements AuthorizationRepository { @Override public void deleteUserRole(UserInfo.Username userID, Application.Name applicationName) { BatchStatement batch = new BatchStatement(); batch.add(userRoleAccessor.deleteUserRoleStatement( userID.getUsername(), applicationName.toString() )); batch.add(appRoleAccessor.deleteAppRoleStatement( applicationName.toString(), userID.getUsername() )); manager.getSession().execute(batch); } @Inject  CassandraAuthorizationRepository(ApplicationListAccessor applicationListAccessor,
                                            AppRoleAccessor appRoleAccessor,
                                            UserRoleAccessor userRoleAccessor,
                                            UserInfoAccessor userInfoAccessor,
                                            UserDirectory userDirectory,
                                            MappingManager mappingManager); }
CassandraAuthorizationRepository implements AuthorizationRepository { @Override public void deleteUserRole(UserInfo.Username userID, Application.Name applicationName) { BatchStatement batch = new BatchStatement(); batch.add(userRoleAccessor.deleteUserRoleStatement( userID.getUsername(), applicationName.toString() )); batch.add(appRoleAccessor.deleteAppRoleStatement( applicationName.toString(), userID.getUsername() )); manager.getSession().execute(batch); } @Inject  CassandraAuthorizationRepository(ApplicationListAccessor applicationListAccessor,
                                            AppRoleAccessor appRoleAccessor,
                                            UserRoleAccessor userRoleAccessor,
                                            UserInfoAccessor userInfoAccessor,
                                            UserDirectory userDirectory,
                                            MappingManager mappingManager); @Override UserPermissionsList getUserPermissionsList(UserInfo.Username userID); @Override UserRoleList getApplicationUsers(Application.Name applicationName); @Override UserPermissions getUserPermissions(@Nonnull UserInfo.Username username,
                                              @Nonnull Application.Name applicationName); @Override void deleteUserRole(UserInfo.Username userID, Application.Name applicationName); @Override void setUserRole(UserRole userRole); @Override UserRoleList getUserRoleList(UserInfo.Username userID); @Override UserInfo getUserInfo(UserInfo.Username userID); @Override void setUserInfo(UserInfo userInfo); @Override UserPermissions checkSuperAdminPermissions(UserInfo.Username userID, Application.Name applicationName); @Override void assignUserToSuperAdminRole(UserInfo candidateUser); @Override void removeUserFromSuperAdminRole(UserInfo candidateUser); @Override List<UserRole> getSuperAdminRoleList(); }
CassandraAuthorizationRepository implements AuthorizationRepository { @Override public void deleteUserRole(UserInfo.Username userID, Application.Name applicationName) { BatchStatement batch = new BatchStatement(); batch.add(userRoleAccessor.deleteUserRoleStatement( userID.getUsername(), applicationName.toString() )); batch.add(appRoleAccessor.deleteAppRoleStatement( applicationName.toString(), userID.getUsername() )); manager.getSession().execute(batch); } @Inject  CassandraAuthorizationRepository(ApplicationListAccessor applicationListAccessor,
                                            AppRoleAccessor appRoleAccessor,
                                            UserRoleAccessor userRoleAccessor,
                                            UserInfoAccessor userInfoAccessor,
                                            UserDirectory userDirectory,
                                            MappingManager mappingManager); @Override UserPermissionsList getUserPermissionsList(UserInfo.Username userID); @Override UserRoleList getApplicationUsers(Application.Name applicationName); @Override UserPermissions getUserPermissions(@Nonnull UserInfo.Username username,
                                              @Nonnull Application.Name applicationName); @Override void deleteUserRole(UserInfo.Username userID, Application.Name applicationName); @Override void setUserRole(UserRole userRole); @Override UserRoleList getUserRoleList(UserInfo.Username userID); @Override UserInfo getUserInfo(UserInfo.Username userID); @Override void setUserInfo(UserInfo userInfo); @Override UserPermissions checkSuperAdminPermissions(UserInfo.Username userID, Application.Name applicationName); @Override void assignUserToSuperAdminRole(UserInfo candidateUser); @Override void removeUserFromSuperAdminRole(UserInfo candidateUser); @Override List<UserRole> getSuperAdminRoleList(); static final String ALL_APPLICATIONS; }