@Test public void getUserRolesWithWildcardAppNameTest() { List<UserRole> userRoleList = new ArrayList<>(); userRoleList.add( UserRole.builder().appName("test").role("test").userId("test").build() ); when(userRoleAccessor.getUserRolesByUserIdWithWildcardAppName(eq("test"))).thenReturn(userRoleResult); when(userRoleResult.iterator()).thenReturn(userRoleList.iterator()); List<UserRole> result = repository.getUserRolesWithWildcardAppName( com.intuit.wasabi.authenticationobjects.UserInfo.Username.valueOf("test"), Application.Name.valueOf("test")); logger.info(result.toString()); assertThat(result.size(), is(1)); }
List<com.intuit.wasabi.repository.cassandra.pojo.UserRole> getUserRolesWithWildcardAppName( UserInfo.Username userID, Application.Name applicationName ) { List<com.intuit.wasabi.repository.cassandra.pojo.UserRole> resultList = Collections.emptyList(); try { Result<com.intuit.wasabi.repository.cassandra.pojo.UserRole> result = userRoleAccessor.getUserRolesByUserIdWithWildcardAppName(userID.getUsername()); resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false) .collect(Collectors.toList()); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve permissions for user \"" + userID + "\" and application " + "\"" + applicationName + "\"", e); } return resultList; }
CassandraAuthorizationRepository implements AuthorizationRepository { List<com.intuit.wasabi.repository.cassandra.pojo.UserRole> getUserRolesWithWildcardAppName( UserInfo.Username userID, Application.Name applicationName ) { List<com.intuit.wasabi.repository.cassandra.pojo.UserRole> resultList = Collections.emptyList(); try { Result<com.intuit.wasabi.repository.cassandra.pojo.UserRole> result = userRoleAccessor.getUserRolesByUserIdWithWildcardAppName(userID.getUsername()); resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false) .collect(Collectors.toList()); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve permissions for user \"" + userID + "\" and application " + "\"" + applicationName + "\"", e); } return resultList; } }
CassandraAuthorizationRepository implements AuthorizationRepository { List<com.intuit.wasabi.repository.cassandra.pojo.UserRole> getUserRolesWithWildcardAppName( UserInfo.Username userID, Application.Name applicationName ) { List<com.intuit.wasabi.repository.cassandra.pojo.UserRole> resultList = Collections.emptyList(); try { Result<com.intuit.wasabi.repository.cassandra.pojo.UserRole> result = userRoleAccessor.getUserRolesByUserIdWithWildcardAppName(userID.getUsername()); resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false) .collect(Collectors.toList()); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve permissions for user \"" + userID + "\" and application " + "\"" + applicationName + "\"", e); } return resultList; } @Inject  CassandraAuthorizationRepository(ApplicationListAccessor applicationListAccessor,
                                            AppRoleAccessor appRoleAccessor,
                                            UserRoleAccessor userRoleAccessor,
                                            UserInfoAccessor userInfoAccessor,
                                            UserDirectory userDirectory,
                                            MappingManager mappingManager); }
CassandraAuthorizationRepository implements AuthorizationRepository { List<com.intuit.wasabi.repository.cassandra.pojo.UserRole> getUserRolesWithWildcardAppName( UserInfo.Username userID, Application.Name applicationName ) { List<com.intuit.wasabi.repository.cassandra.pojo.UserRole> resultList = Collections.emptyList(); try { Result<com.intuit.wasabi.repository.cassandra.pojo.UserRole> result = userRoleAccessor.getUserRolesByUserIdWithWildcardAppName(userID.getUsername()); resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false) .collect(Collectors.toList()); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve permissions for user \"" + userID + "\" and application " + "\"" + applicationName + "\"", e); } return resultList; } @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 { List<com.intuit.wasabi.repository.cassandra.pojo.UserRole> getUserRolesWithWildcardAppName( UserInfo.Username userID, Application.Name applicationName ) { List<com.intuit.wasabi.repository.cassandra.pojo.UserRole> resultList = Collections.emptyList(); try { Result<com.intuit.wasabi.repository.cassandra.pojo.UserRole> result = userRoleAccessor.getUserRolesByUserIdWithWildcardAppName(userID.getUsername()); resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false) .collect(Collectors.toList()); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve permissions for user \"" + userID + "\" and application " + "\"" + applicationName + "\"", e); } return resultList; } @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; }