@Test void testSpaceDevelopersCache() { setUpMocks(true, true, null); when(client.getSpaceDevelopers(UUID.fromString(SPACE_ID))).thenReturn(Collections.singletonList(USER_ID)); when(client.getSpaceDevelopers(UUID.fromString(SECOND_SPACE_ID))).thenReturn(Collections.singletonList(USER_ID)); assertTrue(authorizationChecker.checkPermissions(userInfo, SPACE_ID, false)); Mockito.verify(client, Mockito.times(1)) .getSpaceDevelopers(Mockito.eq(UUID.fromString(SPACE_ID))); assertTrue(authorizationChecker.checkPermissions(userInfo, SPACE_ID, false)); Mockito.verify(client, Mockito.times(1)) .getSpaceDevelopers(Mockito.eq(UUID.fromString(SPACE_ID))); assertTrue(authorizationChecker.checkPermissions(userInfo, SECOND_SPACE_ID, false)); Mockito.verify(client, Mockito.times(1)) .getSpaceDevelopers(Mockito.eq(UUID.fromString(SPACE_ID))); Mockito.verify(client, Mockito.times(1)) .getSpaceDevelopers(Mockito.eq(UUID.fromString(SECOND_SPACE_ID))); }
boolean checkPermissions(UserInfo userInfo, String orgName, String spaceName, boolean readOnly) { if (hasAdminScope(userInfo)) { return true; } CloudControllerClient client = clientProvider.getControllerClient(userInfo.getName()); UUID userGuid = UUID.fromString(userInfo.getId()); return hasPermissions(client, userGuid, orgName, spaceName, readOnly) && hasAccess(client, orgName, spaceName); }
AuthorizationChecker { boolean checkPermissions(UserInfo userInfo, String orgName, String spaceName, boolean readOnly) { if (hasAdminScope(userInfo)) { return true; } CloudControllerClient client = clientProvider.getControllerClient(userInfo.getName()); UUID userGuid = UUID.fromString(userInfo.getId()); return hasPermissions(client, userGuid, orgName, spaceName, readOnly) && hasAccess(client, orgName, spaceName); } }
AuthorizationChecker { boolean checkPermissions(UserInfo userInfo, String orgName, String spaceName, boolean readOnly) { if (hasAdminScope(userInfo)) { return true; } CloudControllerClient client = clientProvider.getControllerClient(userInfo.getName()); UUID userGuid = UUID.fromString(userInfo.getId()); return hasPermissions(client, userGuid, orgName, spaceName, readOnly) && hasAccess(client, orgName, spaceName); } @Inject  AuthorizationChecker(CloudControllerClientProvider clientProvider, ApplicationConfiguration applicationConfiguration); }
AuthorizationChecker { boolean checkPermissions(UserInfo userInfo, String orgName, String spaceName, boolean readOnly) { if (hasAdminScope(userInfo)) { return true; } CloudControllerClient client = clientProvider.getControllerClient(userInfo.getName()); UUID userGuid = UUID.fromString(userInfo.getId()); return hasPermissions(client, userGuid, orgName, spaceName, readOnly) && hasAccess(client, orgName, spaceName); } @Inject  AuthorizationChecker(CloudControllerClientProvider clientProvider, ApplicationConfiguration applicationConfiguration); void ensureUserIsAuthorized(HttpServletRequest request, UserInfo userInfo, CloudTarget target, String action); void ensureUserIsAuthorized(HttpServletRequest request, UserInfo userInfo, String spaceGuid, String action); ClientHelper getClientHelper(CloudControllerClient client); }
AuthorizationChecker { boolean checkPermissions(UserInfo userInfo, String orgName, String spaceName, boolean readOnly) { if (hasAdminScope(userInfo)) { return true; } CloudControllerClient client = clientProvider.getControllerClient(userInfo.getName()); UUID userGuid = UUID.fromString(userInfo.getId()); return hasPermissions(client, userGuid, orgName, spaceName, readOnly) && hasAccess(client, orgName, spaceName); } @Inject  AuthorizationChecker(CloudControllerClientProvider clientProvider, ApplicationConfiguration applicationConfiguration); void ensureUserIsAuthorized(HttpServletRequest request, UserInfo userInfo, CloudTarget target, String action); void ensureUserIsAuthorized(HttpServletRequest request, UserInfo userInfo, String spaceGuid, String action); ClientHelper getClientHelper(CloudControllerClient client);  }