Skip to content

Commit

Permalink
Merge pull request #4365 from cloudfoundry/space-dev-perms-2
Browse files Browse the repository at this point in the history
Fix last two cf role permission bugs
  • Loading branch information
richard-cox authored Jun 18, 2020
2 parents f1b99b0 + fa54046 commit b438b10
Show file tree
Hide file tree
Showing 28 changed files with 43 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ import { APIResource } from '../../../../store/src/types/api.types';
import { EndpointModel } from '../../../../store/src/types/endpoint.types';
import { PaginatedAction, PaginationEntityState } from '../../../../store/src/types/pagination.types';
import { IServiceInstance, IUserProvidedServiceInstance } from '../../cf-api-svc.types';
import { CFFeatureFlagTypes, ISpace } from '../../cf-api.types';
import { CFFeatureFlagTypes, IApp, ISpace } from '../../cf-api.types';
import { cfEntityFactory } from '../../cf-entity-factory';
import { CFEntityConfig } from '../../cf-types';
import { ListCfRoute } from '../../shared/components/list/list-types/cf-routes/cf-routes-data-source-base';
import {
CfUser,
CfUserRoleParams,
Expand Down Expand Up @@ -350,20 +351,25 @@ export function fetchTotalResults(
);
}

type CfOrgSpaceFilterTypes = IApp | ListCfRoute | IServiceInstance;
export const cfOrgSpaceFilter = (entities: APIResource[], paginationState: PaginationEntityState) => {
// Filtering is done remotely when maxedResults are hit (see `setMultiFilter`)
if (!!paginationState.maxedState.isMaxedMode && !paginationState.maxedState.ignoreMaxed) {
return entities;
}

const fetchOrgGuid = (e: APIResource<CfOrgSpaceFilterTypes>): string => {
return e.entity.space ? e.entity.space.entity.organization_guid : null;
}

// Filter by cf/org/space
const cfGuid = paginationState.clientPagination.filter.items.cf;
const orgGuid = paginationState.clientPagination.filter.items.org;
const spaceGuid = paginationState.clientPagination.filter.items.space;
return !cfGuid && !orgGuid && !spaceGuid ? entities : entities.filter(e => {
e = extractActualListEntity(e);
const validCF = !(cfGuid && cfGuid !== e.entity.cfGuid);
const validOrg = !(orgGuid && orgGuid !== e.entity.space.entity.organization_guid);
const validOrg = !(orgGuid && orgGuid !== fetchOrgGuid(e));
const validSpace = !(spaceGuid && spaceGuid !== e.entity.space_guid);
return validCF && validOrg && validSpace;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class CfRoleCheckboxComponent implements OnInit, OnDestroy {


@Input() cfGuid: string;
@Input() orgGuid: string;
@Input() spaceGuid: string;
@Input() orgName: string;
@Input() spaceName: string;
Expand All @@ -60,7 +61,6 @@ export class CfRoleCheckboxComponent implements OnInit, OnDestroy {
sub: Subscription;
isOrgRole = false;
disabled = false;
orgGuid: string;

private static hasExistingRole(role: string, roles: CfUserRolesSelected, userGuid: string, orgGuid: string, spaceGuid: string): boolean {
if (roles && roles[userGuid] && roles[userGuid][orgGuid]) {
Expand Down Expand Up @@ -266,7 +266,6 @@ export class CfRoleCheckboxComponent implements OnInit, OnDestroy {
combineLatestOp(this.cfRolesService.newRoles$, users$, canEditRole$, selectUsersIsSetByUsername$),
filter(([existingRoles, newRoles, users, canEditRole, isSetByUsername]) => !!users.length && !!newRoles.orgGuid)
).subscribe(([existingRoles, newRoles, users, canEditRole, isSetByUsername]) => {
this.orgGuid = newRoles.orgGuid;
const { checked, tooltip } = CfRoleCheckboxComponent.getCheckedState(
this.role, users, existingRoles, newRoles, this.orgGuid, this.spaceGuid);
this.checked = checked;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<app-cf-role-checkbox [cfGuid]="row.entity.cfGuid"
[orgGuid]="config.isSpace ? row?.entity.organization?.metadata.guid : row?.metadata.guid"
[orgName]="config.isSpace ? row?.entity.organization?.entity.name : row?.entity.name"
[spaceName]="config.isSpace ? row?.entity.name : null" [spaceGuid]="config.isSpace ? row.metadata.guid : ''"
[role]="config.role"></app-cf-role-checkbox>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { browser } from 'protractor';

import { e2e } from '../e2e';
import { CFHelpers } from '../helpers/cf-helpers';
import { CFHelpers } from '../helpers/cf-e2e-helpers';
import { ConsoleUserType } from '../helpers/e2e-helpers';
import { CREATE_APP_DEPLOY_TEST_TYPE, createApplicationDeployTests } from './application-deploy-helper';
import { ApplicationE2eHelper } from './application-e2e-helpers';
Expand Down
2 changes: 1 addition & 1 deletion src/test-e2e/application/application-deploy-e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { browser, promise } from 'protractor';

import { e2e } from '../e2e';
import { CFHelpers } from '../helpers/cf-helpers';
import { CFHelpers } from '../helpers/cf-e2e-helpers';
import { ConsoleUserType } from '../helpers/e2e-helpers';
import { ConfirmDialogComponent } from '../po/confirm-dialog';
import { createApplicationDeployTests } from './application-deploy-helper';
Expand Down
2 changes: 1 addition & 1 deletion src/test-e2e/application/application-e2e-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IApp, IRoute, ISpace } from '../../frontend/packages/cloud-foundry/src/
import { APIResource } from '../../frontend/packages/store/src/types/api.types';
import { e2e, E2ESetup } from '../e2e';
import { E2EConfigCloudFoundry } from '../e2e.types';
import { CFHelpers } from '../helpers/cf-helpers';
import { CFHelpers } from '../helpers/cf-e2e-helpers';
import { CFRequestHelpers } from '../helpers/cf-request-helpers';
import { E2EHelpers } from '../helpers/e2e-helpers';

Expand Down
2 changes: 1 addition & 1 deletion src/test-e2e/application/application-routes-e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { browser, promise, protractor } from 'protractor';
import { IApp } from '../../frontend/packages/cloud-foundry/src/cf-api.types';
import { APIResource } from '../../frontend/packages/store/src/types/api.types';
import { e2e } from '../e2e';
import { CFHelpers } from '../helpers/cf-helpers';
import { CFHelpers } from '../helpers/cf-e2e-helpers';
import { ConsoleUserType } from '../helpers/e2e-helpers';
import { ConfirmDialogComponent } from '../po/confirm-dialog';
import { ApplicationE2eHelper } from './application-e2e-helpers';
Expand Down
2 changes: 1 addition & 1 deletion src/test-e2e/application/application-view-e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IApp } from '../../frontend/packages/cloud-foundry/src/cf-api.types';
import { APIResource } from '../../frontend/packages/store/src/types/api.types';
import { ApplicationsPage } from '../applications/applications.po';
import { e2e } from '../e2e';
import { CFHelpers } from '../helpers/cf-helpers';
import { CFHelpers } from '../helpers/cf-e2e-helpers';
import { ConsoleUserType, E2EHelpers } from '../helpers/e2e-helpers';
import { ApplicationE2eHelper } from './application-e2e-helpers';
import { ApplicationPageEventsTab } from './po/application-page-events.po';
Expand Down
2 changes: 1 addition & 1 deletion src/test-e2e/applications/application-wall-e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { APIResource } from '../../frontend/packages/store/src/types/api.types';
import { ApplicationE2eHelper } from '../application/application-e2e-helpers';
import { e2e } from '../e2e';
import { E2EConfigCloudFoundry } from '../e2e.types';
import { CFHelpers } from '../helpers/cf-helpers';
import { CFHelpers } from '../helpers/cf-e2e-helpers';
import { ConsoleUserType, E2EHelpers } from '../helpers/e2e-helpers';
import { extendE2ETestTime } from '../helpers/extend-test-helpers';
import { FormComponent } from '../po/form.po';
Expand Down
2 changes: 1 addition & 1 deletion src/test-e2e/cloud-foundry/cf-level/manage-org-e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { by, element, promise, protractor } from 'protractor';

import { e2e } from '../../e2e';
import { CFHelpers } from '../../helpers/cf-helpers';
import { CFHelpers } from '../../helpers/cf-e2e-helpers';
import { ConsoleUserType, E2EHelpers } from '../../helpers/e2e-helpers';
import { CfOrgLevelPage } from '../org-level/cf-org-level-page.po';
import { CfTopLevelPage } from './cf-top-level-page.po';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { by, element, promise, protractor } from 'protractor';

import { e2e } from '../../e2e';
import { CFHelpers } from '../../helpers/cf-helpers';
import { CFHelpers } from '../../helpers/cf-e2e-helpers';
import { ConsoleUserType, E2EHelpers } from '../../helpers/e2e-helpers';
import { extendE2ETestTime } from '../../helpers/extend-test-helpers';
import { TableComponent } from '../../po/table.po';
Expand Down
2 changes: 1 addition & 1 deletion src/test-e2e/cloud-foundry/invite-users-e2e.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { browser, promise } from 'protractor';

import { e2e } from '../e2e';
import { E2EConfigCloudFoundry } from '../e2e.types';
import { CFHelpers } from '../helpers/cf-helpers';
import { CFHelpers } from '../helpers/cf-e2e-helpers';
import { ConsoleUserType } from '../helpers/e2e-helpers';
import { extendE2ETestTime } from '../helpers/extend-test-helpers';
import { CFUsersListComponent } from '../po/cf-users-list.po';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { browser, by, element, promise } from 'protractor';
import { CfUser } from '../../frontend/packages/cloud-foundry/src/store/types/cf-user.types';
import { APIResource } from '../../frontend/packages/store/src/types/api.types';
import { e2e } from '../e2e';
import { CFHelpers } from '../helpers/cf-helpers';
import { CFHelpers } from '../helpers/cf-e2e-helpers';
import { ConsoleUserType, E2EHelpers } from '../helpers/e2e-helpers';
import { UaaHelpers } from '../helpers/uaa-helpers';
import { CFUsersListComponent } from '../po/cf-users-list.po';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { browser, by, element, protractor } from 'protractor';

import { e2e } from '../e2e';
import { CFHelpers } from '../helpers/cf-helpers';
import { CFHelpers } from '../helpers/cf-e2e-helpers';
import { E2EHelpers } from '../helpers/e2e-helpers';
import { extendE2ETestTime } from '../helpers/extend-test-helpers';
import { CFUsersListComponent } from '../po/cf-users-list.po';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { by, element, protractor } from 'protractor';

import { e2e } from '../../e2e';
import { CFHelpers } from '../../helpers/cf-helpers';
import { CFHelpers } from '../../helpers/cf-e2e-helpers';
import { ConsoleUserType, E2EHelpers } from '../../helpers/e2e-helpers';
import { CfTopLevelPage } from '../cf-level/cf-top-level-page.po';
import { CFPage } from '../../po/cf-page.po';
import { SideNavMenuItem } from '../../po/side-nav.po';
import { CfTopLevelPage } from '../cf-level/cf-top-level-page.po';

describe('Delete Organization', () => {
let e2eSetup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { by, element, promise, protractor } from 'protractor';

import { e2e } from '../../e2e';
import { CFHelpers } from '../../helpers/cf-helpers';
import { CFHelpers } from '../../helpers/cf-e2e-helpers';
import { ConsoleUserType, E2EHelpers } from '../../helpers/e2e-helpers';
import { extendE2ETestTime } from '../../helpers/extend-test-helpers';
import { CfOrgLevelPage } from '../org-level/cf-org-level-page.po';
Expand Down
4 changes: 2 additions & 2 deletions src/test-e2e/cloud-foundry/org-level/mange-space-e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { by, element, promise, protractor } from 'protractor';

import { e2e } from '../../e2e';
import { CFHelpers } from '../../helpers/cf-helpers';
import { CFHelpers } from '../../helpers/cf-e2e-helpers';
import { ConsoleUserType, E2EHelpers } from '../../helpers/e2e-helpers';
import { TableComponent } from '../../po/table.po';
import { CfSpaceLevelPage } from '../space-level/cf-space-level-page.po';
import { CfOrgLevelPage } from './cf-org-level-page.po';
import { SpaceFormPage } from './space-form-page.po';
import { TableComponent } from '../../po/table.po';

describe('Manage Space', () => {
let e2eSetup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { E2EConfigCloudFoundry } from '../../e2e.types';
import { CFHelpers } from '../../helpers/cf-helpers';
import { CFHelpers } from '../../helpers/cf-e2e-helpers';
import { CFPage } from '../../po/cf-page.po';
import { SideNavMenuItem } from '../../po/side-nav.po';
import { setupInviteUserTests } from '../invite-users-e2e.helper';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IOrganization } from '../../../frontend/packages/cloud-foundry/src/cf-a
import { APIResource } from '../../../frontend/packages/store/src/types/api.types';
import { e2e } from '../../e2e';
import { E2EConfigCloudFoundry } from '../../e2e.types';
import { CFHelpers } from '../../helpers/cf-helpers';
import { CFHelpers } from '../../helpers/cf-e2e-helpers';
import { ConsoleUserType, E2EHelpers } from '../../helpers/e2e-helpers';
import { ListComponent } from '../../po/list.po';
import { CfOrgLevelPage } from './cf-org-level-page.po';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { CfOrgLevelPage } from './../org-level/cf-org-level-page.po';
import { by, element, protractor } from 'protractor';

import { e2e } from '../../e2e';
import { CFHelpers } from '../../helpers/cf-helpers';
import { CFHelpers } from '../../helpers/cf-e2e-helpers';
import { ConsoleUserType, E2EHelpers } from '../../helpers/e2e-helpers';
import { CfTopLevelPage } from '../cf-level/cf-top-level-page.po';
import { CFPage } from '../../po/cf-page.po';
import { SideNavMenuItem } from '../../po/side-nav.po';
import { ConfirmDialogComponent } from '../../po/confirm-dialog';
import { ListComponent } from '../../po/list.po';
import { MetaCardTitleType } from '../../po/meta-card.po';
import { ConfirmDialogComponent } from '../../po/confirm-dialog';
import { SideNavMenuItem } from '../../po/side-nav.po';
import { CfTopLevelPage } from '../cf-level/cf-top-level-page.po';
import { CfOrgLevelPage } from './../org-level/cf-org-level-page.po';

describe('Delete Space', () => {
let e2eSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { by, element, protractor } from 'protractor';

import { e2e } from '../../e2e';
import { E2EConfigCloudFoundry } from '../../e2e.types';
import { CFHelpers } from '../../helpers/cf-helpers';
import { CFHelpers } from '../../helpers/cf-e2e-helpers';
import { ConsoleUserType, E2EHelpers } from '../../helpers/e2e-helpers';
import { extendE2ETestTime } from '../../helpers/extend-test-helpers';
import { CFPage } from '../../po/cf-page.po';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { promise } from 'protractor';

import { E2EConfigCloudFoundry } from '../../e2e.types';
import { CFHelpers } from '../../helpers/cf-helpers';
import { CFHelpers } from '../../helpers/cf-e2e-helpers';
import { setupInviteUserTests } from '../invite-users-e2e.helper';
import { CfSpaceLevelPage } from './cf-space-level-page.po';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ISpace } from '../../../frontend/packages/cloud-foundry/src/cf-api.type
import { APIResource } from '../../../frontend/packages/store/src/types/api.types';
import { e2e } from '../../e2e';
import { E2EConfigCloudFoundry } from '../../e2e.types';
import { CFHelpers } from '../../helpers/cf-helpers';
import { CFHelpers } from '../../helpers/cf-e2e-helpers';
import { ConsoleUserType, E2EHelpers } from '../../helpers/e2e-helpers';
import { ListComponent } from '../../po/list.po';
import { CfSpaceLevelPage } from './cf-space-level-page.po';
Expand Down
2 changes: 1 addition & 1 deletion src/test-e2e/cloud-foundry/users-list-e2e.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { protractor } from 'protractor/built/ptor';

import { e2e, E2ESetup } from '../e2e';
import { E2EConfigCloudFoundry } from '../e2e.types';
import { CFHelpers } from '../helpers/cf-helpers';
import { CFHelpers } from '../helpers/cf-e2e-helpers';
import { ConsoleUserType, E2EHelpers } from '../helpers/e2e-helpers';
import { extendE2ETestTime } from '../helpers/extend-test-helpers';
import { CFUsersListComponent, UserRoleChip } from '../po/cf-users-list.po';
Expand Down
2 changes: 1 addition & 1 deletion src/test-e2e/cloud-foundry/users-removal-e2e.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { protractor } from 'protractor/built/ptor';
import { CfUser } from '../../frontend/packages/cloud-foundry/src/store/types/cf-user.types';
import { APIResource } from '../../frontend/packages/store/src/types/api.types';
import { e2e } from '../e2e';
import { CFHelpers } from '../helpers/cf-helpers';
import { CFHelpers } from '../helpers/cf-e2e-helpers';
import { ConsoleUserType, E2EHelpers } from '../helpers/e2e-helpers';
import { UaaHelpers } from '../helpers/uaa-helpers';
import { CFUsersListComponent } from '../po/cf-users-list.po';
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/test-e2e/marketplace/services-helper-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IServiceInstance } from '../../frontend/packages/cloud-foundry/src/cf-a
import { CFResponse, createEmptyCfResponse } from '../../frontend/packages/cloud-foundry/src/store/types/cf-api.types';
import { APIResource } from '../../frontend/packages/store/src/types/api.types';
import { e2e, E2ESetup } from '../e2e';
import { CFHelpers } from '../helpers/cf-helpers';
import { CFHelpers } from '../helpers/cf-e2e-helpers';
import { CFRequestHelpers } from '../helpers/cf-request-helpers';
import { E2EHelpers } from '../helpers/e2e-helpers';
import { ListComponent } from '../po/list.po';
Expand Down Expand Up @@ -65,7 +65,7 @@ export class ServicesHelperE2E {

deleteServiceInstance = (cfGuid: string, serviceGuid: string, userProvided = false): promise.Promise<CFResponse> => {
const id = `${cfGuid}:${serviceGuid}`;
const url = userProvided ?`user_provided_service_instances/${serviceGuid}?async=false&recursive=true` : `service_instances/${serviceGuid}?async=false&recursive=true`;
const url = userProvided ? `user_provided_service_instances/${serviceGuid}?async=false&recursive=true` : `service_instances/${serviceGuid}?async=false&recursive=true`;
return this.cfRequestHelper.sendCfDelete(
cfGuid,
url
Expand Down
2 changes: 1 addition & 1 deletion src/test-e2e/po/invite-users-stepper.po.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { by, promise } from 'protractor';

import { CFHelpers } from '../helpers/cf-helpers';
import { CFHelpers } from '../helpers/cf-e2e-helpers';
import { E2EHelpers } from '../helpers/e2e-helpers';
import { RadioGroup } from './radio-group.po';
import { SnackBarPo } from './snackbar.po';
Expand Down

0 comments on commit b438b10

Please sign in to comment.