diff --git a/.github/workflows/aps-cypress-e2e.yaml b/.github/workflows/aps-cypress-e2e.yaml index ed3e232ed..918a69a7d 100644 --- a/.github/workflows/aps-cypress-e2e.yaml +++ b/.github/workflows/aps-cypress-e2e.yaml @@ -2,7 +2,7 @@ name: Build and Deploy Cypress and Execute Tests on: push: - branches: ['test', 'cypress/*'] + branches: ['test', 'cypress*'] env: DASHBOARD_PROJECT_ID: ${{ secrets.CY_DASHBOARD_PRJ_ID }} @@ -20,14 +20,47 @@ jobs: steps: - name: Build GWA API Image run: | - git clone https://github.com/bcgov/gwa-api.git -b master + git clone https://github.com/bcgov/gwa-api.git cd gwa-api/microservices/gatewayApi docker build -t gwa-api:e2e . + - name: Checkout Portal uses: actions/checkout@v2 + + - name: Checkout Source Repository + run: | + git clone https://github.com/bcgov/gwa-cli.git + cd gwa-cli + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: '1.20.x' + + - name: create .env file + run: | + cd gwa-cli + echo "GWA_API_HOST=api-services-portal-feature-gwa-cli-v2.apps.silver.devops.gov.bc.ca" >> .env + echo "GWA_CLIENT_ID=gwa-cli" >> .env + + - name: Debug + run: echo ${{ github.workspace }} + + - name: Build + run: | + cd gwa-cli + go clean + go build -o ${{ github.workspace }}/e2e/gwa + + - uses: actions/upload-artifact@v2 + with: + name: binary-artifact + path: ${{ github.workspace }}/e2e + - name: Build Docker Images run: | docker-compose build + - name: Spin up API Services Portal and Run E2E Tests run: | export CY_EXECUTION_ENV=${{ env.EXECUTION_ENV }} @@ -40,6 +73,7 @@ jobs: export CY_REPO_URL=${{ env.GIT_REPO_URL }} export CY_COMMIT_AUTHOR_EMAIL=$(git --no-pager show -s --format='%ae' ${{ env.GIT_COMMIT_SHA }}) docker-compose up -d + - name: Execute Tests & Clean Up run: | while true; do diff --git a/e2e/Dockerfile b/e2e/Dockerfile index 46e1ec3bc..a77289f4a 100644 --- a/e2e/Dockerfile +++ b/e2e/Dockerfile @@ -3,14 +3,15 @@ FROM cypress/included:12.4.0 WORKDIR /e2e RUN apt-get -y update; apt-get -y install curl - COPY cypress.config.ts /e2e COPY tsconfig.json /e2e COPY package.json /e2e COPY package-lock.json /e2e COPY entrypoint.sh /tmp +COPY gwa /usr/local/bin ADD cypress /e2e/cypress RUN npm install + ENTRYPOINT ["npm", "run", "cy:run:html"] \ No newline at end of file diff --git a/e2e/cypress.config.ts b/e2e/cypress.config.ts index 150628ffc..526b4dd58 100644 --- a/e2e/cypress.config.ts +++ b/e2e/cypress.config.ts @@ -23,10 +23,11 @@ export default defineConfig({ './cypress/tests/10-*/*.ts', './cypress/tests/11-*/*.ts', './cypress/tests/12-*/*.ts', - './cypress/tests/13-*/*.ts', + './cypress/tests/13-*/*.ts', './cypress/tests/14-*/*.ts', './cypress/tests/15-*/*.ts', - './cypress/tests/16-*/*.ts' + './cypress/tests/16-*/*.ts', + './cypress/tests/17-*/*.ts' ] return config }, diff --git a/e2e/cypress/fixtures/api.json b/e2e/cypress/fixtures/api.json index 5ae336805..41435f225 100644 --- a/e2e/cypress/fixtures/api.json +++ b/e2e/cypress/fixtures/api.json @@ -10,10 +10,36 @@ "title": "Planning and Innovation Division" }, "orgName": "ministry-of-health", - "expectedScope": ["Dataset.Manage", "GroupAccess.Manage", "Namespace.Assign"], + "expectedScope": [ + "Dataset.Manage", + "GroupAccess.Manage", + "Namespace.Assign" + ], "expectedNamespace": { - "name": "newplatform", - "orgUnit": "planning-and-innovation-division" + "name": "gw-3a443", + "orgUnit": "planning-and-innovation-division", + "enabled": true + }, + "expectedRoles": { + "organization-admin": { + "label": "Organization Administrator", + "permissions": [ + { + "resourceType": "organization", + "scopes": [ + "GroupAccess.Manage", + "Namespace.Assign", + "Dataset.Manage" + ] + }, + { + "resourceType": "namespace", + "scopes": [ + "Namespace.View" + ] + } + ] + } }, "body": { "name": "ministry-of-health", @@ -24,7 +50,9 @@ "id": "janis@idir", "email": "janis@testmail.com" }, - "roles": ["organization-admin"] + "roles": [ + "organization-admin" + ] } ] } @@ -44,7 +72,10 @@ "order": 0, "isPublic": true, "isComplete": true, - "tags": ["tag1", "tag2"] + "tags": [ + "tag1", + "tag2" + ] } }, "apiDirectory": { @@ -65,18 +96,25 @@ "title": "Dataset for Test API", "isInCatalog": "false", "isDraft": "false", - "tags": ["gateway", "kong"], + "tags": [ + "gateway", + "kong" + ], "organization": "ministry-of-health", "organizationUnit": "planning-and-innovation-division" }, "directory": { - "name": "api-auto-test-product", - "title": "API Auto Test Product", - "notes": "API Gateway Services provides a way to configure services on the API Gateway, manage access to APIs and get insight into the use of them.", - "license_title": "Access Only", - "view_audience": "Government", - "security_class": "LOW-PUBLIC", - "tags": ["gateway", "kong", "openapi"], + "name": "gwa-auto-test-product", + "title": "GWA Auto Test Product", + "notes": "For Test Purpose", + "license_title": "Open Government Licence - British Columbia", + "view_audience": "Public", + "security_class": "PUBLIC", + "record_publish_date": "2017-09-05", + "tags": [ + "tag1", + "tag2" + ], "organization": { "name": "ministry-of-health", "title": "Ministry of Health" @@ -87,12 +125,18 @@ }, "products": [ { - "name": "API Auto Test Product", + "id": "2", + "name": "GWA Auto Test Product", "environments": [ { "name": "dev", "active": true, - "flow": "kong-api-key-acl" + "flow": "kong-api-key-only" + }, + { + "name": "test", + "active": true, + "flow": "client-credentials" } ] } @@ -105,7 +149,11 @@ "license_title": "Access Only", "view_audience": "Government", "security_class": "LOW-PUBLIC", - "tags": ["gateway", "kong", "openapi"], + "tags": [ + "gateway", + "kong", + "openapi" + ], "organization": { "name": "ministry-of-health", "title": "Ministry of Health" @@ -174,6 +222,46 @@ ], "isShared": true }, + "shared_gwa": { + "name": "Gold Shared IdP", + "description": "A Shared IdP for Teams to use", + "flow": "client-credentials", + "clientAuthenticator": "client-secret", + "mode": "auto", + "environmentDetails": [ + { + "environment": "test", + "issuerUrl": "http://keycloak.localtest.me:9080/auth/realms/master", + "clientRegistration": "managed", + "clientId": "gwa-api", + "clientSecret": "18900468-3db1-43f7-a8af-e75f079eb742" + } + ], + "isShared": true + }, + "shared_gwa_publish": { + "name": "Gold Shared IdP", + "description": "A Shared IdP for Teams to use", + "flow": "client-credentials", + "mode": "auto", + "clientAuthenticator": "client-secret", + "environmentDetails": [ + { + "clientId": "gwa-api", + "clientRegistration": "managed", + "clientSecret": "****", + "environment": "test", + "issuerUrl": "http://keycloak.localtest.me:9080/auth/realms/master", + "exists": true + } + ], + "clientRoles": [], + "clientMappers": [], + "availableScopes": [], + "resourceScopes": [], + "isShared": true, + "apiKeyName": "X-API-KEY" + }, "shared_IDP_body": { "name": "Sample Shared IdP new", "description": "A Shared IdP for Teams to use", @@ -194,8 +282,12 @@ "shared_IDP_inheritFrom": { "environmentDetails": [], "mode": "auto", - "clientRoles": ["administrator"], - "clientMappers": ["test-audience"], + "clientRoles": [ + "administrator" + ], + "clientMappers": [ + "test-audience" + ], "flow": "client-credentials", "clientAuthenticator": "client-secret", "name": "my-auth-client-secret-1", @@ -218,8 +310,12 @@ "clientId": "ap-my-auth-client-secret-1-test" } ], - "clientRoles": ["administrator"], - "clientMappers": ["test-audience"], + "clientRoles": [ + "administrator" + ], + "clientMappers": [ + "test-audience" + ], "isShared": false, "apiKeyName": "X-API-KEY", "inheritFrom": { @@ -282,11 +378,21 @@ "name": "CredentialIssuer.Admin" } ], - "permDomains": [".api.gov.bc.ca"], + "permDomains": [ + ".api.gov.bc.ca" + ], "permDataPlane": "local.dataplane", "permProtectedNs": "deny", "org": "ministry-of-health", "orgUnit": "planning-and-innovation-division" + }, + "userDefinedNamespace": { + "name": "gwanelatform", + "displayName": "Test for GWA test" + }, + "inValidNamespace": { + "name": "gwa", + "displayName": "Test for GWA test" } } -} +} \ No newline at end of file diff --git a/e2e/cypress/fixtures/apiowner.json b/e2e/cypress/fixtures/apiowner.json index c7b0844b3..fdd261d0e 100644 --- a/e2e/cypress/fixtures/apiowner.json +++ b/e2e/cypress/fixtures/apiowner.json @@ -2,17 +2,25 @@ "user": { "credentials": { "username": "janis@idir", - "email":"janis@testmail.com", + "email": "janis@testmail.com", "password": "awsummer" } }, "namespace": "newplatform", - "invalid_namespace": ["test_1234", "New_napespace", "Government"], + "invalid_namespace": [ + "test_1234", + "New_napespace", + "Government" + ], "serviceAccount": { - "scopes": ["GatewayConfig.Publish", "Namespace.Manage", "Content.Publish"] + "scopes": [ + "GatewayConfig.Publish", + "Namespace.Manage", + "Content.Publish" + ] }, "deleteResources": { - "namespace": "deleteplatform", + "namespace": "gw-2a3ef", "product": { "name": "Delete-Auto Test Product", "environment": { @@ -26,9 +34,11 @@ } } }, - "namespaceAccessPermissions": ["CredentialIssuer.Admin"], + "namespaceAccessPermissions": [ + "CredentialIssuer.Admin" + ], "product": { - "name": "Auto Test Product", + "name": "GWA Auto Test Product", "orgName": "Ministry of Health", "orgUnitName": "Planning and Innovation Division", "environment": { @@ -51,17 +61,21 @@ } }, "clientCredentials": { - "namespace": "ccplatform", + "namespace": "gw-e9cd4", "serviceName": "cc-service-for-platform", "Mark": { "userName": "mark", - "email":"mark@gmail.com", - "accessRole": ["Access.Manage"] + "email": "mark@gmail.com", + "accessRole": [ + "Access.Manage" + ] }, "Wendy": { "userName": "wendy", - "email":"wendy@test.com", - "accessRole": ["CredentialIssuer.Admin"] + "email": "wendy@test.com", + "accessRole": [ + "CredentialIssuer.Admin" + ] }, "jwtKeyPair": { "authProfile": { @@ -161,7 +175,9 @@ "name": "cy-client-id-secret-auth", "flow": "Client Credential Flow", "element": "cc-id-secret", - "scopes":["System.Write"], + "scopes": [ + "System.Write" + ], "clientAuthenticator": "Client ID and Secret", "environmentConfig": { "environment": "Test", @@ -206,7 +222,7 @@ }, "KongApiOnly": { "product": { - "name": "Auto Test Product", + "name": "GWA Auto Test Product", "orgName": "Ministry of Health", "orgUnitName": "Planning and Innovation Division", "environment": { @@ -222,7 +238,7 @@ }, "clientIdSecret_KongKeyToCC": { "product": { - "name": "Auto Test Product", + "name": "GWA Auto Test Product", "orgName": "Ministry of Health", "orgUnitName": "Planning and Innovation Division", "environment": { @@ -238,7 +254,9 @@ "name": "cy-client-id-secret-auth-updated", "flow": "Client Credential Flow", "element": "cc-id-secret", - "scopes":["System.Write"], + "scopes": [ + "System.Write" + ], "clientAuthenticator": "Client ID and Secret", "environmentConfig": { "environment": "Test", @@ -256,15 +274,18 @@ "element": "cc-id-secret", "clientAuthenticator": "Client ID and Secret", "environmentConfig": { - "isShardIDP":true + "isShardIDP": true } } } }, "namespacePreview": { - "namespace": "previewmode", + "namespace": "gw-07034", "serviceAccount": { - "scopes": ["GatewayConfig.Publish", "Namespace.Manage"] + "scopes": [ + "GatewayConfig.Publish", + "Namespace.Manage" + ] }, "product": { "name": "Namespace Preview Test Product", @@ -280,15 +301,20 @@ } }, "orgAssignment": { - "namespace": "orgassignment", + "namespace": "gw-57421", "serviceName": "a-service-for-orgassignment", "Mark": { "userName": "mark", - "email":"mark@gmail.com", - "accessRole": ["Access.Manage"] + "email": "mark@gmail.com", + "accessRole": [ + "Access.Manage" + ] }, "serviceAccount": { - "scopes": ["GatewayConfig.Publish", "Namespace.Manage"] + "scopes": [ + "GatewayConfig.Publish", + "Namespace.Manage" + ] }, "product": { "name": "Org Assignment Product", @@ -302,9 +328,9 @@ } } }, - "orgAdminNotification":{ - "parent" : "Your Organization Administrator has been notified to enable API Publishing to the Directory for the orgassignment namespace.", - "child" : "New namespaces must be reviewed by your Organization Administrator before you can publish APIs to the Directory. Your APIs are still in preview mode. For status inquiries, contact your Organization Administrator benny@test.com." + "orgAdminNotification": { + "parent": "Your Organization Administrator has been notified to enable API Publishing to the Directory for the orgassignment namespace.", + "child": "New namespaces must be reviewed by your Organization Administrator before you can publish APIs to the Directory. Your APIs are still in preview mode. For status inquiries, contact your Organization Administrator benny@test.com." } }, "orgAssignmentMultipleAdmin": { @@ -312,13 +338,17 @@ "serviceName": "a-service-for-orgassignment1", "Mark": { "userName": "mark", - "email":"mark@gmail.com", - "accessRole": ["Access.Manage"] + "email": "mark@gmail.com", + "accessRole": [ + "Access.Manage" + ] }, "GroupAccess": { - "members": ["benny@test.com", "wendy@test.com"] + "members": [ + "benny@test.com", + "wendy@test.com" + ] }, - "product": { "name": "Org Assignment Product", "environment": { @@ -331,9 +361,9 @@ } } }, - "orgAdminNotification":{ - "parent" : "Your Organization Administrator has been notified to enable API Publishing to the Directory for the orgassignment namespace.", - "child" : "New namespaces must be reviewed by your Organization Administrator before you can publish APIs to the Directory. Your APIs are still in preview mode. For status inquiries, contact your Organization Administrator benny@test.com." + "orgAdminNotification": { + "parent": "Your Organization Administrator has been notified to enable API Publishing to the Directory for the orgassignment namespace.", + "child": "New namespaces must be reviewed by your Organization Administrator before you can publish APIs to the Directory. Your APIs are still in preview mode. For status inquiries, contact your Organization Administrator benny@test.com." } }, "orgAssignmentOrgUnit": { @@ -341,13 +371,16 @@ "serviceName": "a-service-for-orgassign-unit", "Mark": { "userName": "mark", - "email":"mark@gmail.com", - "accessRole": ["Access.Manage"] + "email": "mark@gmail.com", + "accessRole": [ + "Access.Manage" + ] }, "GroupAccess": { - "members": ["benny@test.com"] + "members": [ + "benny@test.com" + ] }, - "product": { "name": "Org Assignment Unit Product", "environment": { @@ -360,15 +393,18 @@ } } }, - "orgAdminNotification":{ - "parent" : "Your Organization Administrator has been notified to enable API Publishing to the Directory for the orgassignment namespace.", - "child" : "New namespaces must be reviewed by your Organization Administrator before you can publish APIs to the Directory. Your APIs are still in preview mode. For status inquiries, contact your Organization Administrator benny@test.com." + "orgAdminNotification": { + "parent": "Your Organization Administrator has been notified to enable API Publishing to the Directory for the orgassignment namespace.", + "child": "New namespaces must be reviewed by your Organization Administrator before you can publish APIs to the Directory. Your APIs are still in preview mode. For status inquiries, contact your Organization Administrator benny@test.com." } }, "checkPermission": { - "namespace": "permission", + "namespace": "gw-e9cca", "serviceAccount": { - "scopes": ["GatewayConfig.Publish", "Namespace.Manage"] + "scopes": [ + "GatewayConfig.Publish", + "Namespace.Manage" + ] }, "product": { "name": "New-Auto Test Product", @@ -385,59 +421,88 @@ "grantPermission": { "Mark": { "userName": "Mark F Mark L", - "email":"mark@gmail.com", - "accessRole": ["Access.Manage"] + "email": "mark@gmail.com", + "accessRole": [ + "Access.Manage" + ] }, "Mark_NV": { "userName": "Mark F Mark L", - "email":"mark@gmail.com", - "accessRole": ["Namespace.View"] + "email": "mark@gmail.com", + "accessRole": [ + "Namespace.View" + ] }, "Wendy": { "userName": "Wendy F Wendy L", - "email":"wendy@test.com", - "accessRole": ["Namespace.Manage", "CredentialIssuer.Admin"] + "email": "wendy@test.com", + "accessRole": [ + "Namespace.Manage", + "CredentialIssuer.Admin" + ] }, "Wendy_NM": { "userName": "Wendy F Wendy L", - "email":"wendy@test.com", - "accessRole": ["Namespace.Manage"] + "email": "wendy@test.com", + "accessRole": [ + "Namespace.Manage" + ] }, "Wendy_CA": { "userName": "Wendy F Wendy L", - "email":"wendy@test.com", - "accessRole": ["CredentialIssuer.Admin"] + "email": "wendy@test.com", + "accessRole": [ + "CredentialIssuer.Admin" + ] }, "Wendy_GC": { "userName": "Wendy F Wendy L", - "email":"wendy@test.com", - "accessRole": ["GatewayConfig.Publish", "Namespace.View"] + "email": "wendy@test.com", + "accessRole": [ + "GatewayConfig.Publish", + "Namespace.View" + ] }, "Janis": { "userName": "Janis Smith", - "email":"janis@testmail.com", - "accessRole": ["Namespace.Manage", "CredentialIssuer.Admin"] + "email": "janis@testmail.com", + "accessRole": [ + "Namespace.Manage", + "CredentialIssuer.Admin" + ] } }, "revokePermission": { "Mark": { "userName": "mark", - "accessRole": ["Namespace.View", "Access.Manage"] + "accessRole": [ + "Namespace.View", + "Access.Manage" + ] }, "Mark_AM": { "userName": "mark", - "accessRole": ["Access.Manage"] + "accessRole": [ + "Access.Manage" + ] }, "Wendy": { "userName": "wendy", - "accessRole": ["Namespace.Manage"] + "accessRole": [ + "Namespace.Manage" + ] }, "Wendy_ci": { "userName": "wendy", - "accessRole": ["CredentialIssuer.Admin"] + "accessRole": [ + "CredentialIssuer.Admin" + ] }, "serviceAccount": { - "scopes": ["Namespace.Manage", "Content.Publish"] + "scopes": [ + "Namespace.Manage", + "Content.Publish" + ] } } }, @@ -445,27 +510,40 @@ "Mark": { "userName": "mark", "email": "mark@gmail.com", - "accessRole": ["Access.Manage", "Namespace.View"] + "accessRole": [ + "Access.Manage", + "Namespace.View" + ] }, "Janis": { "userName": "Janis Smith", "email": "janis@testmail.com", - "accessRole": ["CredentialIssuer.Admin","Namespace.Manage"] + "accessRole": [ + "CredentialIssuer.Admin", + "Namespace.Manage" + ] }, "OldUser": { "userName": "olduser@idir", "email": "olduser@testmail.com", - "accessRole": ["Access.Manage", "Namespace.View","Namespace.Manage"] + "accessRole": [ + "Access.Manage", + "Namespace.View", + "Namespace.Manage" + ] } }, "permission": { "Mark": { "userName": "mark", - "accessRole": ["Access.Manage", "Namespace.View"] + "accessRole": [ + "Access.Manage", + "Namespace.View" + ] } }, "apiTest": { - "namespace": "apiplatform", + "namespace": "gw-65590", "delete_namespace": "testplatform", "product": { "name": "API Auto Test Product", @@ -480,197 +558,197 @@ } } }, - "expectedActivitiesResponse":[ + "expectedActivitiesResponse": [ { - "result": "success", - "message": "{actor} {action} {entity} for {application} ({consumer}) to access {product} {environment}", - "params": { - "actor": "Mark F Mark L", - "action": "approved", - "entity": "access request", - "accessRequest": "2", - "environment": "dev", - "product": "Auto Test Product", - "application": "Auto Test App to check labels", - "consumer": "9C3EFC92-8F3DE9D3B74" - }, - "activityAt": "2022-09-20T20:39:05.318Z" + "result": "success", + "message": "{actor} {action} {entity} for {application} ({consumer}) to access {product} {environment}", + "params": { + "actor": "Mark F Mark L", + "action": "approved", + "entity": "access request", + "accessRequest": "2", + "environment": "dev", + "product": "GWA Auto Test Product", + "application": "Auto Test App to check labels", + "consumer": "9C3EFC92-8F3DE9D3B74" + }, + "activityAt": "2022-09-20T20:39:05.318Z" }, { - "result": "success", - "message": "{actor} {action} for {application} ({consumer}) to access {product} {environment} ({note})", - "params": { - "actor": "Harley Jones", - "action": "received credentials", - "entity": "access", - "note": "access pending approval", - "accessRequest": "2", - "environment": "dev", - "product": "Auto Test Product", - "application": "Auto Test App to check labels", - "consumer": "9C3EFC92-8F3DE9D3B73" - }, - "activityAt": "2022-09-20T20:38:40.857Z" + "result": "success", + "message": "{actor} {action} for {application} ({consumer}) to access {product} {environment} ({note})", + "params": { + "actor": "Harley Jones", + "action": "received credentials", + "entity": "access", + "note": "access pending approval", + "accessRequest": "2", + "environment": "dev", + "product": "GWA Auto Test Product", + "application": "Auto Test App to check labels", + "consumer": "9C3EFC92-8F3DE9D3B73" + }, + "activityAt": "2022-09-20T20:38:40.857Z" }, { - "result": "success", - "message": "{actor} {action} {entity} for {consumer}", - "params": { - "actor": "Mark F Mark L", - "action": "update", - "entity": "consumer control" - }, - "activityAt": "2022-09-20T20:38:19.732Z" + "result": "success", + "message": "{actor} {action} {entity} for {consumer}", + "params": { + "actor": "Mark F Mark L", + "action": "update", + "entity": "consumer control" + }, + "activityAt": "2022-09-20T20:38:19.732Z" }, { - "result": "completed", - "message": "GatewayConsumerPlugin Update", - "params": { - "actor": "Unknown Actor" - }, - "activityAt": "2022-09-20T20:38:19.678Z" + "result": "completed", + "message": "GatewayConsumerPlugin Update", + "params": { + "actor": "Unknown Actor" + }, + "activityAt": "2022-09-20T20:38:19.678Z" }, { - "result": "success", - "message": "{actor} {action} {entity} for {consumer}", - "params": { - "actor": "Mark F Mark L", - "action": "update", - "entity": "consumer control" - }, - "activityAt": "2022-09-20T20:38:14.706Z" + "result": "success", + "message": "{actor} {action} {entity} for {consumer}", + "params": { + "actor": "Mark F Mark L", + "action": "update", + "entity": "consumer control" + }, + "activityAt": "2022-09-20T20:38:14.706Z" }, { - "result": "completed", - "message": "GatewayConsumerPlugin Update", - "params": { - "actor": "Unknown Actor" - }, - "activityAt": "2022-09-20T20:38:12.664Z" + "result": "completed", + "message": "GatewayConsumerPlugin Update", + "params": { + "actor": "Unknown Actor" + }, + "activityAt": "2022-09-20T20:38:12.664Z" }, { - "result": "success", - "message": "{actor} {action} {entity} for {consumer}", - "params": { - "actor": "Mark F Mark L", - "action": "update", - "entity": "consumer control" - }, - "activityAt": "2022-09-20T20:38:08.054Z" + "result": "success", + "message": "{actor} {action} {entity} for {consumer}", + "params": { + "actor": "Mark F Mark L", + "action": "update", + "entity": "consumer control" + }, + "activityAt": "2022-09-20T20:38:08.054Z" }, { - "result": "completed", - "message": "GatewayConsumerPlugin Update", - "params": { - "actor": "Unknown Actor" - }, - "activityAt": "2022-09-20T20:38:07.996Z" + "result": "completed", + "message": "GatewayConsumerPlugin Update", + "params": { + "actor": "Unknown Actor" + }, + "activityAt": "2022-09-20T20:38:07.996Z" }, { - "result": "success", - "message": "{actor} {action} {entity} for {consumer}", - "params": { - "actor": "Mark F Mark L", - "action": "update", - "entity": "consumer control" - }, - "activityAt": "2022-09-20T20:38:00.947Z" + "result": "success", + "message": "{actor} {action} {entity} for {consumer}", + "params": { + "actor": "Mark F Mark L", + "action": "update", + "entity": "consumer control" + }, + "activityAt": "2022-09-20T20:38:00.947Z" }, { - "result": "completed", - "message": "GatewayConsumerPlugin Update", - "params": { - "actor": "Unknown Actor" - }, - "activityAt": "2022-09-20T20:38:00.899Z" + "result": "completed", + "message": "GatewayConsumerPlugin Update", + "params": { + "actor": "Unknown Actor" + }, + "activityAt": "2022-09-20T20:38:00.899Z" }, { - "result": "success", - "message": "{actor} {action} {entity} for {consumer}", - "params": { - "actor": "Mark F Mark L", - "action": "update", - "entity": "consumer control" - }, - "activityAt": "2022-09-20T20:37:56.316Z" + "result": "success", + "message": "{actor} {action} {entity} for {consumer}", + "params": { + "actor": "Mark F Mark L", + "action": "update", + "entity": "consumer control" + }, + "activityAt": "2022-09-20T20:37:56.316Z" }, { - "result": "completed", - "message": "GatewayConsumerPlugin Update", - "params": { - "actor": "Unknown Actor" - }, - "activityAt": "2022-09-20T20:37:56.252Z" + "result": "completed", + "message": "GatewayConsumerPlugin Update", + "params": { + "actor": "Unknown Actor" + }, + "activityAt": "2022-09-20T20:37:56.252Z" }, { - "result": "completed", - "message": "GatewayConsumerPlugin Update", - "params": { - "actor": "Unknown Actor" - }, - "activityAt": "2022-09-20T20:37:56.192Z" + "result": "completed", + "message": "GatewayConsumerPlugin Update", + "params": { + "actor": "Unknown Actor" + }, + "activityAt": "2022-09-20T20:37:56.192Z" }, { - "result": "success", - "message": "{actor} {action} {entity} for {consumer}", - "params": { - "actor": "Mark F Mark L", - "action": "update", - "entity": "consumer control" - }, - "activityAt": "2022-09-20T20:37:47.630Z" + "result": "success", + "message": "{actor} {action} {entity} for {consumer}", + "params": { + "actor": "Mark F Mark L", + "action": "update", + "entity": "consumer control" + }, + "activityAt": "2022-09-20T20:37:47.630Z" }, { - "result": "completed", - "message": "GatewayConsumerPlugin Update", - "params": { - "actor": "Unknown Actor" - }, - "activityAt": "2022-09-20T20:37:47.574Z" + "result": "completed", + "message": "GatewayConsumerPlugin Update", + "params": { + "actor": "Unknown Actor" + }, + "activityAt": "2022-09-20T20:37:47.574Z" }, { - "result": "completed", - "message": "GatewayConsumerPlugin Update", - "params": { - "actor": "Unknown Actor" - }, - "activityAt": "2022-09-20T20:37:47.516Z" + "result": "completed", + "message": "GatewayConsumerPlugin Update", + "params": { + "actor": "Unknown Actor" + }, + "activityAt": "2022-09-20T20:37:47.516Z" }, { - "result": "success", - "message": "{actor} {action} {entity} for {consumer}", - "params": { - "actor": "Mark F Mark L", - "action": "update", - "entity": "consumer control" - }, - "activityAt": "2022-09-20T20:37:38.815Z" + "result": "success", + "message": "{actor} {action} {entity} for {consumer}", + "params": { + "actor": "Mark F Mark L", + "action": "update", + "entity": "consumer control" + }, + "activityAt": "2022-09-20T20:37:38.815Z" }, { - "result": "completed", - "message": "GatewayConsumerPlugin Update", - "params": { - "actor": "Unknown Actor" - }, - "activityAt": "2022-09-20T20:37:38.763Z" + "result": "completed", + "message": "GatewayConsumerPlugin Update", + "params": { + "actor": "Unknown Actor" + }, + "activityAt": "2022-09-20T20:37:38.763Z" }, { - "result": "completed", - "message": "GatewayConsumerPlugin Update", - "params": { - "actor": "Unknown Actor" - }, - "activityAt": "2022-09-20T20:37:38.696Z" + "result": "completed", + "message": "GatewayConsumerPlugin Update", + "params": { + "actor": "Unknown Actor" + }, + "activityAt": "2022-09-20T20:37:38.696Z" }, { - "result": "success", - "message": "{actor} {action} {entity} for {consumer}", - "params": { - "actor": "Mark F Mark L", - "action": "update", - "entity": "consumer control" - }, - "activityAt": "2022-09-20T20:37:30.570Z" + "result": "success", + "message": "{actor} {action} {entity} for {consumer}", + "params": { + "actor": "Mark F Mark L", + "action": "update", + "entity": "consumer control" + }, + "activityAt": "2022-09-20T20:37:30.570Z" } -] -} + ] +} \ No newline at end of file diff --git a/e2e/cypress/fixtures/cc-service-gwa.yml b/e2e/cypress/fixtures/cc-service-gwa.yml new file mode 100644 index 000000000..77b815834 --- /dev/null +++ b/e2e/cypress/fixtures/cc-service-gwa.yml @@ -0,0 +1,19 @@ +services: +- name: cc-service-for-platform + host: httpbin.org + tags: [ns.ccplatform] + port: 443 + protocol: https + retries: 0 + routes: + - name: cc-service-for-platform-route + tags: [ns.ccplatform] + hosts: + - cc-service-for-platform.api.gov.bc.ca + paths: + - / + methods: + - GET + strip_path: false + https_redirect_status_code: 426 + path_handling: v0 \ No newline at end of file diff --git a/e2e/cypress/fixtures/service-clear-resources-gwa.yml b/e2e/cypress/fixtures/service-clear-resources-gwa.yml new file mode 100644 index 000000000..11a83ad3d --- /dev/null +++ b/e2e/cypress/fixtures/service-clear-resources-gwa.yml @@ -0,0 +1,19 @@ +services: +- name: service-for-deleteplatform + host: httpbin.org + tags: [ns.deleteplatform] + port: 443 + protocol: https + retries: 0 + routes: + - name: service-for-deleteplatform-route + tags: [ns.deleteplatform] + hosts: + - service-for-deleteplatform.api.gov.bc.ca + paths: + - / + methods: + - GET + strip_path: false + https_redirect_status_code: 426 + path_handling: v0 \ No newline at end of file diff --git a/e2e/cypress/fixtures/service-gwa.yml b/e2e/cypress/fixtures/service-gwa.yml new file mode 100644 index 000000000..77ddda761 --- /dev/null +++ b/e2e/cypress/fixtures/service-gwa.yml @@ -0,0 +1,38 @@ +services: +- name: a-service-for-newplatform + host: httpbin.org + tags: [ns.newplatform] + port: 443 + protocol: https + retries: 0 + routes: + - name: a-service-for-newplatform-route + tags: [ns.newplatform] + hosts: + - a-service-for-newplatform.api.gov.bc.ca + paths: + - / + methods: + - GET + strip_path: false + https_redirect_status_code: 426 + path_handling: v0 + +- name: a-service-for-newplatform-test + host: httpbin.org + tags: [ns.newplatform] + port: 443 + protocol: https + retries: 0 + routes: + - name: a-service-for-newplatform-test-route + tags: [ns.newplatform] + hosts: + - a-service-for-newplatform-test.api.gov.bc.ca + paths: + - / + methods: + - GET + strip_path: false + https_redirect_status_code: 426 + path_handling: v0 \ No newline at end of file diff --git a/e2e/cypress/fixtures/service-permission-gwa.yml b/e2e/cypress/fixtures/service-permission-gwa.yml new file mode 100644 index 000000000..cbcf1e7c7 --- /dev/null +++ b/e2e/cypress/fixtures/service-permission-gwa.yml @@ -0,0 +1,19 @@ +services: +- name: service-for-permission + host: httpbin.org + tags: [ns.permission] + port: 443 + protocol: https + retries: 0 + routes: + - name: service-for-permission-route + tags: [ns.permission] + hosts: + - service-for-permission.api.gov.bc.ca + paths: + - / + methods: + - GET + strip_path: false + https_redirect_status_code: 426 + path_handling: v0 diff --git a/e2e/cypress/fixtures/service-plugin-key-auth-only.yml b/e2e/cypress/fixtures/service-plugin-key-auth-only.yml index 897d275a7..69ad7b220 100644 --- a/e2e/cypress/fixtures/service-plugin-key-auth-only.yml +++ b/e2e/cypress/fixtures/service-plugin-key-auth-only.yml @@ -9,4 +9,4 @@ plugins: config: key_names: - x-api-key - anonymous: 1aaf2351-0622-4cc4-8d14-32e78771e620 + anonymous: bb2c1e04-96ce-4b1d-baf4-a7e681a862a6 diff --git a/e2e/cypress/fixtures/test_data/gwa-cli.json b/e2e/cypress/fixtures/test_data/gwa-cli.json new file mode 100644 index 000000000..a993bc254 --- /dev/null +++ b/e2e/cypress/fixtures/test_data/gwa-cli.json @@ -0,0 +1,12 @@ +{ + "content": { + "help": "You can login via device login or by using client credentials\n\nTo use device login, simply run the command like so:\n $ gwa login\n\nTo use your credentials you must supply both a client-id and client-secret:\n $ gwa login --client-id --client-secret \n\nUsage:\n gwa login [flags]\n\nFlags:\n --client-id string Your gateway's client ID\n --client-secret string Your gateway's client secret\n -h, --help help for login\n\nGlobal Flags:\n --host string Set the default host to use for the API\n --namespace string Assign the namespace you would like to use\n --scheme string Use to override default https", + "login_help": "Log in to your IDIR account\n\nUsage:\n gwa login [flags]\n\nFlags:\n --client-id string Your gateway's client ID\n --client-secret string Your gateway's client secret\n -h, --help help for login\n\nGlobal Flags:\n --host string Set the default host to use for the API\n --scheme string Use to override default https", + "namespace_help": "Longer explanation to come...\n\nUsage:\n gwa namespace [command]\n\nAvailable Commands:\n create Create a new namespace\n list List all your managed namespaces\n\nFlags:\n -h, --help help for namespace\n\nGlobal Flags:\n --host string Set the default host to use for the API\n --namespace string Assign the namespace you would like to use\n --scheme string Use to override default https\n\nUse \"gwa namespace [command] --help\" for more information about a command.", + "config_help": "Configuration commands\n\nUsage:\n gwa config [command]\n\nAvailable Commands:\n set Write a specific global setting\n\nFlags:\n -h, --help help for config\n\nGlobal Flags:\n --host string Set the default host to use for the API\n --namespace string Assign the namespace you would like to use\n --scheme string Use to override default https\n\nUse \"gwa config [command] --help\" for more information about a command." + }, + "credentials": { + "clientID": "gwa-api", + "clientSecret": "18900468-3db1-43f7-a8af-e75f079eb742" + } +} diff --git a/e2e/cypress/fixtures/test_data/gwa-dataset.yaml b/e2e/cypress/fixtures/test_data/gwa-dataset.yaml new file mode 100644 index 000000000..28eb9d201 --- /dev/null +++ b/e2e/cypress/fixtures/test_data/gwa-dataset.yaml @@ -0,0 +1,15 @@ +name: gwa-auto-test-product +license_title: Open Government Licence - British Columbia +security_class: PUBLIC +view_audience: Public +download_audience: Public +record_publish_date: '2017-09-05' +notes: For Test Purpose +title: GWA Auto Test Product +tags: + - tag1 + - tag2 +organization: ministry-of-health +organizationUnit: planning-and-innovation-division +isInCatalog: true +isDraft: false \ No newline at end of file diff --git a/e2e/cypress/fixtures/test_data/gwa-issuer.yaml b/e2e/cypress/fixtures/test_data/gwa-issuer.yaml new file mode 100644 index 000000000..fb1c7a992 --- /dev/null +++ b/e2e/cypress/fixtures/test_data/gwa-issuer.yaml @@ -0,0 +1,12 @@ +name: Gold Shared IdP +description: A Shared IdP for Teams to use +flow: client-credentials +clientAuthenticator: client-secret +mode: auto +environmentDetails: + - environment: test + issuerUrl: http://keycloak.localtest.me:9080/auth/realms/master + clientRegistration: managed + clientId: gwa-api + clientSecret: 18900468-3db1-43f7-a8af-e75f079eb742 +isShared: true \ No newline at end of file diff --git a/e2e/cypress/fixtures/test_data/gwa-product.yaml b/e2e/cypress/fixtures/test_data/gwa-product.yaml new file mode 100644 index 000000000..8b95400a3 --- /dev/null +++ b/e2e/cypress/fixtures/test_data/gwa-product.yaml @@ -0,0 +1,8 @@ +name: GWA Auto Test Product +appId: 'KFH78YU956RE' +environments: + - name: dev + active: false + approval: false + flow: public + appId: '406CB7CF' \ No newline at end of file diff --git a/e2e/cypress/pageObjects/activity.ts b/e2e/cypress/pageObjects/activity.ts index 2d1f17774..357ff8d3f 100644 --- a/e2e/cypress/pageObjects/activity.ts +++ b/e2e/cypress/pageObjects/activity.ts @@ -31,12 +31,11 @@ class ActivityPage { responseText = responseText.replaceAll("{", "${filteredResponse[index].params.") const regexp = /\${([^{]+)}/g; if (!(record.result === 'failed')) { - result = responseText.replace(regexp, function (ignore: any, key: any) { + result = responseText.replace(regexp, function (ignore: any, key: any) { return eval(key); }); } - else if(responseText.includes("Failed to Apply Workflow - IssuerMisconfigError")) - { + else if (responseText.includes("Failed to Apply Workflow - IssuerMisconfigError")) { result = 'Failed to Apply Workflow - IssuerMisconfigError: undefined' } if (result === activityText) { @@ -61,12 +60,25 @@ class ActivityPage { } loadMoreRecords() { + // cy.get(this.loadButton) + // .then(($button) => { + // cy.wrap($button).click() + // cy.wait(2000) + // debugger + // if ($button.is(':visible')) { + // // If the button is still visible, call the function again + // debugger + // this.loadMoreRecords(); + // } + // }); cy.get("body").then($body => { if ($body.find(this.loadButton).length > 0) { cy.get(this.loadButton).click({ force: true }) cy.wait(2000) + this.loadMoreRecords() } }) } + } export default ActivityPage \ No newline at end of file diff --git a/e2e/cypress/pageObjects/apiDirectory.ts b/e2e/cypress/pageObjects/apiDirectory.ts index 984129983..f0911e67e 100644 --- a/e2e/cypress/pageObjects/apiDirectory.ts +++ b/e2e/cypress/pageObjects/apiDirectory.ts @@ -17,6 +17,7 @@ class ApiDirectoryPage { orgDropDown: string = '[data-testid="orgDropDown"]' orgUnitDropDown: string = '[data-testid="orgUnitDropDown"]' addOrganizationBtn: string = '[data-testid="addOrganizationBtn"]' + jwksPublicKeyCheckBox: string = '[data-testid="access-rqst-app-env-public-key"]' createAccessRequest(product: any, app: any, accessRqst: any, elevatedAccess?: boolean) { @@ -57,6 +58,14 @@ class ApiDirectoryPage { cy.get(this.submitBtn).click() } + checkInactiveEnvironmentAccessReqOption(product: any, app: any){ + cy.contains('a', product.name, { timeout: 10000 }).should('be.visible'); + cy.contains(product.name).click() + cy.get(this.rqstAccessBtn).click() + cy.get(this.appSelect).select(app.name) + cy.get('[data-testid=access-rqst-app-env-' + product.environment + ']').should('not.exist'); + } + isProductDisplay(productName: string, expResult: boolean) { cy.get("button").then(($btn) => { var flag = true @@ -105,14 +114,14 @@ class ApiDirectoryPage { cy.get(this.addOrganizationBtn).click({ force: true }) } - checkOrgAdminNotificationBanner(notification: any) { + checkOrgAdminNotificationBanner(notification: any, childMessage: string) { cy.get('[data-testid="org-assignment-notification-parent"]').invoke('text').then((text) => { text = this.getPlainText(text) - assert.equal(text, notification.parent) + assert.equal(text, notification) cy.contains('button', 'Learn More').click() cy.get('[data-testid="org-assignment-notification-child"]').invoke('text').then((text) => { text = this.getPlainText(text) - assert.equal(text, notification.child) + assert.equal(text, childMessage) }) }) } @@ -120,6 +129,24 @@ class ApiDirectoryPage { getPlainText(text: string): string { return text.replace(/[\r\n]/g, '').replace(/\s+/g, " ") } + + enterInvalidJWTKey(product: any, app: any, accessRqst: any) { + cy.contains(product.name).click() + cy.get(this.rqstAccessBtn).click() + cy.get(this.appSelect).select(app.name) + cy.get('[data-testid=access-rqst-app-env-' + product.environment + ']').click() + cy.get('body', { log: false }).then(($body) => { + if ($body.find(this.legatTermCheckBox).length > 0) { + cy.get(this.legatTermCheckBox).first().click() + } + }) + cy.readFile('cypress/fixtures/state/jwtReGenPublicKey_new.pub').then((publicKeyKey) => { + cy.get(this.jwksPublicKeyCheckBox).click() + cy.get('[name="clientCertificate"]').click().type(publicKeyKey + "End of File") + }) + cy.get(this.additionalNotes).type(accessRqst.notes) + cy.get(this.submitBtn).click() + } } export default ApiDirectoryPage diff --git a/e2e/cypress/pageObjects/authProfile.ts b/e2e/cypress/pageObjects/authProfile.ts index 09ce67d09..cb69ccb7a 100644 --- a/e2e/cypress/pageObjects/authProfile.ts +++ b/e2e/cypress/pageObjects/authProfile.ts @@ -165,6 +165,21 @@ class AuthorizationProfile { cy.contains(issuerURL).should('exist') cy.visit(this.path) } + + deleteAuthProfile(authProfileName: string) { + cy.wait(2000) + let authProfileText + cy.get(this.profileTable).find('tr').each(($e1, index, $list) => { + authProfileText = $e1.find('td:nth-child(1)').text(); + if (authProfileText===authProfileName) { + cy.wrap($e1).find('button').eq(1).click() + cy.wait(2000) + cy.wrap($e1).find('button').last().click({force: true}) + cy.verifyToastMessage(authProfileName +' deleted') + return false + } + }) + } } export default AuthorizationProfile diff --git a/e2e/cypress/pageObjects/consumers.ts b/e2e/cypress/pageObjects/consumers.ts index 95e50f454..93887f5b6 100644 --- a/e2e/cypress/pageObjects/consumers.ts +++ b/e2e/cypress/pageObjects/consumers.ts @@ -156,8 +156,13 @@ export default class ConsumersPage { cy.get(this.consumerDialogSaveBtn, { timeout: 2000 }).should('not.exist') } - approvePendingRequest() { - cy.get(this.approveBtn).click({ force: true }) + approvePendingRequest(flag?: boolean) { + if (flag) { + cy.get(this.approveBtn).click({ force: true, multiple : true }) + } + else { + cy.get(this.approveBtn).click({ force: true }) + } cy.wait(1000) cy.verifyToastMessage("Access request approved") } @@ -318,12 +323,20 @@ export default class ConsumersPage { cy.wait(1000) } - selectAuthorizationScope(scopes: any) { + selectAuthorizationScope(scopes: any, isChecked = true) { cy.contains("Authorization").click() - scopes.forEach(function (scope: string) { - cy.get('[data-testid="client-scope-' + scope + '"]').click() - cy.wait(1000) - }) + if (isChecked) { + scopes.forEach(function (scope: string) { + cy.get('[data-testid="client-scope-' + scope + '"]').find('[type="checkbox"]').check({ force: true }); + cy.wait(1000) + }) + } + else { + scopes.forEach(function (scope: string) { + cy.get('[data-testid="client-scope-' + scope + '"]').find('[type="checkbox"]').uncheck({ force: true }); + cy.wait(1000) + }) + } } selectClientRole(roles: any) { @@ -339,21 +352,26 @@ export default class ConsumersPage { cy.log($row.find('td:nth-child(1)').text()) if ($row.find('td:nth-child(1)').text() == consumerID) { cy.wrap($row).find('button').first().click() - cy.get('[data-testid="consumer-delete-menuitem"]').last().click({force:true}) + cy.get('[data-testid="consumer-delete-menuitem"]').last().click({ force: true }) } }) } + + saveAppliedConfig(){ + cy.get(this.consumerDialogSaveBtn).click() + cy.wait(1000) + } clickOnLinkConsumerToNamespaceBtn() { - cy.get(this.linkConsumerToNamespaceBtn).click({force:true}) + cy.get(this.linkConsumerToNamespaceBtn).click({ force: true }) } linkTheConsumerToNamespace(consumerID: any) { cy.get(this.userNameTxt).type(consumerID) - cy.get(this.linkBtn).click({force:true}) + cy.get(this.linkBtn).click({ force: true }) } - getText(){ + getText() { cy.get('[data-testid="all-consumer-control-tbl"]').find('tr').last().find('td').first().find('a').as('inputValue') } } \ No newline at end of file diff --git a/e2e/cypress/pageObjects/keycloakClientScopes.ts b/e2e/cypress/pageObjects/keycloakClientScopes.ts new file mode 100644 index 000000000..cdb96bd90 --- /dev/null +++ b/e2e/cypress/pageObjects/keycloakClientScopes.ts @@ -0,0 +1,23 @@ +import { Assertion } from "chai" + +class keycloakClientScopesPage { + path: string = '/' + + clientTab: string = '[data-ng-controller="ClientTabCtrl"]' + + selectTab(tabName: string){ + cy.get(this.clientTab).contains('a',tabName).click() + } + + verifyAssignedScope(scope: string, expResult:boolean) + { + if(expResult){ + cy.get('[id="assigned"]').find('[title="'+scope+'"]').should('exist'); + } + else{ + cy.get('[id="assigned"]').find('[title="'+scope+'"]').should('not.exist'); + } + } +} + +export default keycloakClientScopesPage diff --git a/e2e/cypress/pageObjects/myAccess.ts b/e2e/cypress/pageObjects/myAccess.ts index 9865f08b4..65b5d8bd6 100644 --- a/e2e/cypress/pageObjects/myAccess.ts +++ b/e2e/cypress/pageObjects/myAccess.ts @@ -14,6 +14,7 @@ class myAccessPage { regenerateCredentialCloseBtn: string = '[data-testid=regenerate-credentials-done-button]' collectCredentialsBtn: string = '[data-testid="generate-credentials-button"]' clientIDValueTxt: string = '[data-testid="sa-new-creds-client-id"]' + cancelRequestAccessRequest: string = '[data-testid="access-request-cancel-button"]' path: string = '/devportal/access' @@ -37,6 +38,11 @@ class myAccessPage { cy.get(this.closeRequestAccesss).click() } + cancelRequestAccessPopUp() + { + cy.get(this.cancelRequestAccessRequest).click() + } + saveReGenAPIKeyValue(): void { cy.get(this.apiKyeValueTxt).invoke('val').then(($apiKey: any) => { cy.saveState('newApiKey', $apiKey) @@ -166,6 +172,7 @@ class myAccessPage { cy.saveState('clientID', $clientID) }) } + } export default myAccessPage diff --git a/e2e/cypress/pageObjects/products.ts b/e2e/cypress/pageObjects/products.ts index 31f030291..e1b1ff727 100644 --- a/e2e/cypress/pageObjects/products.ts +++ b/e2e/cypress/pageObjects/products.ts @@ -319,6 +319,25 @@ class Products { cy.get(this.messageForNotDataset).should('be.visible'); } + + verifyAuthScope(expAuthValue: string){ + cy.get(this.envCfgAuthzDropdown).find(':selected').invoke('text').then(($auth: any) => { + assert.equal($auth,expAuthValue ) + }) + } + + verifyIssuer(expIssuerValue: string){ + cy.get('[name="credentialIssuer"]').find(':selected').invoke('text').then(($issuer: any) => { + assert.equal($issuer,expIssuerValue ) + }) + } + + verifyDataset(expDatasetValue: string, product: string){ + this.editProduct(product) + cy.get(this.catelogueDropDown).invoke('val').then(($dataset: any) => { + assert.equal($dataset,expDatasetValue) + }) + } } export default Products diff --git a/e2e/cypress/support/auth-commands.ts b/e2e/cypress/support/auth-commands.ts index 23f266765..a031aed1c 100644 --- a/e2e/cypress/support/auth-commands.ts +++ b/e2e/cypress/support/auth-commands.ts @@ -1,9 +1,6 @@ import * as jwt from 'jsonwebtoken' import HomePage from '../pageObjects/home' import LoginPage from '../pageObjects/login' -import request = require('request') -import { method } from 'cypress/types/bluebird' -import { url } from 'inspector' import NamespaceAccessPage from '../pageObjects/namespaceAccess' import _ = require('cypress/types/lodash') import { checkElementExists } from './e2e' @@ -82,9 +79,9 @@ Cypress.Commands.add('keycloakLogin', (username: string, password: string) => { cy.get(login.loginSubmitButton).click() }) -Cypress.Commands.add('getLastConsumerID',() =>{ - let id : any - cy.get('[data-testid="all-consumer-control-tbl"]').find('tr').last().find('td').first().find('a').then(($text)=>{ +Cypress.Commands.add('getLastConsumerID', () => { + let id: any + cy.get('[data-testid="all-consumer-control-tbl"]').find('tr').last().find('td').first().find('a').then(($text) => { id = $text.text() return id }) @@ -112,7 +109,7 @@ Cypress.Commands.add('resetCredential', (accessRole: string) => { }) }) -Cypress.Commands.add('getUserSessionTokenValue', (namespace: string) => { +Cypress.Commands.add('getUserSessionTokenValue', (namespace: string, isNamespaceSelected?: true) => { const login = new LoginPage() const home = new HomePage() const na = new NamespaceAccessPage() @@ -128,7 +125,9 @@ Cypress.Commands.add('getUserSessionTokenValue', (namespace: string) => { cy.login(user.credentials.username, user.credentials.password) cy.log('Logged in!') // home.useNamespace(apiTest.namespace) - home.useNamespace(namespace) + if (isNamespaceSelected || undefined) { + home.useNamespace(namespace) + } cy.get('@login').then(function (xhr: any) { userSession = xhr.response.headers['x-auth-request-access-token'] return userSession @@ -234,7 +233,7 @@ Cypress.Commands.add('getAccessToken', (client_id: string, client_secret: string cy.log('> Get Token') }) -Cypress.Commands.add('getServiceOrRouteID', (configType: string) => { +Cypress.Commands.add('getServiceOrRouteID', (configType: string, host: string) => { const config = configType.toLowerCase() cy.request({ method: 'GET', @@ -242,10 +241,10 @@ Cypress.Commands.add('getServiceOrRouteID', (configType: string) => { }).then((res) => { expect(res.status).to.eq(200) if (config === 'routes') { - cy.saveState(config + 'ID', Cypress._.get((Cypress._.filter(res.body.data, ["hosts", ["a-service-for-newplatform.api.gov.bc.ca"]]))[0], 'id')) + cy.saveState(config + 'ID', Cypress._.get((Cypress._.filter(res.body.data, ["hosts", [host+".api.gov.bc.ca"]]))[0], 'id')) } else { - cy.saveState(config + 'ID', Cypress._.get((Cypress._.filter(res.body.data, ["name", "a-service-for-newplatform"]))[0], 'id')) + cy.saveState(config + 'ID', Cypress._.get((Cypress._.filter(res.body.data, ["name", host]))[0], 'id')) } }) }) @@ -260,17 +259,18 @@ Cypress.Commands.add('publishApi', (fileName: string, namespace: string, flag?: () => { cy.wait(3000) cy.get('@accessTokenResponse').then((res: any) => { - const options = { - method: 'PUT', - url: Cypress.env('GWA_API_URL') + '/namespaces/' + namespace + '/gateway', - } - formDataRequest(options, res.body.access_token, fileName, requestName) - cy.wait(`@${requestName}`).then((res: any) => { - cy.wrap(res.response).as('publishAPIResponse') + cy.executeCliCommand('gwa config set --namespace ' + namespace).then((response) => { + cy.executeCliCommand('gwa config set --token ' + res.body.access_token).then((response) => { + { + expect(response.stdout).to.contain("Config settings saved") + cy.executeCliCommand('gwa pg ./cypress/fixtures/' + fileName).then((response) => { + expect(response.stdout).to.contain("Gateway config published") + }) + } + }) }) }) - } - ) + }) }) }) @@ -295,8 +295,7 @@ Cypress.Commands.add('makeKongRequest', (serviceName: string, methodType: string cy.fixture('state/regen').then((creds: any) => { cy.wait(5000) let token = key - if (key==undefined) - { + if (key == undefined) { token = creds.apikey } const service = serviceName @@ -361,7 +360,7 @@ Cypress.Commands.add('updateKongPlugin', (pluginName: string, name: string, endP let endpoint if (pluginName == '') endpoint = 'plugins' - else if(id !== undefined) + else if (id !== undefined) endpoint = pluginName.toLowerCase() + '/' + id.toString() + '/' + 'plugins' endpoint = (typeof endPoint !== 'undefined') ? endPoint : endpoint body = config[name] @@ -379,7 +378,7 @@ Cypress.Commands.add('updateKongPlugin', (pluginName: string, name: string, endP Cypress.Commands.add('updateKongPluginForJSONRequest', (jsonBody: string, endPoint: string, verb = 'POST') => { cy.fixture('state/store').then((creds: any) => { let body = {} - let headers = {"content-type": "application/json", "accept": "application/json"} + let headers = { "content-type": "application/json", "accept": "application/json" } body = jsonBody return cy.request({ url: Cypress.env('KONG_CONFIG_URL') + '/' + endPoint, @@ -503,6 +502,9 @@ Cypress.Commands.add('updatePropertiesOfPluginFile', (filename: string, property if (propertyName === "config.anonymous") { obj.plugins[0].config.anonymous = propertyValue } + else if (propertyName === "tags"){ + obj.plugins[0][propertyName] = propertyValue + } else { Object.keys(obj.services).forEach(function (key, index) { if (propertyName == "methods") { @@ -562,14 +564,19 @@ Cypress.Commands.add("generateKeyPair", () => { cy.writeFile('cypress/fixtures/state/jwtReGenPrivateKey_new.pem', privateKeyPem) cy.writeFile('cypress/fixtures/state/jwtReGenPublicKey_new.pub', publicKeyPem) - + }) -Cypress.Commands.add('forceVisit', (url:string) => { +Cypress.Commands.add('forceVisit', (url: string) => { cy.window().then(win => { - return win.open(url, '_self'); + return win.open(url, '_self'); }); -}); +}); + +Cypress.Commands.add('updateJsonBoby', (json: any, key: string, newValue: string):any => { + json[key] = newValue + return json +}); const formDataRequest = ( options: formDataRequestOptions, diff --git a/e2e/cypress/support/global.d.ts b/e2e/cypress/support/global.d.ts index 53ece714d..71d1f2e93 100644 --- a/e2e/cypress/support/global.d.ts +++ b/e2e/cypress/support/global.d.ts @@ -19,7 +19,7 @@ declare namespace Cypress { preserveCookies(): void - makeKongRequest(serviceName : string, methodType : string, key?: string): Chainable + makeKongRequest(serviceName: string, methodType: string, key?: string): Chainable makeKongGatewayRequestUsingClientIDSecret(hostURL: string, methodType?: string): Chainable @@ -36,44 +36,44 @@ declare namespace Cypress { client_secret: string ): Chainable> - publishApi(fileName: string, namespace: string, flag?:boolean): Chainable> - - getServiceOrRouteID(configType: string + publishApi(fileName: string, namespace: string, flag?: boolean): Chainable> + + getServiceOrRouteID(configType: string, host: string ): Chainable> - updateKongPlugin(pluginName : string, name : string, endPoint?: string, verb?: string): Chainable> + updateKongPlugin(pluginName: string, name: string, endPoint?: string, verb?: string): Chainable> - makeKongGatewayRequest(endpoint: string, requestName:string, methodType: string): Chainable> + makeKongGatewayRequest(endpoint: string, requestName: string, methodType: string): Chainable> // generateKeystore() : Chainable - generateKeystore() : void + generateKeystore(): void - setHeaders(headerValues : any) : void + setHeaders(headerValues: any): void - setRequestBody(requestBody : any) : void + setRequestBody(requestBody: any): void - setAuthorizationToken (token : string) : void + setAuthorizationToken(token: string): void - makeAPIRequest(endPoint: string,methodType: string): Chainable> + makeAPIRequest(endPoint: string, methodType: string): Chainable> getUserSession(): Chainable> - compareJSONObjects(actualResponse: any, expectedResponse:any, indexFlag?: boolean) : Chainable> + compareJSONObjects(actualResponse: any, expectedResponse: any, indexFlag?: boolean): Chainable> - getUserSessionTokenValue(namespace: string): Chainable> + getUserSessionTokenValue(namespace: string, isNamespaceSelected?: boolean): Chainable> getUserSessionResponse(): Chainable> - getTokenUsingJWKCredentials(credential: any, privateKey: any):Chainable> + getTokenUsingJWKCredentials(credential: any, privateKey: any): Chainable> - verifyToastMessage(msg: string):Chainable> + verifyToastMessage(msg: string): Chainable> - updatePluginFile (filename: string, serviceName: string, pluginFileName: string):Chainable> + updatePluginFile(filename: string, serviceName: string, pluginFileName: string): Chainable> - updateElementsInPluginFile(filename: string, elementName: string, elementValue: string):Chainable> + updateElementsInPluginFile(filename: string, elementName: string, elementValue: string): Chainable> - updatePropertiesOfPluginFile(filename: string, propertyName: any, propertyValue: any):Chainable> + updatePropertiesOfPluginFile(filename: string, propertyName: any, propertyValue: any): Chainable> keycloakLogin(username: string, password: string): Chainable @@ -81,13 +81,25 @@ declare namespace Cypress { getLastConsumerID(): Chainable - generateKeyPair() : void + generateKeyPair(): void // isProductDisplay(productName: string, expResult : boolean) :Chainable> - updateJsonValue(jsonBody: any, jsonPath: string, newValue: string, index?: number): Chainable + updateJsonValue(filePath: string, jsonPath: string, newValue: string, index?: any): Chainable updateKongPluginForJSONRequest(jsonBody: string, endPoint: string, verb?: string): Chainable> - - forceVisit (url:string): Chainable + + forceVisit(url: string): Chainable + + executeCliCommand(command: string): Chainable + + replaceWordInJsonObject(targetWord: string, replacement: string, fileName: string): Chainable> + + gwaPublish(type: string, fileName: string): Chainable> + + replaceWord(originalString: string, wordToReplace: string, replacementWord: string): Chainable + + updateJsonBoby(json: any, key: string, newValue: string):Chainable + + deleteFileInE2EFolder(fileName: string):Chainable } } diff --git a/e2e/cypress/support/util-commands.ts b/e2e/cypress/support/util-commands.ts index ad61b4fb5..9d1653869 100644 --- a/e2e/cypress/support/util-commands.ts +++ b/e2e/cypress/support/util-commands.ts @@ -1,5 +1,8 @@ import 'cypress-v10-preserve-cookie' -import jsonpath = require('jsonpath'); +const YAML = require('yamljs'); +const path = require('path'); + + const listOfCookies = [ 'AUTH_SESSION_ID_LEGACY', 'KC_RESTART', @@ -107,10 +110,78 @@ Cypress.Commands.add('resetState', () => { cy.log('Test state was reset') }) -Cypress.Commands.add('updateJsonValue', (jsonBody: any, jsonPath: string, newValue: string, index?: any) => { - let updatedFileContent: any - const jsonContent = JSON.parse(jsonBody); - jsonpath.apply(jsonContent, jsonPath, () => newValue); - updatedFileContent = JSON.stringify(jsonContent, null, 2); - return updatedFileContent +Cypress.Commands.add('updateJsonValue', (filePath: string, jsonPath: string, newValue: string, index?: any) => { + debugger + cy.readFile('cypress/fixtures/' + filePath).then(currState => { + debugger + + const keys = jsonPath.split('.'); // Split the keyPath using dot notation + let currentObj = currState; + + for (let i = 0; i < keys.length - 1; i++) { + const key = keys[i]; + if (!currentObj.hasOwnProperty(key) || typeof currentObj[key] !== 'object') { + return; // If any intermediate key doesn't exist or is not an object, return without updating + } + currentObj = currentObj[key]; + } + + const lastKey = keys[keys.length - 1]; + currentObj[lastKey] = newValue; + + cy.writeFile('cypress/fixtures/' + filePath, currState) + }) + + +}) + +Cypress.Commands.add('executeCliCommand', (command: string) => { + cy.exec(command, { timeout: 9000, failOnNonZeroExit: false }).then((response) => { + return response + }); +}) + +Cypress.Commands.add('replaceWordInJsonObject', (targetWord: string, replacement: string, fileName: string) => { + debugger + cy.readFile('cypress/fixtures/' + fileName).then((content: any) => { + let regex = new RegExp(targetWord, 'g'); + let modifiedString = content.replace(regex, replacement); + + let obj = YAML.parse(modifiedString) + + const yamlString = YAML.stringify(obj, 'utf8'); + cy.writeFile('cypress/fixtures/' + fileName, yamlString) + }) + +}) + +Cypress.Commands.add('gwaPublish', (type: string, fileName: string) => { + cy.exec('gwa publish '+type+' --input ./cypress/fixtures/test_data/'+fileName, { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + return response + }); +}) +// cypress/support/commands.js + +Cypress.Commands.add('deleteFileInE2EFolder', (fileName: string) => { + const currentDirectory = Cypress.config('fileServerFolder'); // Get the current working directory + const filePath = path.join(currentDirectory, fileName) + debugger + try { + cy.exec(`rm -f ${filePath}`); + cy.log(`File '${fileName}' has been deleted from the e2e folder.`); + } catch (error) { + cy.log(`Error deleting file '${fileName}' from the e2e folder`); + } +}); + + +Cypress.Commands.add('replaceWord', (originalString: string, wordToReplace: string, replacementWord: string)=> { + // Create a regular expression with the 'g' flag for global search + let replacedString : any + const regex = new RegExp(wordToReplace, 'g'); + + // Use the 'replace()' method to replace all occurrences of the word + replacedString = originalString.replace(regex, replacementWord); + + return replacedString; }) \ No newline at end of file diff --git a/e2e/cypress/tests/01-api-key/01-create-api.cy.ts b/e2e/cypress/tests/01-api-key/01-create-api.cy.ts index 5e1abba9c..20f5bd96f 100644 --- a/e2e/cypress/tests/01-api-key/01-create-api.cy.ts +++ b/e2e/cypress/tests/01-api-key/01-create-api.cy.ts @@ -10,7 +10,7 @@ describe('Create API Spec', () => { const sa = new ServiceAccountsPage() const pd = new Products() var nameSpace: string - let userSession: string + let userSession: any before(() => { cy.visit('/') @@ -23,31 +23,43 @@ describe('Create API Spec', () => { cy.preserveCookies() cy.fixture('apiowner').as('apiowner') cy.fixture('api').as('api') - // cy.visit(login.path) + cy.visit(login.path) }) - it('authenticates Janis (api owner)', () => { - cy.get('@apiowner').then(({ user }: any) => { - cy.login(user.credentials.username, user.credentials.password) + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ namespace }: any) => { + cy.getUserSessionTokenValue(namespace, false).then((value) => { + userSession = value + }) }) }) - it('creates and activates new namespace', () => { + it('Check gwa config command to set environment', () => { + var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, ""); + cy.executeCliCommand('gwa config set --host ' + cleanedUrl + ' --scheme http').then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('Check gwa config command to set token', () => { + cy.executeCliCommand('gwa config set --token ' + userSession).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('creates new namespace', () => { cy.getUserSession().then(() => { cy.get('@apiowner').then(({ namespace }: any) => { nameSpace = namespace - home.createNamespace(namespace) - cy.get('@login').then(function (xhr: any) { - userSession = xhr.response.headers['x-auth-request-access-token'] + cy.executeCliCommand('gwa namespace create -n ' + namespace).then((response) => { + assert.equal(response.stdout, namespace) }) }) }) }) - it('Verify for invalid namespace name', () => { - cy.get('@apiowner').then(({ invalid_namespace }: any) => { - home.validateNamespaceName(invalid_namespace) - }) + it('activates new namespace', () => { + home.useNamespace(nameSpace) }) it('creates a new service account', () => { @@ -61,18 +73,16 @@ describe('Create API Spec', () => { it('publishes a new API for Dev environment to Kong Gateway', () => { cy.get('@apiowner').then(({ namespace }: any) => { - cy.publishApi('service.yml', namespace).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - }) + cy.publishApi('service.yml', namespace).then((response: any) => { + expect(response.stdout).to.contain('Sync successful'); }) }) }) - it('creates as new product in the directory', () => { - cy.visit(pd.path) - cy.get('@apiowner').then(({ product }: any) => { - pd.createNewProduct(product.name, product.environment.name) + it('Upload dataset and Product using GWA Apply command', () => { + cy.executeCliCommand('gwa apply').then((response) => { + let wordOccurrences = (response.stdout.match(/\bcreated\b/g) || []).length; + expect(wordOccurrences).to.equal(2) }) }) @@ -89,7 +99,7 @@ describe('Create API Spec', () => { it('Verify the message when no dataset is linked to BCDC', () => { cy.visit(pd.path) cy.get('@apiowner').then(({ product }: any) => { - pd.checkMessageForNoDataset(product.name,"health") + pd.checkMessageForNoDataset(product.name, "health") }) }) @@ -116,17 +126,14 @@ describe('Create API Spec', () => { pd.addEnvToProduct(product.name, product.test_environment.name) pd.editProductEnvironment(product.name, product.test_environment.name) pd.editProductEnvironmentConfig(product.test_environment.config) - pd.generateKongPluginConfig(product.name, product.test_environment.name,'service.yml', true) + pd.generateKongPluginConfig(product.name, product.test_environment.name, 'service.yml', true) }) }) it('applies authorization plugin to service published to Kong Gateway', () => { cy.get('@apiowner').then(({ namespace }: any) => { - cy.publishApi('service-plugin.yml', namespace).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - expect(res.body.message).to.contains("Sync successful") - }) + cy.publishApi('service-plugin.yml', namespace).then((response: any) => { + expect(response.stdout).to.contain('Sync successful'); }) }) }) @@ -134,7 +141,7 @@ describe('Create API Spec', () => { it('activate the service for Test environment', () => { cy.visit(pd.path) cy.get('@apiowner').then(({ product }: any) => { - pd.activateService(product.name, product.test_environment.name,product.test_environment.config) + pd.activateService(product.name, product.test_environment.name, product.test_environment.config) cy.wait(3000) }) }) @@ -143,11 +150,22 @@ describe('Create API Spec', () => { cy.visit(pd.path) cy.get('@apiowner').then(({ product }: any) => { // pd.editProductEnvironment(product.name, product.environment.name) - pd.activateService(product.name, product.environment.name,product.environment.config) + pd.activateService(product.name, product.environment.name, product.environment.config) cy.wait(3000) }) }) + it('verify status of the services using "gwa status" command', () => { + cy.get('@apiowner').then(({ product }: any) => { + cy.executeCliCommand('gwa status').then((response) => { + expect(response.stdout).to.contain(product.environment.config.serviceName); + expect(response.stdout).to.contain(product.test_environment.config.serviceName); + const wordOccurrences = (response.stdout.match(/\b200 Response\b/g) || []).length; + expect(wordOccurrences).to.equal(2) + }) + }) + }) + after(() => { cy.logout() cy.clearLocalStorage({ log: true }) diff --git a/e2e/cypress/tests/01-api-key/02-team-access.cy.ts b/e2e/cypress/tests/01-api-key/02-team-access.cy.ts index c3dda8ffe..84161c65c 100644 --- a/e2e/cypress/tests/01-api-key/02-team-access.cy.ts +++ b/e2e/cypress/tests/01-api-key/02-team-access.cy.ts @@ -39,17 +39,8 @@ describe('Team Access Spec', () => { }) }) - // it('Grant CredentialIssuer.Admin permission to Janis (API Owner)', () => { - // cy.get('@apiowner').then(({ grantPermission }: any) => { - // na.clickGrantUserAccessButton() - // na.grantPermission(grantPermission.Janis) - // }) - // }) - it('Grant CredentialIssuer.Admin permission to Janis (API Owner)', () => { cy.get('@apiowner').then(({ grantPermission }: any) => { - // na.clickGrantUserAccessButton() - // na.grantPermission(grantPermission.Janis) na.editPermission(grantPermission.Janis) }) }) diff --git a/e2e/cypress/tests/01-api-key/03-request-access-inactive-env.cy.ts b/e2e/cypress/tests/01-api-key/03-request-access-inactive-env.cy.ts new file mode 100644 index 000000000..cf01b89e4 --- /dev/null +++ b/e2e/cypress/tests/01-api-key/03-request-access-inactive-env.cy.ts @@ -0,0 +1,143 @@ +import ApiDirectoryPage from '../../pageObjects/apiDirectory' +import ApplicationPage from '../../pageObjects/applications' +import HomePage from '../../pageObjects/home' +import LoginPage from '../../pageObjects/login' +import NamespaceAccessPage from '../../pageObjects/namespaceAccess' +import Products from '../../pageObjects/products' +import MyAccessPage from '../../pageObjects/myAccess' + +describe('Change an Active environment to Inactive', () => { + const login = new LoginPage() + const home = new HomePage() + const na = new NamespaceAccessPage() + const pd = new Products() + + before(() => { + cy.visit('/') + cy.deleteAllCookies() + cy.reload() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('apiowner').as('apiowner') + // cy.visit(login.path) + }) + + it('authenticates Janis (api owner)', () => { + cy.get('@apiowner').then(({ user, namespace }: any) => { + cy.login(user.credentials.username, user.credentials.password) + cy.log('Logged in!') + home.useNamespace(namespace) + }) + }) + + it('Navigate to Products Page', () => { + cy.visit(pd.path) + }) + + it('Change the current active environment to inactive state', () => { + cy.get('@apiowner').then(({ product }: any) => { + pd.editProductEnvironment(product.name, product.environment.name) + pd.editProductEnvironmentConfig(product.environment.config, true) + }) + }) + + after(() => { + cy.logout() + cy.clearLocalStorage({ log: true }) + cy.deleteAllCookies() + }) +}) + +describe('Verify enactive environment in rrequest access pop up', () => { + const apiDir = new ApiDirectoryPage() + const app = new ApplicationPage() + const myAccessPage = new MyAccessPage() + + before(() => { + cy.visit('/') + cy.deleteAllCookies() + cy.reload() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('developer').as('developer') + // cy.visit(login.path) + }) + + it('authenticates Harley (developer)', () => { + cy.get('@developer').then(({ user }: any) => { + cy.login(user.credentials.username, user.credentials.password) + }) + }) + + it('creates an application', () => { + cy.visit(app.path) + cy.get('@developer').then(({ application }: any) => { + app.createApplication(application) + }) + }) + + it('Verify that inactive environment is not displayed', () => { + cy.visit(apiDir.path) + cy.get('@developer').then(({ product, application }: any) => { + apiDir.checkInactiveEnvironmentAccessReqOption(product, application) + }) + }) + + it('Close the popup by click on Cancel button', () => { + myAccessPage.cancelRequestAccessPopUp() + }) + + after(() => { + cy.logout() + cy.clearLocalStorage({ log: true }) + cy.deleteAllCookies() + }) +}) + +describe('Change an the environment back to active', () => { + const login = new LoginPage() + const home = new HomePage() + const na = new NamespaceAccessPage() + const pd = new Products() + + before(() => { + cy.visit('/') + cy.deleteAllCookies() + cy.reload() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('apiowner').as('apiowner') + // cy.visit(login.path) + }) + + it('authenticates Janis (api owner)', () => { + cy.get('@apiowner').then(({ user, namespace }: any) => { + cy.login(user.credentials.username, user.credentials.password) + cy.log('Logged in!') + home.useNamespace(namespace) + }) + }) + + it('Navigate to Products Page', () => { + cy.visit(pd.path) + }) + + it('Change the environment back to active state', () => { + cy.get('@apiowner').then(({ product }: any) => { + pd.editProductEnvironment(product.name, product.environment.name) + pd.editProductEnvironmentConfig(product.environment.config) + }) + }) + + after(() => { + cy.logout() + cy.clearLocalStorage({ log: true }) + cy.deleteAllCookies() + }) +}) \ No newline at end of file diff --git a/e2e/cypress/tests/01-api-key/03-request-access-with-out-collecting-credentials.cy.ts b/e2e/cypress/tests/01-api-key/04-request-access-with-out-collecting-credentials.cy.ts similarity index 87% rename from e2e/cypress/tests/01-api-key/03-request-access-with-out-collecting-credentials.cy.ts rename to e2e/cypress/tests/01-api-key/04-request-access-with-out-collecting-credentials.cy.ts index 63747c8fa..4eb63eb4c 100644 --- a/e2e/cypress/tests/01-api-key/03-request-access-with-out-collecting-credentials.cy.ts +++ b/e2e/cypress/tests/01-api-key/04-request-access-with-out-collecting-credentials.cy.ts @@ -26,13 +26,6 @@ describe('Request Access without colleting credential Spec', () => { }) }) - it('creates an application', () => { - cy.visit(app.path) - cy.get('@developer').then(({ application }: any) => { - app.createApplication(application) - }) - }) - it('Collect the credentials', () => { cy.visit(apiDir.path) cy.get('@developer').then(({ product, application,accessRequest }: any) => { diff --git a/e2e/cypress/tests/01-api-key/04-review-request-without-collecting-credentials.cy.ts b/e2e/cypress/tests/01-api-key/05-review-request-without-collecting-credentials.cy.ts similarity index 81% rename from e2e/cypress/tests/01-api-key/04-review-request-without-collecting-credentials.cy.ts rename to e2e/cypress/tests/01-api-key/05-review-request-without-collecting-credentials.cy.ts index 06a133037..39f89c4c7 100644 --- a/e2e/cypress/tests/01-api-key/04-review-request-without-collecting-credentials.cy.ts +++ b/e2e/cypress/tests/01-api-key/05-review-request-without-collecting-credentials.cy.ts @@ -12,8 +12,6 @@ describe('Approve Pending Request without collecting credentials Spec', () => { cy.visit('/') cy.deleteAllCookies() cy.reload() - cy.getServiceOrRouteID('services') - cy.getServiceOrRouteID('routes') }) beforeEach(() => { @@ -25,9 +23,11 @@ describe('Approve Pending Request without collecting credentials Spec', () => { }) it('authenticates Mark (Access-Manager)', () => { - cy.get('@access-manager').then(({ user, namespace }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(namespace); + cy.get('@apiowner').then(({ namespace }: any) => { + cy.get('@access-manager').then(({ user }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(namespace); + }) }) }) @@ -45,5 +45,5 @@ describe('Approve Pending Request without collecting credentials Spec', () => { cy.clearLocalStorage({ log: true }) cy.deleteAllCookies() }) - + }) \ No newline at end of file diff --git a/e2e/cypress/tests/01-api-key/05-collect-credentials.cy.ts b/e2e/cypress/tests/01-api-key/06-collect-credentials.cy.ts similarity index 100% rename from e2e/cypress/tests/01-api-key/05-collect-credentials.cy.ts rename to e2e/cypress/tests/01-api-key/06-collect-credentials.cy.ts diff --git a/e2e/cypress/tests/01-api-key/06-approve-pending-rqst.cy.ts b/e2e/cypress/tests/01-api-key/07-approve-pending-rqst.cy.ts similarity index 92% rename from e2e/cypress/tests/01-api-key/06-approve-pending-rqst.cy.ts rename to e2e/cypress/tests/01-api-key/07-approve-pending-rqst.cy.ts index e0a21c595..1dc6ca499 100644 --- a/e2e/cypress/tests/01-api-key/06-approve-pending-rqst.cy.ts +++ b/e2e/cypress/tests/01-api-key/07-approve-pending-rqst.cy.ts @@ -12,8 +12,6 @@ describe('Approve Pending Request Spec', () => { cy.visit('/') cy.deleteAllCookies() cy.reload() - cy.getServiceOrRouteID('services') - cy.getServiceOrRouteID('routes') }) beforeEach(() => { @@ -35,9 +33,11 @@ describe('Approve Pending Request Spec', () => { }) it('authenticates Mark (Access-Manager)', () => { - cy.get('@access-manager').then(({ user, namespace }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(namespace); + cy.get('@apiowner').then(({ namespace }: any) => { + cy.get('@access-manager').then(({ user }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(namespace); + }) }) }) diff --git a/e2e/cypress/tests/01-api-key/07-grant-access.cy.ts b/e2e/cypress/tests/01-api-key/08-grant-access.cy.ts similarity index 87% rename from e2e/cypress/tests/01-api-key/07-grant-access.cy.ts rename to e2e/cypress/tests/01-api-key/08-grant-access.cy.ts index 5658cfebc..7f0ad2b15 100644 --- a/e2e/cypress/tests/01-api-key/07-grant-access.cy.ts +++ b/e2e/cypress/tests/01-api-key/08-grant-access.cy.ts @@ -12,8 +12,6 @@ describe('Grant Access Spec', () => { cy.visit('/') cy.deleteAllCookies() cy.reload() - cy.getServiceOrRouteID('services') - cy.getServiceOrRouteID('routes') }) beforeEach(() => { @@ -25,9 +23,11 @@ describe('Grant Access Spec', () => { }) it('authenticates Mark (Access-Manager)', () => { - cy.get('@access-manager').then(({ user, namespace }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(namespace); + cy.get('@apiowner').then(({ namespace }: any) => { + cy.get('@access-manager').then(({ user }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(namespace); + }) }) }) diff --git a/e2e/cypress/tests/01-api-key/09-gwa-get.ts b/e2e/cypress/tests/01-api-key/09-gwa-get.ts new file mode 100644 index 000000000..f39e1f99a --- /dev/null +++ b/e2e/cypress/tests/01-api-key/09-gwa-get.ts @@ -0,0 +1,85 @@ +import ConsumersPage from '../../pageObjects/consumers' +import LoginPage from '../../pageObjects/login' +import HomePage from '../../pageObjects/home' +import ProductPage from '../../pageObjects/products' +const yaml = require('js-yaml'); + +describe('Verify GWA get commands', () => { + const login = new LoginPage() + const consumers = new ConsumersPage() + const home = new HomePage() + var _namespace: string + let userSession: any + let resObj: any + + before(() => { + cy.visit('/') + cy.deleteAllCookies() + cy.reload() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('api').as('api') + cy.fixture('apiowner').as('apiowner') + }) + + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ namespace }: any) => { + cy.getUserSessionTokenValue(namespace, false).then((value) => { + userSession = value + _namespace = namespace + }) + }) + }) + + it('Check gwa config command to set token', () => { + cy.executeCliCommand('gwa config set --token ' + userSession).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('Verify "gwa get" for dataset', () => { + cy.get('@apiowner').then(({ product }: any) => { + cy.executeCliCommand('gwa get datasets').then((response) => { + expect(response.stdout).not.to.contain(product); + }) + }) + }) + + it('Verify "gwa get" for dataset in JSON format', () => { + cy.executeCliCommand('gwa get datasets --json').then((response) => { + cy.get('@api').then(({ apiDirectory }: any) => { + cy.setHeaders(apiDirectory.headers) + cy.setAuthorizationToken(userSession) + cy.makeAPIRequest(apiDirectory.endPoint + '/' + _namespace + '/directory', 'GET').then((res) => { + resObj = res.body[0] + Cypress._.isEqual(resObj, JSON.parse(response.stdout)[0]) + }) + }) + }) + }) + + it('Verify "gwa get" for dataset in YAML format', () => { + cy.executeCliCommand('gwa get datasets --yaml').then((response) => { + const yamlObject = yaml.load(response.stdout) + Cypress._.isEqual(resObj, yamlObject) + }) + }) + + it('Verify "gwa get" for products', () => { + cy.get('@apiowner').then(({ product }: any) => { + cy.executeCliCommand('gwa get products').then((response) => { + expect(response.stdout).not.to.contain(product); + }) + }) + }) + + + after(() => { + cy.logout() + cy.clearLocalStorage({ log: true }) + cy.deleteAllCookies() + }) + +}) \ No newline at end of file diff --git a/e2e/cypress/tests/02-client-credential-flow/01-client-cred-team-access.cy.ts b/e2e/cypress/tests/02-client-credential-flow/01-client-cred-team-access.cy.ts index 8c87f4696..24e2c4b36 100644 --- a/e2e/cypress/tests/02-client-credential-flow/01-client-cred-team-access.cy.ts +++ b/e2e/cypress/tests/02-client-credential-flow/01-client-cred-team-access.cy.ts @@ -7,6 +7,8 @@ describe('Grant appropriate permissions to team members for client credential fl const login = new LoginPage() const home = new HomePage() const na = new NamespaceAccessPage() + let userSession: any + let namespace: string before(() => { cy.visit('/') @@ -20,18 +22,37 @@ describe('Grant appropriate permissions to team members for client credential fl cy.visit(login.path) }) - it('Authenticates api owner', () => { - cy.get('@apiowner').then(({ user }: any) => { - cy.login(user.credentials.username, user.credentials.password) + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace, false).then((value) => { + userSession = value + }) }) }) - it('Creates and activates new namespace', () => { - cy.get('@apiowner').then(({ clientCredentials }: any) => { - home.createNamespace(clientCredentials.namespace) - }) + it('Set token with gwa config command', () => { + cy.exec('gwa config set --token ' + userSession, { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('create namespace using gwa cli command', () => { + var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, ""); + cy.exec('gwa namespace create --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + assert.isNotNaN(response.stdout) + namespace = response.stdout + cy.replaceWordInJsonObject('ccplatform', namespace, 'cc-service-gwa.yml') + cy.updateJsonValue('apiowner.json', 'clientCredentials.namespace', namespace) + // cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace) + cy.executeCliCommand("gwa config set --namespace " + namespace) + }); }) + it('activates new namespace', () => { + home.useNamespace(namespace) + }) + + it('Grant namespace access to access manager(Mark)', () => { cy.get('@apiowner').then(({ clientCredentials }: any) => { cy.visit(na.path) diff --git a/e2e/cypress/tests/02-client-credential-flow/03-client-cred-create-api-prod-auth-pro.cy.ts b/e2e/cypress/tests/02-client-credential-flow/03-client-cred-create-api-prod-auth-pro.cy.ts index 84170a63d..7766994a2 100644 --- a/e2e/cypress/tests/02-client-credential-flow/03-client-cred-create-api-prod-auth-pro.cy.ts +++ b/e2e/cypress/tests/02-client-credential-flow/03-client-cred-create-api-prod-auth-pro.cy.ts @@ -13,7 +13,8 @@ describe('Create API, Product, and Authorization Profiles; Apply Auth Profiles t const pd = new Products() const authProfile = new AuthorizationProfile() var nameSpace: string - let userSession: string + let userSession: any + let namespace : string before(() => { cy.visit('/') @@ -27,11 +28,15 @@ describe('Create API, Product, and Authorization Profiles; Apply Auth Profiles t cy.fixture('api').as('api') cy.visit(login.path) }) - it('Authenticates api owner', () => { - cy.get('@apiowner').then(({ user }: any) => { - cy.login(user.credentials.username, user.credentials.password) + + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace, false).then((value) => { + userSession = value + }) }) }) + it('Activates namespace for client credential flow tests', () => { cy.getUserSession().then(() => { cy.get('@apiowner').then(({ clientCredentials }: any) => { @@ -54,11 +59,11 @@ describe('Create API, Product, and Authorization Profiles; Apply Auth Profiles t it('Publishes a new API to Kong Gateway', () => { cy.get('@apiowner').then(({ clientCredentials }: any) => { - cy.publishApi('cc-service.yml', clientCredentials.namespace, true).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - expect(res.body.message).to.contains("Sync successful") - }) + cy.publishApi('cc-service-gwa.yml', clientCredentials.namespace, true).then(() => { + // cy.get('@publishAPIResponse').then((res: any) => { + // // cy.log(JSON.stringify(res.body)) + // // expect(res.body.message).to.contains("Sync successful") + // }) }) }) }) @@ -107,11 +112,13 @@ describe('Create API, Product, and Authorization Profiles; Apply Auth Profiles t it('applies authorization plugin to service published to Kong Gateway', () => { cy.get('@apiowner').then(({ clientCredentials }: any) => { + cy.replaceWordInJsonObject('ccplatform', clientCredentials.namespace, 'cc-service-plugin.yml') + cy.wait(2000) cy.publishApi('cc-service-plugin.yml', clientCredentials.namespace,true).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - expect(res.body.message).to.contains("Sync successful") - }) + // cy.get('@publishAPIResponse').then((res: any) => { + // // cy.log(JSON.stringify(res.body)) + // // expect(res.body.message).to.contains("Sync successful") + // }) }) }) }) @@ -147,11 +154,13 @@ describe('Create API, Product, and Authorization Profiles; Apply Auth Profiles t it('Applies authorization plugin to service published to Kong Gateway', () => { cy.get('@apiowner').then(({ clientCredentials }: any) => { + cy.replaceWordInJsonObject('ccplatform', clientCredentials.namespace, 'cc-service-plugin.yml') + cy.wait(2000) cy.publishApi('cc-service-plugin.yml', clientCredentials.namespace, true).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - expect(res.body.message).to.contains("Sync successful") - }) + // cy.get('@publishAPIResponse').then((res: any) => { + // // cy.log(JSON.stringify(res.body)) + // // expect(res.body.message).to.contains("Sync successful") + // }) }) }) }) diff --git a/e2e/cypress/tests/02-client-credential-flow/05-cids-access-approve-api-rqst.cy.ts b/e2e/cypress/tests/02-client-credential-flow/05-cids-access-approve-api-rqst.cy.ts index cce000c6f..87693de85 100644 --- a/e2e/cypress/tests/02-client-credential-flow/05-cids-access-approve-api-rqst.cy.ts +++ b/e2e/cypress/tests/02-client-credential-flow/05-cids-access-approve-api-rqst.cy.ts @@ -1,6 +1,10 @@ import HomePage from '../../pageObjects/home' import LoginPage from '../../pageObjects/login' import ConsumersPage from '../../pageObjects/consumers' +import KeycloakUserGroupPage from '../../pageObjects/keycloakUserGroup' +import keycloakGroupPage from '../../pageObjects/keycloakGroup' +import AuthorizationProfile from '../../pageObjects/authProfile' +import keycloakClientScopesPage from '../../pageObjects/keycloakClientScopes' describe('Access manager approves developer access request for Client ID/Secret authenticator', () => { const home = new HomePage() @@ -21,17 +25,17 @@ describe('Access manager approves developer access request for Client ID/Secret }) it('Access Manager logs in', () => { - cy.get('@access-manager').then(({ user, clientCredentials }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(clientCredentials.namespace) + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ clientCredentials }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(clientCredentials.namespace) + }) }) }) it('Access Manager approves developer access request', () => { - cy.get('@access-manager').then(() => { - cy.visit(consumers.path) - consumers.reviewThePendingRequest() - }) + cy.visit(consumers.path) + consumers.reviewThePendingRequest() }) it('Select scopes in Authorization Tab', () => { @@ -56,7 +60,7 @@ describe('Make an API request using Client ID, Secret, and Access Token', () => cy.readFile('cypress/fixtures/state/store.json').then((store_res) => { let cc = JSON.parse(store_res.clientidsecret) - + cy.getAccessToken(cc.clientId, cc.clientSecret).then(() => { cy.get('@accessTokenResponse').then((token_res: any) => { let token = token_res.body.access_token @@ -75,4 +79,160 @@ describe('Make an API request using Client ID, Secret, and Access Token', () => }) }) }) +}) + +describe('Verify the selected client scoped is displayed in assigned default list', () => { + const clientScopes = new keycloakClientScopesPage() + const groups = new keycloakGroupPage() + var nameSpace: string + const home = new HomePage() + const authProfile = new AuthorizationProfile() + + before(() => { + cy.visit(Cypress.env('KEYCLOAK_URL')) + cy.deleteAllCookies() + cy.reload() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('developer').as('developer') + cy.fixture('apiowner').as('apiowner') + cy.fixture('state/regen').as('regen') + cy.fixture('admin').as('admin') + }) + + it('Authenticates Admin owner', () => { + cy.get('@admin').then(({ user }: any) => { + cy.contains('Administration Console').click({ force: true }) + cy.keycloakLogin(user.credentials.username, user.credentials.password) + }) + }) + + it('Navigate to Clients page', () => { + cy.contains('Clients').click() + }) + + it('Select the consumer ID', () => { + cy.readFile('cypress/fixtures/state/store.json').then((store_res) => { + let cc = JSON.parse(store_res.clientidsecret) + cy.contains(cc.clientId).click() + }) + }) + + it('Navigate to client scope tab', () => { + clientScopes.selectTab('Client Scopes') + }) + + it('Verify that "System.Write" scope is in assigned default scope', () => { + clientScopes.verifyAssignedScope('System.Write', true) + }) + + after(() => { + cy.keycloakLogout() + cy.clearLocalStorage({ log: true }) + cy.deleteAllCookies() + }) + +}) + +describe('Deselect the scope from authorization tab', () => { + const login = new LoginPage() + const home = new HomePage() + const consumers = new ConsumersPage() + + before(() => { + cy.visit('/') + cy.deleteAllCookies() + cy.reload() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('access-manager').as('access-manager') + cy.fixture('apiowner').as('apiowner') + cy.fixture('manage-control-config-setting').as('manage-control-config-setting') + // cy.visit(login.path) + }) + + it('authenticates Mark (Access Manager)', () => { + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ clientCredentials }: any) => { + cy.login(user.credentials.username, user.credentials.password).then(() => { + home.useNamespace(clientCredentials.namespace); + }) + }) + }) + }) + + it('Navigate to Consumer page ', () => { + cy.visit(consumers.path); + }) + + it('Select the consumer from the list ', () => { + consumers.clickOnTheFirstConsumerID() + }) + + it('Deselect scopes in Authorization Tab', () => { + cy.get('@apiowner').then(({ clientCredentials }: any) => { + consumers.editConsumerDialog() + consumers.selectAuthorizationScope(clientCredentials.clientIdSecret.authProfile.scopes, false) + consumers.saveAppliedConfig() + }) + }) +}) + +describe('Verify the selected client scoped is not displayed in assigned default list', () => { + const clientScopes = new keycloakClientScopesPage() + const groups = new keycloakGroupPage() + var nameSpace: string + const home = new HomePage() + const authProfile = new AuthorizationProfile() + + before(() => { + cy.visit(Cypress.env('KEYCLOAK_URL')) + cy.deleteAllCookies() + cy.reload() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('developer').as('developer') + cy.fixture('apiowner').as('apiowner') + cy.fixture('state/regen').as('regen') + cy.fixture('admin').as('admin') + }) + + it('Authenticates Admin owner', () => { + cy.get('@admin').then(({ user }: any) => { + cy.contains('Administration Console').click({ force: true }) + cy.keycloakLogin(user.credentials.username, user.credentials.password) + }) + }) + + it('Navigate to Clients page', () => { + cy.contains('Clients').click() + }) + + it('Select the consumer ID', () => { + cy.readFile('cypress/fixtures/state/store.json').then((store_res) => { + let cc = JSON.parse(store_res.clientidsecret) + cy.contains(cc.clientId).click() + }) + }) + + it('Navigate to client scope tab', () => { + clientScopes.selectTab('Client Scopes') + }) + + it('Verify that "System.Write" scope is not in assigned default scope', () => { + clientScopes.verifyAssignedScope('System.Write', false) + }) + + after(() => { + cy.keycloakLogout() + cy.clearLocalStorage({ log: true }) + cy.deleteAllCookies() + }) + }) \ No newline at end of file diff --git a/e2e/cypress/tests/02-client-credential-flow/07-jwt-genkp-access-approve-api-rqst.cy.ts b/e2e/cypress/tests/02-client-credential-flow/07-jwt-genkp-access-approve-api-rqst.cy.ts index 24adf4d1a..6ee1c408a 100644 --- a/e2e/cypress/tests/02-client-credential-flow/07-jwt-genkp-access-approve-api-rqst.cy.ts +++ b/e2e/cypress/tests/02-client-credential-flow/07-jwt-genkp-access-approve-api-rqst.cy.ts @@ -18,13 +18,16 @@ describe('Access manager approves developer access request for JWT - Generated K beforeEach(() => { cy.preserveCookies() cy.fixture('access-manager').as('access-manager') + cy.fixture('apiowner').as('apiowner') // cy.visit(login.path) }) it('Access Manager logs in', () => { - cy.get('@access-manager').then(({ user, clientCredentials }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(clientCredentials.namespace) + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ clientCredentials }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(clientCredentials.namespace) + }) }) }) diff --git a/e2e/cypress/tests/02-client-credential-flow/09-jwks-url-access-approval-api-rqst.cy.ts b/e2e/cypress/tests/02-client-credential-flow/09-jwks-url-access-approval-api-rqst.cy.ts index bdbf8b860..e44f75b99 100644 --- a/e2e/cypress/tests/02-client-credential-flow/09-jwks-url-access-approval-api-rqst.cy.ts +++ b/e2e/cypress/tests/02-client-credential-flow/09-jwks-url-access-approval-api-rqst.cy.ts @@ -19,13 +19,16 @@ describe('Access manager approves developer access request for JWKS URL flow', ( beforeEach(() => { cy.preserveCookies() cy.fixture('access-manager').as('access-manager') + cy.fixture('apiowner').as('apiowner') // cy.visit(login.path) }) it('Access Manager logs in', () => { - cy.get('@access-manager').then(({ user, clientCredentials }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(clientCredentials.namespace) + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ clientCredentials }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(clientCredentials.namespace) + }) }) }) diff --git a/e2e/cypress/tests/02-client-credential-flow/10-jwks-publicKey-access-rqst.cy.ts b/e2e/cypress/tests/02-client-credential-flow/10-jwks-publicKey-access-rqst.cy.ts index c3587dc51..798fdaef3 100644 --- a/e2e/cypress/tests/02-client-credential-flow/10-jwks-publicKey-access-rqst.cy.ts +++ b/e2e/cypress/tests/02-client-credential-flow/10-jwks-publicKey-access-rqst.cy.ts @@ -20,7 +20,7 @@ describe('Generates public/private key and set public key to access request', () beforeEach(() => { cy.preserveCookies() cy.fixture('developer').as('developer') - cy.visit(login.path) + // cy.visit(login.path) }) it('Generate the RS256 key pair', () => { @@ -40,6 +40,19 @@ describe('Generates public/private key and set public key to access request', () }) }) + it('Enter JWT key with invalid format', () => { + cy.visit(apiDir.path) + cy.get('@developer').then(({ clientCredentials, accessRequest }: any) => { + let jwksPublicKey = clientCredentials.jwksPublicKey + apiDir.enterInvalidJWTKey(jwksPublicKey.product, jwksPublicKey.application, accessRequest) + }) + }) + + it('Verify the error popups for invalid JWT key', () => { + cy.wait(3000) + cy.verifyToastMessage("Certificate failed validation") + }) + it('Creates an access request', () => { cy.visit(apiDir.path) cy.get('@developer').then(({ clientCredentials, accessRequest }: any) => { diff --git a/e2e/cypress/tests/02-client-credential-flow/11-jwt-publlicKey-access-approve-api-rqst.cy.ts b/e2e/cypress/tests/02-client-credential-flow/11-jwt-publlicKey-access-approve-api-rqst.cy.ts index f4917dcbe..a0818d6f5 100644 --- a/e2e/cypress/tests/02-client-credential-flow/11-jwt-publlicKey-access-approve-api-rqst.cy.ts +++ b/e2e/cypress/tests/02-client-credential-flow/11-jwt-publlicKey-access-approve-api-rqst.cy.ts @@ -18,13 +18,16 @@ describe('Access manager approves developer access request for JWT - Generated K beforeEach(() => { cy.preserveCookies() cy.fixture('access-manager').as('access-manager') + cy.fixture('apiowner').as('apiowner') // cy.visit(login.path) }) it('Access Manager logs in', () => { - cy.get('@access-manager').then(({ user, clientCredentials }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(clientCredentials.namespace) + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ clientCredentials }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(clientCredentials.namespace) + }) }) }) diff --git a/e2e/cypress/tests/03-manage-labels/02-approve-pending-rqst-for-labels.spec.cy.ts b/e2e/cypress/tests/03-manage-labels/02-approve-pending-rqst-for-labels.spec.cy.ts index 576bc21f6..acd3830b3 100644 --- a/e2e/cypress/tests/03-manage-labels/02-approve-pending-rqst-for-labels.spec.cy.ts +++ b/e2e/cypress/tests/03-manage-labels/02-approve-pending-rqst-for-labels.spec.cy.ts @@ -12,8 +12,6 @@ describe('Approve Pending Request Spec', () => { cy.visit('/') cy.deleteAllCookies() cy.reload() - cy.getServiceOrRouteID('services') - cy.getServiceOrRouteID('routes') }) beforeEach(() => { @@ -26,9 +24,11 @@ describe('Approve Pending Request Spec', () => { }) it('authenticates Mark (Access-Manager)', () => { - cy.get('@access-manager').then(({ user, namespace }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(namespace); + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ namespace }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(namespace); + }) }) }) diff --git a/e2e/cypress/tests/03-manage-labels/03-filter-labels.cy.ts b/e2e/cypress/tests/03-manage-labels/03-filter-labels.cy.ts index 15670cb68..d79910e41 100644 --- a/e2e/cypress/tests/03-manage-labels/03-filter-labels.cy.ts +++ b/e2e/cypress/tests/03-manage-labels/03-filter-labels.cy.ts @@ -12,8 +12,6 @@ describe('Filter Manage labels Spec', () => { cy.visit('/') cy.deleteAllCookies() cy.reload() - cy.getServiceOrRouteID('services') - cy.getServiceOrRouteID('routes') }) beforeEach(() => { @@ -27,9 +25,11 @@ describe('Filter Manage labels Spec', () => { it('authenticates Mark (Access-Manager)', () => { - cy.get('@access-manager').then(({ user, namespace }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(namespace); + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ namespace }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(namespace); + }) }) }) diff --git a/e2e/cypress/tests/03-manage-labels/04-manage-labels.cy.ts b/e2e/cypress/tests/03-manage-labels/04-manage-labels.cy.ts index eacbab194..e6bee8d2f 100644 --- a/e2e/cypress/tests/03-manage-labels/04-manage-labels.cy.ts +++ b/e2e/cypress/tests/03-manage-labels/04-manage-labels.cy.ts @@ -12,8 +12,6 @@ describe('Manage/Edit labels spec', () => { cy.visit('/') cy.deleteAllCookies() cy.reload() - cy.getServiceOrRouteID('services') - cy.getServiceOrRouteID('routes') }) beforeEach(() => { @@ -25,9 +23,11 @@ describe('Manage/Edit labels spec', () => { }) it('authenticates Mark (Access-Manager)', () => { - cy.get('@access-manager').then(({ user, namespace }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(namespace); + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ namespace }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(namespace); + }) }) }) @@ -57,5 +57,5 @@ describe('Manage/Edit labels spec', () => { cy.logout() cy.clearLocalStorage({ log: true }) cy.deleteAllCookies() -}) + }) }) \ No newline at end of file diff --git a/e2e/cypress/tests/03-manage-labels/05-link-consumers.ts b/e2e/cypress/tests/03-manage-labels/05-link-consumers.ts index 8bfb50601..97eea0365 100644 --- a/e2e/cypress/tests/03-manage-labels/05-link-consumers.ts +++ b/e2e/cypress/tests/03-manage-labels/05-link-consumers.ts @@ -13,8 +13,6 @@ describe('Link Consumers to Namespace', () => { cy.visit('/') cy.deleteAllCookies() cy.reload() - cy.getServiceOrRouteID('services') - cy.getServiceOrRouteID('routes') }) beforeEach(() => { @@ -27,9 +25,11 @@ describe('Link Consumers to Namespace', () => { }) it('authenticates Mark (Access-Manager)', () => { - cy.get('@access-manager').then(({ user, namespace }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(namespace); + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ namespace }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(namespace); + }) }) }) @@ -39,12 +39,9 @@ describe('Link Consumers to Namespace', () => { }) it('Get the consumer ID from the list', () => { - cy.getLastConsumerID().then((title)=>{ - consumerID = title - }) - // cy.wrap(consumers).its('inputValue').then(inputValue => { - // consumerID = inputValue.text() - // }) + cy.getLastConsumerID().then((title) => { + consumerID = title + }) }) it('Delete the consumer ID from the list', () => { @@ -61,7 +58,7 @@ describe('Link Consumers to Namespace', () => { }) it('Verify that the consumer is linked to the namespace', () => { - cy.getLastConsumerID().then((title)=>{ + cy.getLastConsumerID().then((title) => { expect(title).to.equal(consumerID) }) }) diff --git a/e2e/cypress/tests/04-gateway-services/01-gateway-service-details.cy.ts b/e2e/cypress/tests/04-gateway-services/01-gateway-service-details.cy.ts index 07401a29f..37134dcb8 100644 --- a/e2e/cypress/tests/04-gateway-services/01-gateway-service-details.cy.ts +++ b/e2e/cypress/tests/04-gateway-services/01-gateway-service-details.cy.ts @@ -6,11 +6,8 @@ import MyAccessPage from '../../pageObjects/myAccess' import NamespaceAccessPage from '../../pageObjects/namespaceAccess' describe('Verify Gateway Service details', () => { - const login = new LoginPage() - const apiDir = new ApiDirectoryPage() - const myAccessPage = new MyAccessPage() + const home = new HomePage() - const na = new NamespaceAccessPage() const gs = new GatewayServicePage() before(() => { @@ -52,7 +49,7 @@ describe('Verify Gateway Service details', () => { it('Verify the routes details ', () => { cy.get('@apiowner').then(({ product }: any) => { - gs.verifyRouteName(product.environment.config.serviceName, 'https://a-service-for-newplatform.api.gov.bc.ca/') + gs.verifyRouteName(product.environment.config.serviceName, 'https://'+product.environment.config.serviceName+'.api.gov.bc.ca/') }) }) @@ -61,7 +58,9 @@ describe('Verify Gateway Service details', () => { }) it('Verify the Tags details ', () => { - gs.verifyTagsName('ns.newplatform') + cy.get('@apiowner').then(({ namespace }: any) => { + gs.verifyTagsName('ns.'+namespace) + }) }) after(() => { diff --git a/e2e/cypress/tests/05-migrate-user/01-migrate-user-access.cy.ts b/e2e/cypress/tests/05-migrate-user/01-migrate-user-access.cy.ts index d8b566044..029ee9fd8 100644 --- a/e2e/cypress/tests/05-migrate-user/01-migrate-user-access.cy.ts +++ b/e2e/cypress/tests/05-migrate-user/01-migrate-user-access.cy.ts @@ -61,14 +61,17 @@ describe('Authernticate with old user to initiate migration', () => { beforeEach(() => { cy.preserveCookies() cy.fixture('usermigration').as('usermigration') + cy.fixture('apiowner').as('apiowner') // cy.visit(login.path) }) it('authenticates with old user', () => { - cy.get('@usermigration').then(({ oldUser, namespace }: any) => { - cy.login(oldUser.credentials.username, oldUser.credentials.password) - cy.log('Logged in!') - home.useNamespace(namespace) + cy.get('@usermigration').then(({ oldUser }: any) => { + cy.get('@apiowner').then(({ namespace }: any) => { + cy.login(oldUser.credentials.username, oldUser.credentials.password) + cy.log('Logged in!') + home.useNamespace(namespace) + }) }) }) @@ -95,20 +98,25 @@ describe('Verify that permission of old user is migrated to new user', () => { cy.preserveCookies() cy.fixture('usermigration').as('usermigration') cy.fixture('apiowner').as('apiowner') - // cy.visit(login.path) + cy.visit(login.path) }) it('authenticates with new user', () => { - cy.get('@usermigration').then(({ newUser, namespace }: any) => { + cy.get('@usermigration').then(({ newUser }: any) => { cy.login(newUser.credentials.username, newUser.credentials.password) cy.log('Logged in!') - // home.useNamespace(namespace) }) }) + // it('activates new namespace', () => { + // cy.get('@apiowner').then(({ namespace }: any) => { + // home.useNamespace(namespace) + // }) + // }) + it('Get the permission of the user', () => { cy.getUserSession().then(() => { - cy.get('@usermigration').then(({ namespace }: any) => { + cy.get('@apiowner').then(({ namespace }: any) => { home.useNamespace(namespace) cy.get('@login').then(function (xhr: any) { userScopes = xhr.response.body.user.scopes @@ -150,8 +158,8 @@ describe('Verify that old user is no longer able to sign in', () => { }) it('authenticates with old user', () => { - cy.get('@usermigration').then(({ oldUser}: any) => { - cy.login(oldUser.credentials.username, oldUser.credentials.password,true) + cy.get('@usermigration').then(({ oldUser }: any) => { + cy.login(oldUser.credentials.username, oldUser.credentials.password, true) }) }) diff --git a/e2e/cypress/tests/06-refresh-credential/02-client-credentials.cy.ts b/e2e/cypress/tests/06-refresh-credential/02-client-credentials.cy.ts index ca841ee5f..327508156 100644 --- a/e2e/cypress/tests/06-refresh-credential/02-client-credentials.cy.ts +++ b/e2e/cypress/tests/06-refresh-credential/02-client-credentials.cy.ts @@ -127,6 +127,10 @@ describe('Regenerate Credential for Client Credentials- Client ID/Secret', () => }) after(() => { + cy.get('@apiowner').then(({ product }: any) => { + cy.getServiceOrRouteID('services', product.environment.config.serviceName) + cy.getServiceOrRouteID('routes', product.environment.config.serviceName) + }) cy.logout() cy.clearLocalStorage({ log: true }) cy.deleteAllCookies() diff --git a/e2e/cypress/tests/07-manage-control/01-ip-restriction.cy.ts b/e2e/cypress/tests/07-manage-control/01-ip-restriction.cy.ts index 94d7b1c94..aed31e1d2 100644 --- a/e2e/cypress/tests/07-manage-control/01-ip-restriction.cy.ts +++ b/e2e/cypress/tests/07-manage-control/01-ip-restriction.cy.ts @@ -6,7 +6,7 @@ describe('Manage Control-IP Restriction Spec', () => { const login = new LoginPage() const home = new HomePage() const consumers = new ConsumersPage() - + before(() => { cy.visit('/') cy.deleteAllCookies() @@ -21,9 +21,11 @@ describe('Manage Control-IP Restriction Spec', () => { }) it('authenticates Mark (Access Manager)', () => { - cy.get('@access-manager').then(({ user, namespace }: any) => { - cy.login(user.credentials.username, user.credentials.password).then(() => { - home.useNamespace(namespace); + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ namespace }: any) => { + cy.login(user.credentials.username, user.credentials.password).then(() => { + home.useNamespace(namespace); + }) }) }) }) @@ -44,7 +46,7 @@ describe('Manage Control-IP Restriction Spec', () => { consumers.setAllowedIPAddress(ipRestriction.ipRange_inValid, 'Route') }) }) - + it('verify IP Restriction error when the API calls other than the allowed IP', () => { cy.get('@apiowner').then(({ product }: any) => { cy.makeKongRequest(product.environment.config.serviceName, 'GET').then((response) => { @@ -58,7 +60,7 @@ describe('Manage Control-IP Restriction Spec', () => { cy.get('@access-manager').then(() => { cy.visit(consumers.path); consumers.clickOnTheFirstConsumerID() - cy.get('@manage-control-config-setting').then(({ipRestriction} : any) => { + cy.get('@manage-control-config-setting').then(({ ipRestriction }: any) => { consumers.setAllowedIPAddress(ipRestriction.ipRange_inValid) }) }) @@ -77,7 +79,7 @@ describe('Manage Control-IP Restriction Spec', () => { cy.get('@access-manager').then(() => { cy.visit(consumers.path); consumers.clickOnTheFirstConsumerID() - cy.get('@manage-control-config-setting').then(({ipRestriction} : any) => { + cy.get('@manage-control-config-setting').then(({ ipRestriction }: any) => { consumers.setAllowedIPAddress(ipRestriction.ipRange_valid, "Route") }) }) @@ -95,7 +97,7 @@ describe('Manage Control-IP Restriction Spec', () => { cy.get('@access-manager').then(() => { cy.visit(consumers.path); consumers.clickOnTheFirstConsumerID() - cy.get('@manage-control-config-setting').then(({ipRestriction} : any) => { + cy.get('@manage-control-config-setting').then(({ ipRestriction }: any) => { consumers.setAllowedIPAddress(ipRestriction.ipRange_valid) }) }) @@ -151,7 +153,7 @@ describe('Manage Control -Apply IP Restriction to Global and Consumer at Service cy.get('@access-manager').then(({ user, namespace }: any) => { cy.visit(consumers.path); consumers.clickOnTheFirstConsumerID() - cy.get('@manage-control-config-setting').then(({ipRestriction} : any) => { + cy.get('@manage-control-config-setting').then(({ ipRestriction }: any) => { consumers.setAllowedIPAddress(ipRestriction.ipRange_inValid) }) }) @@ -186,7 +188,7 @@ describe('Manage Control -Apply IP Restriction to Global and Consumer at Route l consumers.filterConsumerByTypeAndValue('Products', product.name) }) }) - + it('set api ip-restriction to global service level', () => { cy.visit(consumers.path); consumers.clickOnTheFirstConsumerID() @@ -208,7 +210,7 @@ describe('Manage Control -Apply IP Restriction to Global and Consumer at Route l cy.get('@access-manager').then(({ user, namespace }: any) => { cy.visit(consumers.path); consumers.clickOnTheFirstConsumerID() - cy.get('@manage-control-config-setting').then(({ipRestriction} : any) => { + cy.get('@manage-control-config-setting').then(({ ipRestriction }: any) => { consumers.setAllowedIPAddress(ipRestriction.ipRange_inValid) }) }) diff --git a/e2e/cypress/tests/07-manage-control/02-rate-limiting.cy.ts b/e2e/cypress/tests/07-manage-control/02-rate-limiting.cy.ts index da7b5c1a4..7dd342b09 100644 --- a/e2e/cypress/tests/07-manage-control/02-rate-limiting.cy.ts +++ b/e2e/cypress/tests/07-manage-control/02-rate-limiting.cy.ts @@ -24,9 +24,11 @@ describe('Manage Control-Rate Limiting Spec for Service as Scope and Local Polic }) it('authenticates Mark (Access Manager)', () => { - cy.get('@access-manager').then(({ user, namespace }: any) => { - cy.login(user.credentials.username, user.credentials.password).then(() => { - home.useNamespace(namespace); + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ namespace }: any) => { + cy.login(user.credentials.username, user.credentials.password).then(() => { + home.useNamespace(namespace); + }) }) }) }) @@ -79,6 +81,7 @@ describe('Manage Control-Rate Limiting Spec for Route as Scope and Local Policy' cy.get('@manage-control-config-setting').then(({ rateLimiting }: any) => { cy.visit(consumers.path); consumers.clickOnTheFirstConsumerID() + consumers.clearRateLimitControl() consumers.setRateLimiting(rateLimiting.requestPerHour_Consumer, "Route") }) }) @@ -188,7 +191,7 @@ describe('Manage Control-Apply Rate limiting to Global and Consumer at Service l cy.get('@apiowner').then(({ product }: any) => { cy.makeKongRequest(product.environment.config.serviceName, 'GET').then((response) => { expect(response.status).to.be.equal(200) - expect(parseInt(response.headers["x-ratelimit-remaining-hour"])).to.be.within(16,18) + expect(parseInt(response.headers["x-ratelimit-remaining-hour"])).to.be.within(16, 18) }) }) }) diff --git a/e2e/cypress/tests/07-manage-control/03-kong-api-only-apply-rate-limiting.cy.ts b/e2e/cypress/tests/07-manage-control/03-kong-api-only-apply-rate-limiting.cy.ts index f3d0f283b..4c0b63f0d 100644 --- a/e2e/cypress/tests/07-manage-control/03-kong-api-only-apply-rate-limiting.cy.ts +++ b/e2e/cypress/tests/07-manage-control/03-kong-api-only-apply-rate-limiting.cy.ts @@ -64,6 +64,8 @@ describe('Apply Kong API key only plugin', () => { }) it('Set Consumer ID to key auth anonymous config', () => { + const arr_namespace = ['ns.' + nameSpace]; + cy.updatePropertiesOfPluginFile('service-plugin-key-auth-only.yml', 'tags', arr_namespace) cy.updatePropertiesOfPluginFile('service-plugin-key-auth-only.yml', 'config.anonymous', consumerID) }) @@ -80,9 +82,9 @@ describe('Apply Kong API key only plugin', () => { cy.get('@apiowner').then(({ namespace, product }: any) => { cy.updatePluginFile('service-plugin.yml', product.environment.config.serviceName, 'service-plugin-key-auth-only.yml') cy.publishApi('service-plugin.yml', namespace).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - }) + // cy.get('@publishAPIResponse').then((res: any) => { + // cy.log(JSON.stringify(res.body)) + // }) }) }) }) @@ -97,7 +99,7 @@ describe('Apply Kong API key only plugin', () => { }) it('Apply Rate limiting on free access', () => { - cy.updateKongPlugin('consumers', 'rateLimitingConsumer', 'consumers/'+consumerID+'/plugins').then((response) => { + cy.updateKongPlugin('consumers', 'rateLimitingConsumer', 'consumers/' + consumerID + '/plugins').then((response) => { expect(response.status).to.be.equal(201) }) }) @@ -115,7 +117,7 @@ describe('Check the API key for free access', () => { cy.get('@apiowner').then(async ({ product }: any) => { cy.fixture('state/store').then((creds: any) => { const key = creds.consumerKey - cy.makeKongRequest(product.environment.config.serviceName, 'GET','').then((response) => { + cy.makeKongRequest(product.environment.config.serviceName, 'GET', '').then((response) => { expect(response.status).to.be.equal(200) expect(parseInt(response.headers["x-ratelimit-remaining-hour"])).to.be.equal(99) }) @@ -185,8 +187,6 @@ describe('Approve Pending Request Spec', () => { cy.visit('/') cy.deleteAllCookies() cy.reload() - cy.getServiceOrRouteID('services') - cy.getServiceOrRouteID('routes') }) beforeEach(() => { @@ -200,9 +200,11 @@ describe('Approve Pending Request Spec', () => { }) it('authenticates Mark (Access-Manager)', () => { - cy.get('@access-manager').then(({ user, namespace }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(namespace); + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ namespace }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(namespace); + }) }) }) diff --git a/e2e/cypress/tests/08-client-role/02-add-roles-authorization-profile.ts b/e2e/cypress/tests/08-client-role/02-add-roles-authorization-profile.ts index 4a24b1262..b3094ced3 100644 --- a/e2e/cypress/tests/08-client-role/02-add-roles-authorization-profile.ts +++ b/e2e/cypress/tests/08-client-role/02-add-roles-authorization-profile.ts @@ -31,7 +31,7 @@ describe('Apply client roles to the Authorization Profile', () => { }) it('Select the namespace created for client credential ', () => { - cy.get('@credential-issuer').then(({ clientCredentials }: any) => { + cy.get('@apiowner').then(({ clientCredentials }: any) => { home.useNamespace(clientCredentials.namespace) }) }) diff --git a/e2e/cypress/tests/08-client-role/03-read-client-role.ts b/e2e/cypress/tests/08-client-role/03-read-client-role.ts index 04cb10b6c..44d50fd85 100644 --- a/e2e/cypress/tests/08-client-role/03-read-client-role.ts +++ b/e2e/cypress/tests/08-client-role/03-read-client-role.ts @@ -79,9 +79,11 @@ describe('Access manager apply "Read" role and approves developer access request }) it('Access Manager logs in', () => { - cy.get('@access-manager').then(({ user, clientCredentials }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(clientCredentials.namespace) + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ clientCredentials }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(clientCredentials.namespace) + }) }) }) @@ -99,7 +101,7 @@ describe('Access manager apply "Read" role and approves developer access request }) it('approves an access request', () => { - consumers.approvePendingRequest() + consumers.approvePendingRequest(true) }) after(() => { @@ -142,10 +144,10 @@ describe('Update Kong plugin and verify that only only GET method is allowed for it('applies authorization plugin to service published to Kong Gateway', () => { cy.get('@apiowner').then(({ clientCredentials }: any) => { cy.publishApi('cc-service-plugin.yml', clientCredentials.namespace, true).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - expect(res.body.message).to.contains("Sync successful") - }) + // cy.get('@publishAPIResponse').then((res: any) => { + // cy.log(JSON.stringify(res.body)) + // expect(res.body.message).to.contains("Sync successful") + // }) }) }) }) diff --git a/e2e/cypress/tests/08-client-role/04-write-client-role.ts b/e2e/cypress/tests/08-client-role/04-write-client-role.ts index edbfcfcd4..060933ec4 100644 --- a/e2e/cypress/tests/08-client-role/04-write-client-role.ts +++ b/e2e/cypress/tests/08-client-role/04-write-client-role.ts @@ -79,9 +79,11 @@ describe('Access manager apply "Write" role and approves developer access reques }) it('Access Manager logs in', () => { - cy.get('@access-manager').then(({ user, clientCredentials }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(clientCredentials.namespace) + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ clientCredentials }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(clientCredentials.namespace) + }) }) }) @@ -133,10 +135,10 @@ describe('Update Kong plugin and verify that only only PUT and POST methods are it('applies authorization plugin to service published to Kong Gateway', () => { cy.get('@apiowner').then(({ clientCredentials }: any) => { cy.publishApi('cc-service-plugin.yml', clientCredentials.namespace, true).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - expect(res.body.message).to.contains("Sync successful") - }) + // cy.get('@publishAPIResponse').then((res: any) => { + // cy.log(JSON.stringify(res.body)) + // expect(res.body.message).to.contains("Sync successful") + // }) }) }) }) diff --git a/e2e/cypress/tests/08-client-role/05-check-without-role.ts b/e2e/cypress/tests/08-client-role/05-check-without-role.ts index 0a2d04402..e159768ea 100644 --- a/e2e/cypress/tests/08-client-role/05-check-without-role.ts +++ b/e2e/cypress/tests/08-client-role/05-check-without-role.ts @@ -58,11 +58,12 @@ describe('Reset Authorization profile to default (without any role)', () => { it('applies authorization plugin to service published to Kong Gateway', () => { cy.get('@apiowner').then(({ clientCredentials }: any) => { + cy.replaceWordInJsonObject('ccplatform', nameSpace, 'cc-service-plugin.yml') cy.publishApi('cc-service-plugin.yml', clientCredentials.namespace,true).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - expect(res.body.message).to.contains("Sync successful") - }) + // cy.get('@publishAPIResponse').then((res: any) => { + // cy.log(JSON.stringify(res.body)) + // expect(res.body.message).to.contains("Sync successful") + // }) }) }) }) diff --git a/e2e/cypress/tests/09-update-product-env/01-client-credential-to-kong-acl-api.cy.ts b/e2e/cypress/tests/09-update-product-env/01-client-credential-to-kong-acl-api.cy.ts index 0b8e547ba..3d42867b8 100644 --- a/e2e/cypress/tests/09-update-product-env/01-client-credential-to-kong-acl-api.cy.ts +++ b/e2e/cypress/tests/09-update-product-env/01-client-credential-to-kong-acl-api.cy.ts @@ -72,10 +72,10 @@ describe('Change Authorization profile', () => { it('applies authorization plugin to service published to Kong Gateway', () => { cy.get('@apiowner').then(({ clientCredentials }: any) => { cy.publishApi('cc-service-plugin.yml', clientCredentials.namespace,true).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - expect(res.body.message).to.contains("Sync successful") - }) + // cy.get('@publishAPIResponse').then((res: any) => { + // cy.log(JSON.stringify(res.body)) + // expect(res.body.message).to.contains("Sync successful") + // }) }) }) }) @@ -105,7 +105,7 @@ describe('Change Authorization profile', () => { }) }) }) - + after(() => { cy.logout() cy.clearLocalStorage({ log: true }) @@ -185,9 +185,11 @@ describe('Access manager approves developer access request for Kong API ACL auth }) it('Access Manager logs in', () => { - cy.get('@access-manager').then(({ user, clientCredentials }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(clientCredentials.namespace) + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ clientCredentials }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(clientCredentials.namespace) + }) }) }) @@ -206,7 +208,7 @@ describe('Access manager approves developer access request for Kong API ACL auth cy.readFile('cypress/fixtures/state/store.json').then((store_cred) => { cy.get('@apiowner').then(({ clientCredentials }: any) => { let product = clientCredentials.clientIdSecret_authProfile.product - cy.makeKongRequest(product.environment.config.serviceName, 'GET',store_cred.apikey).then((response) => { + cy.makeKongRequest(product.environment.config.serviceName, 'GET', store_cred.apikey).then((response) => { cy.log(response) expect(response.status).to.be.equal(200) }) diff --git a/e2e/cypress/tests/09-update-product-env/02-kong-acl-api-to-client-credential.cy.ts b/e2e/cypress/tests/09-update-product-env/02-kong-acl-api-to-client-credential.cy.ts index 64e5684f4..dd50eed3e 100644 --- a/e2e/cypress/tests/09-update-product-env/02-kong-acl-api-to-client-credential.cy.ts +++ b/e2e/cypress/tests/09-update-product-env/02-kong-acl-api-to-client-credential.cy.ts @@ -62,7 +62,7 @@ describe('Change Authorization profile from Kong ACL-API to Client Credential', it('Deactivate the service for Test environment', () => { cy.visit(pd.path) cy.get('@apiowner').then(({ product }: any) => { - pd.deactivateService(product.name, product.test_environment.name,product.test_environment.config) + pd.deactivateService(product.name, product.test_environment.name, product.test_environment.config) cy.wait(3000) }) }) @@ -77,27 +77,25 @@ describe('Change Authorization profile from Kong ACL-API to Client Credential', prod.environment.config.authIssuer = authProfile.name prod.environment.config.authIssuerEnv = authProfile.environmentConfig.environment pd.editProductEnvironmentConfig(prod.environment.config) - pd.generateKongPluginConfigForAuthScope(product.name, product.test_environment.name, 'service-plugin.yml',product.test_environment.config.serviceName) + pd.generateKongPluginConfigForAuthScope(product.name, product.test_environment.name, 'service-plugin.yml', product.test_environment.config.serviceName) // pd.generateKongPluginConfig(product.name, product.test_environment.name,'service-test.yml') }) }) }) it('applies authorization plugin to service published to Kong Gateway', () => { - cy.get('@apiowner').then(({ namespace }: any) => { - cy.publishApi('service-plugin.yml', nameSpace).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - expect(res.body.message).to.contains("Sync successful") - }) - }) + cy.publishApi('service-plugin.yml', nameSpace).then(() => { + // cy.get('@publishAPIResponse').then((res: any) => { + // cy.log(JSON.stringify(res.body)) + // expect(res.body.message).to.contains("Sync successful") + // }) }) }) it('activate the service for Test environment', () => { cy.visit(pd.path) cy.get('@apiowner').then(({ product }: any) => { - pd.activateService(product.name, product.test_environment.name,product.test_environment.config) + pd.activateService(product.name, product.test_environment.name, product.test_environment.config) cy.wait(3000) }) }) @@ -193,9 +191,11 @@ describe('Access manager approves developer access request for Client ID/Secret }) it('Access Manager logs in', () => { - cy.get('@access-manager').then(({ user, namespace }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(namespace) + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ namespace }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(namespace) + }) }) }) @@ -218,25 +218,30 @@ describe('Access manager approves developer access request for Client ID/Secret }) describe('Make an API request using Client ID, Secret, and Access Token', () => { + beforeEach(() => { + cy.fixture('apiowner').as('apiowner') + }) it('Get access token using client ID and secret; make API request', () => { cy.readFile('cypress/fixtures/state/store.json').then((store_res) => { - - let cc = JSON.parse(store_res.clientidsecret) - // let cc = JSON.parse(Cypress.env('clientidsecret')) - cy.log('cc-->' + cc.clientSecret) - cy.getAccessToken(cc.clientId, cc.clientSecret).then(() => { - cy.get('@accessTokenResponse').then((token_res: any) => { - let token = token_res.body.access_token - cy.request({ - url: Cypress.env('KONG_URL'), - headers: { - Host: 'a-service-for-newplatform-test.api.gov.bc.ca', - }, - auth: { - bearer: token, - }, - }).then((res) => { - expect(res.status).to.eq(200) + cy.get('@apiowner').then(({ product }: any) => { + let host = product.test_environment.config.serviceName+'.api.gov.bc.ca' + let cc = JSON.parse(store_res.clientidsecret) + // let cc = JSON.parse(Cypress.env('clientidsecret')) + cy.log('cc-->' + cc.clientSecret) + cy.getAccessToken(cc.clientId, cc.clientSecret).then(() => { + cy.get('@accessTokenResponse').then((token_res: any) => { + let token = token_res.body.access_token + cy.request({ + url: Cypress.env('KONG_URL'), + headers: { + Host: host, + }, + auth: { + bearer: token, + }, + }).then((res) => { + expect(res.status).to.eq(200) + }) }) }) }) diff --git a/e2e/cypress/tests/09-update-product-env/03-apply-multiple-services.cy.ts b/e2e/cypress/tests/09-update-product-env/03-apply-multiple-services.cy.ts index eff4e4eaa..6de9001f0 100644 --- a/e2e/cypress/tests/09-update-product-env/03-apply-multiple-services.cy.ts +++ b/e2e/cypress/tests/09-update-product-env/03-apply-multiple-services.cy.ts @@ -6,7 +6,8 @@ import HomePage from '../../pageObjects/home' import LoginPage from '../../pageObjects/login' import MyAccessPage from '../../pageObjects/myAccess' import Products from '../../pageObjects/products' - +let host_test: string +let host: string describe('Apply multiple services to the product environment', () => { const login = new LoginPage() @@ -60,7 +61,7 @@ describe('Apply multiple services to the product environment', () => { let authProfile = clientCredentials.clientIdSecret_KongKeyToCC.authProfile prod.environment.config.authIssuer = authProfile.name prod.environment.config.authIssuerEnv = authProfile.environmentConfig.environment - pd.editProductEnvironmentConfig(prod.environment.config, false ,false) + pd.editProductEnvironmentConfig(prod.environment.config, false, false) pd.generateKongPluginConfigForAuthScope(product.name, product.test_environment.name, 'service-plugin.yml', product.environment.config.serviceName) // pd.generateKongPluginConfig(product.name, product.test_environment.name,'service-test.yml') }) @@ -70,10 +71,10 @@ describe('Apply multiple services to the product environment', () => { it('applies authorization plugin to service published to Kong Gateway', () => { cy.get('@apiowner').then(({ namespace }: any) => { cy.publishApi('service-plugin.yml', namespace).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - expect(res.body.message).to.contains("Sync successful") - }) + // cy.get('@publishAPIResponse').then((res: any) => { + // cy.log(JSON.stringify(res.body)) + // expect(res.body.message).to.contains("Sync successful") + // }) }) }) }) @@ -96,45 +97,50 @@ describe('Apply multiple services to the product environment', () => { describe('Verify that the service is accessible using existing Client ID, Secret, and Access Token', () => { let token: string + beforeEach(() => { + cy.fixture('apiowner').as('apiowner') + }) it('Get access token using client ID and secret; make API request for test', () => { cy.readFile('cypress/fixtures/state/store.json').then((store_res) => { - - let cc = JSON.parse(store_res.clientidsecret) - // let cc = JSON.parse(Cypress.env('clientidsecret')) - cy.log('cc-->' + cc.clientSecret) - cy.getAccessToken(cc.clientId, cc.clientSecret).then(() => { - cy.get('@accessTokenResponse').then((token_res: any) => { - token = token_res.body.access_token - cy.request({ - url: Cypress.env('KONG_URL'), - headers: { - Host: 'a-service-for-newplatform-test.api.gov.bc.ca', - }, - auth: { - bearer: token, - }, - }).then((res) => { - expect(res.status).to.eq(200) + cy.get('@apiowner').then(({ product }: any) => { + host_test = product.test_environment.config.serviceName + '.api.gov.bc.ca' + host = product.environment.config.serviceName + '.api.gov.bc.ca' + let cc = JSON.parse(store_res.clientidsecret) + // let cc = JSON.parse(Cypress.env('clientidsecret')) + cy.log('cc-->' + cc.clientSecret) + cy.getAccessToken(cc.clientId, cc.clientSecret).then(() => { + cy.get('@accessTokenResponse').then((token_res: any) => { + token = token_res.body.access_token + cy.request({ + url: Cypress.env('KONG_URL'), + headers: { + Host: host_test, + }, + auth: { + bearer: token, + }, + }).then((res) => { + expect(res.status).to.eq(200) + }) }) }) }) }) - }) - it('Get access token using client ID and secret; make API request for Dev', () => { - cy.request({ - url: Cypress.env('KONG_URL'), - headers: { - Host: 'a-service-for-newplatform.api.gov.bc.ca', - }, - auth: { - bearer: token, - }, - }).then((res) => { - expect(res.status).to.eq(200) + it('Get access token using client ID and secret; make API request for Dev', () => { + cy.request({ + url: Cypress.env('KONG_URL'), + headers: { + Host: host, + }, + auth: { + bearer: token, + }, + }).then((res) => { + expect(res.status).to.eq(200) + }) }) }) - }) @@ -212,9 +218,11 @@ describe('Access manager approves developer access request for Client ID/Secret }) it('Access Manager logs in', () => { - cy.get('@access-manager').then(({ user, namespace }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(namespace) + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ namespace }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(namespace) + }) }) }) @@ -250,7 +258,7 @@ describe('Verify that the service is accessible using new Client ID, Secret, and cy.request({ url: Cypress.env('KONG_URL'), headers: { - Host: 'a-service-for-newplatform-test.api.gov.bc.ca', + Host: host_test, }, auth: { bearer: token, @@ -267,7 +275,7 @@ describe('Verify that the service is accessible using new Client ID, Secret, and cy.request({ url: Cypress.env('KONG_URL'), headers: { - Host: 'a-service-for-newplatform.api.gov.bc.ca', + Host: host, }, auth: { bearer: token, diff --git a/e2e/cypress/tests/09-update-product-env/05-keycloak-shared-IDP-config.cy.ts b/e2e/cypress/tests/09-update-product-env/05-keycloak-shared-IDP-config.cy.ts index 48e92d978..7b38cefae 100644 --- a/e2e/cypress/tests/09-update-product-env/05-keycloak-shared-IDP-config.cy.ts +++ b/e2e/cypress/tests/09-update-product-env/05-keycloak-shared-IDP-config.cy.ts @@ -42,7 +42,7 @@ describe('Apply Shared IDP config at Keycloak user group', () => { }) it('Edit the namespace from the tree view', () => { - cy.get('@admin').then(({ namespace }: any) => { + cy.get('@apiowner').then(({ namespace }: any) => { cy.contains(namespace).click() userGroups.clickOnEditButton() }) diff --git a/e2e/cypress/tests/09-update-product-env/07-kong-public-auth.ts b/e2e/cypress/tests/09-update-product-env/07-kong-public-auth.ts index 12a48b816..39115b439 100644 --- a/e2e/cypress/tests/09-update-product-env/07-kong-public-auth.ts +++ b/e2e/cypress/tests/09-update-product-env/07-kong-public-auth.ts @@ -70,11 +70,8 @@ describe('Verify for Kong Public Auth', () => { it('applies authorization plugin to service published to Kong Gateway', () => { cy.get('@apiowner').then(({ clientCredentials }: any) => { - cy.publishApi('cc-service.yml', clientCredentials.namespace,true).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - expect(res.body.message).to.contains("Sync successful") - }) + cy.publishApi('cc-service-gwa.yml', clientCredentials.namespace,true).then((response:any) => { + expect(response.stdout).to.contain('Sync successful'); }) }) }) diff --git a/e2e/cypress/tests/10-clear-resources/01-create-api.cy.ts b/e2e/cypress/tests/10-clear-resources/01-create-api.cy.ts index d531bc523..9ffeb309f 100644 --- a/e2e/cypress/tests/10-clear-resources/01-create-api.cy.ts +++ b/e2e/cypress/tests/10-clear-resources/01-create-api.cy.ts @@ -8,8 +8,8 @@ describe('Create API Spec for Delete Resources', () => { const home = new HomePage() const sa = new ServiceAccountsPage() const pd = new Products() - var nameSpace: string - let userSession: string + let userSession: any + let namespace: string before(() => { cy.visit('/') @@ -22,25 +22,37 @@ describe('Create API Spec for Delete Resources', () => { cy.preserveCookies() cy.fixture('apiowner').as('apiowner') cy.fixture('api').as('api') - // cy.visit(login.path) + cy.visit(login.path) }) - it('authenticates Janis (api owner)', () => { - cy.get('@apiowner').then(({ user }: any) => { - cy.login(user.credentials.username, user.credentials.password) + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace, false).then((value) => { + userSession = value + }) }) }) - it('creates and activates new namespace', () => { - cy.getUserSession().then(() => { - cy.get('@apiowner').then(({ deleteResources }: any) => { - nameSpace = deleteResources.namespace - home.createNamespace(deleteResources.namespace) - cy.get('@login').then(function (xhr: any) { - userSession = xhr.response.headers['x-auth-request-access-token'] - }) - }) - }) + it('Set token with gwa config command', () => { + cy.exec('gwa config set --token ' + userSession, { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('create namespace using gwa cli command', () => { + var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, ""); + cy.exec('gwa namespace create --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + assert.isNotNaN(response.stdout) + namespace = response.stdout + cy.replaceWordInJsonObject('ns.deleteplatform', 'ns.' + namespace, 'service-clear-resources-gwa.yml') + cy.updateJsonValue('apiowner.json', 'deleteResources.namespace', namespace) + // cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace) + cy.executeCliCommand("gwa config set --namespace " + namespace) + }); + }) + + it('activates new namespace', () => { + home.useNamespace(namespace) }) it('creates a new service account', () => { @@ -53,13 +65,12 @@ describe('Create API Spec for Delete Resources', () => { it('publishes a new API to Kong Gateway', () => { cy.get('@apiowner').then(({ deleteResources }: any) => { - cy.publishApi('service-clear-resources.yml', deleteResources.namespace).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - }) + cy.publishApi('service-clear-resources-gwa.yml', namespace).then((response: any) => { + expect(response.stdout).to.contain('Sync successful'); }) }) }) + it('creates as new product in the directory', () => { cy.visit(pd.path) cy.get('@apiowner').then(({ deleteResources }: any) => { @@ -71,7 +82,7 @@ describe('Create API Spec for Delete Resources', () => { cy.get('@api').then(({ organization }: any) => { cy.setHeaders(organization.headers) cy.setAuthorizationToken(userSession) - cy.makeAPIRequest(organization.endPoint + '/' + organization.orgName + '/' + organization.orgExpectedList.name + '/namespaces/' + nameSpace, 'PUT').then((response) => { + cy.makeAPIRequest(organization.endPoint + '/' + organization.orgName + '/' + organization.orgExpectedList.name + '/namespaces/' + namespace, 'PUT').then((response) => { expect(response.status).to.be.equal(200) }) }) @@ -84,23 +95,22 @@ describe('Create API Spec for Delete Resources', () => { pd.updateDatasetNameToCatelogue(deleteResources.product.name, deleteResources.product.environment.name) }) }) - + it('publish product to directory', () => { cy.visit(sa.path) cy.visit(pd.path) cy.get('@apiowner').then(({ deleteResources }: any) => { pd.editProductEnvironment(deleteResources.product.name, deleteResources.product.environment.name) pd.editProductEnvironmentConfig(deleteResources.product.environment.config) - pd.generateKongPluginConfig(deleteResources.product.name, deleteResources.product.environment.name,'service-clear-resources.yml') + pd.generateKongPluginConfig(deleteResources.product.name, deleteResources.product.environment.name, 'service-clear-resources.yml') }) }) it('applies authorization plugin to service published to Kong Gateway', () => { cy.get('@apiowner').then(({ deleteResources }: any) => { - cy.publishApi('service-clear-resources-plugin.yml', deleteResources.namespace).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - }) + cy.replaceWordInJsonObject('ns.deleteplatform', 'ns.' + namespace, 'service-clear-resources-plugin.yml') + cy.publishApi('service-clear-resources-plugin.yml', namespace).then((response: any) => { + expect(response.stdout).to.contain('Sync successful'); }) }) }) @@ -108,14 +118,14 @@ describe('Create API Spec for Delete Resources', () => { it('activate the service for Dev environment', () => { cy.visit(pd.path) cy.get('@apiowner').then(({ deleteResources }: any) => { - pd.activateService(deleteResources.product.name, deleteResources.product.environment.name,deleteResources.product.environment.config) + pd.activateService(deleteResources.product.name, deleteResources.product.environment.name, deleteResources.product.environment.config) cy.wait(3000) }) }) after(() => { cy.logout() - cy.clearLocalStorage({log:true}) + cy.clearLocalStorage({ log: true }) cy.deleteAllCookies() }) }) diff --git a/e2e/cypress/tests/11-activity-feed/01-activity-feed.cy.ts b/e2e/cypress/tests/11-activity-feed/01-activity-feed.cy.ts index 83c376ebb..58bbff630 100644 --- a/e2e/cypress/tests/11-activity-feed/01-activity-feed.cy.ts +++ b/e2e/cypress/tests/11-activity-feed/01-activity-feed.cy.ts @@ -106,26 +106,33 @@ describe('Verify the Activity filter for users', () => { // cy.visit(login.path) }) + it('activates new namespace', () => { + cy.get('@apiowner').then(({ namespace }: any) => { + home.useNamespace(namespace) + }) + }) + + it('Navigate to activity page', () => { cy.visit(activity.path) }) it('Verify Activity filter for "Janis Smith" user', () => { - activity.checkActivityFilter("User","Janis Smith", response) + activity.checkActivityFilter("User", "Janis Smith", response) }) it('Verify Activity filter for "Harley Jones" user', () => { - activity.checkActivityFilter("User","Harley Jones", response) + activity.checkActivityFilter("User", "Harley Jones", response) }) it('Verify Activity filter for "Mark F Mark L" user', () => { - activity.checkActivityFilter("User","Mark F Mark L", response) + activity.checkActivityFilter("User", "Mark F Mark L", response) }) it('Verify Activities filter for consumer', () => { cy.readFile('cypress/fixtures/state/regen.json').then((store) => { let consumerID = store.consumernumber - activity.checkActivityFilter("Consumer",consumerID, response) + activity.checkActivityFilter("Consumer", consumerID, response) }) }) }) \ No newline at end of file diff --git a/e2e/cypress/tests/11-activity-feed/02-activity-feed-failure.cy.ts b/e2e/cypress/tests/11-activity-feed/02-activity-feed-failure.cy.ts index a7c69dc4e..d1535a836 100644 --- a/e2e/cypress/tests/11-activity-feed/02-activity-feed-failure.cy.ts +++ b/e2e/cypress/tests/11-activity-feed/02-activity-feed-failure.cy.ts @@ -112,6 +112,10 @@ describe('Create API, Product, and Authorization Profiles; Apply Auth Profiles t cy.visit(activity.path) }) + it('Load all the records by click on "Load More" button', () => { + activity.loadMoreRecords() + }) + it('Verify Activity filter foe all the listed activities', () => { activity.checkActivityFilter("User", "", response) }) diff --git a/e2e/cypress/tests/12-access-permission/01-create-api.cy.ts b/e2e/cypress/tests/12-access-permission/01-create-api.cy.ts index ed7f07ab5..f30f59aa4 100644 --- a/e2e/cypress/tests/12-access-permission/01-create-api.cy.ts +++ b/e2e/cypress/tests/12-access-permission/01-create-api.cy.ts @@ -8,8 +8,8 @@ describe('Create API Spec', () => { const home = new HomePage() const sa = new ServiceAccountsPage() const pd = new Products() - var nameSpace: string - let userSession: string + let userSession: any + let namespace: string before(() => { cy.visit('/') @@ -25,22 +25,34 @@ describe('Create API Spec', () => { cy.visit(login.path) }) - it('authenticates Janis (api owner)', () => { - cy.get('@apiowner').then(({ user }: any) => { - cy.login(user.credentials.username, user.credentials.password) + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace, false).then((value) => { + userSession = value + }) }) }) - it('creates and activates new namespace', () => { - cy.getUserSession().then(() => { - cy.get('@apiowner').then(({ checkPermission }: any) => { - nameSpace = checkPermission.namespace - home.createNamespace(checkPermission.namespace) - cy.get('@login').then(function (xhr: any) { - userSession = xhr.response.headers['x-auth-request-access-token'] - }) - }) - }) + it('Set token with gwa config command', () => { + cy.exec('gwa config set --token ' + userSession, { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('create namespace using gwa cli command', () => { + var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, ""); + cy.exec('gwa namespace create --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + assert.isNotNaN(response.stdout) + namespace = response.stdout + cy.replaceWordInJsonObject('ns.permission', 'ns.' + namespace, 'service-permission-gwa.yml') + cy.updateJsonValue('apiowner.json', 'checkPermission.namespace', namespace) + // cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace) + cy.executeCliCommand("gwa config set --namespace " + namespace) + }); + }) + + it('activates new namespace', () => { + home.useNamespace(namespace) }) it('creates a new service account', () => { @@ -52,12 +64,8 @@ describe('Create API Spec', () => { }) it('publishes a new API to Kong Gateway', () => { - cy.get('@apiowner').then(({ checkPermission }: any) => { - cy.publishApi('service-permission.yml', checkPermission.namespace).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - }) - }) + cy.publishApi('service-permission-gwa.yml', namespace).then((response: any) => { + expect(response.stdout).to.contain('Sync successful'); }) }) @@ -72,7 +80,7 @@ describe('Create API Spec', () => { cy.get('@api').then(({ organization }: any) => { cy.setHeaders(organization.headers) cy.setAuthorizationToken(userSession) - cy.makeAPIRequest(organization.endPoint + '/' + organization.orgName + '/' + organization.orgExpectedList.name + '/namespaces/' + nameSpace, 'PUT').then((response) => { + cy.makeAPIRequest(organization.endPoint + '/' + organization.orgName + '/' + organization.orgExpectedList.name + '/namespaces/' + namespace, 'PUT').then((response) => { expect(response.status).to.be.equal(200) }) }) @@ -84,28 +92,27 @@ describe('Create API Spec', () => { pd.updateDatasetNameToCatelogue(checkPermission.product.name, checkPermission.product.environment.name) }) }) - + it('publish product to directory', () => { cy.visit(pd.path) cy.get('@apiowner').then(({ checkPermission }: any) => { pd.editProductEnvironment(checkPermission.product.name, checkPermission.product.environment.name) pd.editProductEnvironmentConfig(checkPermission.product.environment.config) - pd.generateKongPluginConfig(checkPermission.product.name, checkPermission.product.environment.name,'service-permission.yml') + pd.generateKongPluginConfig(checkPermission.product.name, checkPermission.product.environment.name, 'service-permission.yml') }) }) it('applies authorization plugin to service published to Kong Gateway', () => { - cy.get('@apiowner').then(({ checkPermission }: any) => { - cy.publishApi('service-permission.yml', checkPermission.namespace).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - }) - }) + cy.replaceWordInJsonObject('ns.permission', 'ns.' + namespace, 'service-permission-plugin.yml') + cy.replaceWordInJsonObject('ns.permission', 'ns.' + namespace, 'service-permission.yml') + cy.publishApi('service-permission-plugin.yml', namespace).then((res: any) => { + expect(res.stdout).to.contain('Sync successful'); }) }) after(() => { cy.logout() - cy.clearLocalStorage({log:true}) + cy.clearLocalStorage({ log: true }) cy.deleteAllCookies() }) }) diff --git a/e2e/cypress/tests/12-access-permission/04-access-manager.cy.ts b/e2e/cypress/tests/12-access-permission/04-access-manager.cy.ts index cb8a1166e..47a0a6668 100644 --- a/e2e/cypress/tests/12-access-permission/04-access-manager.cy.ts +++ b/e2e/cypress/tests/12-access-permission/04-access-manager.cy.ts @@ -51,7 +51,7 @@ describe('Verify that Mark is able to view the pending request', () => { const consumers = new ConsumersPage() const mp = new MyProfilePage() const na = new NamespaceAccessPage() - + before(() => { cy.visit('/') @@ -62,24 +62,28 @@ describe('Verify that Mark is able to view the pending request', () => { beforeEach(() => { cy.preserveCookies() cy.fixture('access-manager').as('access-manager') + cy.fixture('apiowner').as('apiowner') }) it('Authenticates Mark (Access-Manager)', () => { - cy.get('@access-manager').then(({ user, checkPermission }: any) => { - cy.visit(login.path) - cy.login(user.credentials.username, user.credentials.password) - cy.log('Logged in!') - home.useNamespace(checkPermission.namespace) - cy.visit(mp.path) + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({checkPermission}: any) => { + cy.visit(login.path) + cy.login(user.credentials.username, user.credentials.password) + cy.log('Logged in!') + debugger + home.useNamespace(checkPermission.namespace) + cy.visit(mp.path) + }) }) }) - it('Navigate to Consumer Page to see the Approve Request option', ()=> { + it('Navigate to Consumer Page to see the Approve Request option', () => { cy.visit(consumers.path) }) - it('Verify that the option to approve request is displayed', ()=> { - consumers.isApproveAccessEnabled(true) + it('Verify that the option to approve request is displayed', () => { + consumers.isApproveAccessEnabled(true) }) after(() => { diff --git a/e2e/cypress/tests/12-access-permission/05-namespace-manage.cy.ts b/e2e/cypress/tests/12-access-permission/05-namespace-manage.cy.ts index 6453ed1ed..cb489c8e8 100644 --- a/e2e/cypress/tests/12-access-permission/05-namespace-manage.cy.ts +++ b/e2e/cypress/tests/12-access-permission/05-namespace-manage.cy.ts @@ -72,12 +72,14 @@ describe('Verify that Wendy is able to see all the options for the Namespace', ( }) it('Authenticates Wendy (Credential-Issuer)', () => { - cy.get('@credential-issuer').then(({ user, checkPermission }: any) => { - cy.visit(login.path) - cy.login(user.credentials.username, user.credentials.password) - cy.log('Logged in!') - home.useNamespace(checkPermission.namespace) - cy.visit(mp.path) + cy.get('@credential-issuer').then(({ user }: any) => { + cy.get('@apiowner').then(({ checkPermission }: any) => { + cy.visit(login.path) + cy.login(user.credentials.username, user.credentials.password) + cy.log('Logged in!') + home.useNamespace(checkPermission.namespace) + cy.visit(mp.path) + }) }) }) diff --git a/e2e/cypress/tests/12-access-permission/06-credential-issuer.cy.ts b/e2e/cypress/tests/12-access-permission/06-credential-issuer.cy.ts index aae608930..24efcdd65 100644 --- a/e2e/cypress/tests/12-access-permission/06-credential-issuer.cy.ts +++ b/e2e/cypress/tests/12-access-permission/06-credential-issuer.cy.ts @@ -66,15 +66,18 @@ describe('Verify that Wendy is able to generate authorization profile', () => { beforeEach(() => { cy.preserveCookies() cy.fixture('credential-issuer').as('credential-issuer') + cy.fixture('apiowner').as('apiowner') }) it('Authenticates Wendy (Credential-Issuer)', () => { - cy.get('@credential-issuer').then(({ user, checkPermission }: any) => { - cy.visit(login.path) - cy.login(user.credentials.username, user.credentials.password) - cy.log('Logged in!') - home.useNamespace(checkPermission.namespace) - cy.visit(mp.path) + cy.get('@credential-issuer').then(({ user }: any) => { + cy.get('@apiowner').then(({ checkPermission }: any) => { + cy.visit(login.path) + cy.login(user.credentials.username, user.credentials.password) + cy.log('Logged in!') + home.useNamespace(checkPermission.namespace) + cy.visit(mp.path) + }) }) }) diff --git a/e2e/cypress/tests/12-access-permission/07-namespace-view.cy.ts b/e2e/cypress/tests/12-access-permission/07-namespace-view.cy.ts index 1155bd1ab..f97827918 100644 --- a/e2e/cypress/tests/12-access-permission/07-namespace-view.cy.ts +++ b/e2e/cypress/tests/12-access-permission/07-namespace-view.cy.ts @@ -65,15 +65,18 @@ describe('Verify that Mark is unable to create service account', () => { cy.preserveCookies() cy.fixture('credential-issuer').as('credential-issuer') cy.fixture('access-manager').as('access-manager') + cy.fixture('apiowner').as('apiowner') }) it('authenticates Mark', () => { - cy.get('@access-manager').then(({ user, checkPermission }: any) => { - cy.visit(login.path) - cy.login(user.credentials.username, user.credentials.password) - cy.log('Logged in!') - home.useNamespace(checkPermission.namespace) - cy.visit(mp.path) + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ checkPermission }: any) => { + cy.visit(login.path) + cy.login(user.credentials.username, user.credentials.password) + cy.log('Logged in!') + home.useNamespace(checkPermission.namespace) + cy.visit(mp.path) + }) }) }) diff --git a/e2e/cypress/tests/12-access-permission/08-gateway-config.cy.ts b/e2e/cypress/tests/12-access-permission/08-gateway-config.cy.ts index 7f41fefd0..c10b06cb7 100644 --- a/e2e/cypress/tests/12-access-permission/08-gateway-config.cy.ts +++ b/e2e/cypress/tests/12-access-permission/08-gateway-config.cy.ts @@ -68,25 +68,25 @@ describe('Verify that Wendy is able to generate authorization profile', () => { beforeEach(() => { cy.preserveCookies() cy.fixture('credential-issuer').as('credential-issuer') + cy.fixture('apiowner').as('apiowner') }) it('Authenticates Wendy (Credential-Issuer)', () => { - cy.get('@credential-issuer').then(({ user, checkPermission }: any) => { - cy.visit(login.path) - cy.login(user.credentials.username, user.credentials.password) - cy.log('Logged in!') - home.useNamespace(checkPermission.namespace) - cy.visit(mp.path) + cy.get('@credential-issuer').then(({ user }: any) => { + cy.get('@apiowner').then(({ checkPermission }: any) => { + cy.visit(login.path) + cy.login(user.credentials.username, user.credentials.password) + cy.log('Logged in!') + home.useNamespace(checkPermission.namespace) + cy.visit(mp.path) + }) }) }) it('Verify that GWA API allows user to publish the API to Kong gateway', () => { - cy.get('@credential-issuer').then(({ checkPermission }: any) => { - cy.publishApi('service-permission.yml', checkPermission.namespace).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - expect(JSON.stringify(res.body.message)).to.be.contain('Sync successful.') - expect(res.statusCode).to.be.equal(200) - }) + cy.get('@apiowner').then(({ checkPermission }: any) => { + cy.publishApi('service-permission.yml', checkPermission.namespace).then((response: any) => { + expect(response.stdout).to.contain('Sync successful'); }) }) }) diff --git a/e2e/cypress/tests/14-namespace-preview-mode/01-create-api.cy.ts b/e2e/cypress/tests/13-namespace-preview-mode/01-create-api.cy.ts similarity index 54% rename from e2e/cypress/tests/14-namespace-preview-mode/01-create-api.cy.ts rename to e2e/cypress/tests/13-namespace-preview-mode/01-create-api.cy.ts index 7011be473..c1c977618 100644 --- a/e2e/cypress/tests/14-namespace-preview-mode/01-create-api.cy.ts +++ b/e2e/cypress/tests/13-namespace-preview-mode/01-create-api.cy.ts @@ -8,8 +8,8 @@ describe('Create API Spec', () => { const home = new HomePage() const sa = new ServiceAccountsPage() const pd = new Products() - var nameSpace: string - let userSession: string + let userSession: any + let namespace: string before(() => { cy.visit('/') @@ -25,22 +25,33 @@ describe('Create API Spec', () => { cy.visit(login.path) }) - it('authenticates Janis (api owner)', () => { - cy.get('@apiowner').then(({ user }: any) => { - cy.login(user.credentials.username, user.credentials.password) + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace, false).then((value) => { + userSession = value + }) }) }) - it('creates and activates new namespace', () => { - cy.getUserSession().then(() => { - cy.get('@apiowner').then(({ namespacePreview }: any) => { - nameSpace = namespacePreview.namespace - home.createNamespace(namespacePreview.namespace) - cy.get('@login').then(function (xhr: any) { - userSession = xhr.response.headers['x-auth-request-access-token'] - }) - }) - }) + it('Set token with gwa config command', () => { + cy.exec('gwa config set --token ' + userSession, { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('create namespace using gwa cli command', () => { + var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, ""); + cy.exec('gwa namespace create --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + assert.isNotNaN(response.stdout) + namespace = response.stdout + cy.updateJsonValue('apiowner.json', 'namespacePreview.namespace', namespace) + // cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace) + cy.executeCliCommand("gwa config set --namespace " + namespace) + }); + }) + + it('activates new namespace', () => { + home.useNamespace(namespace) }) it('creates a new service account', () => { @@ -51,16 +62,6 @@ describe('Create API Spec', () => { sa.saveServiceAcctCreds() }) - it('publishes a new API to Kong Gateway', () => { - cy.get('@apiowner').then(({ namespacePreview }: any) => { - cy.publishApi('service-permission.yml', namespacePreview.namespace).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - }) - }) - }) - }) - it('creates as new product in the directory', () => { cy.visit(pd.path) cy.get('@apiowner').then(({ namespacePreview }: any) => { @@ -75,18 +76,9 @@ describe('Create API Spec', () => { }) }) - it('applies authorization plugin to service published to Kong Gateway', () => { - cy.get('@apiowner').then(({ namespacePreview }: any) => { - cy.publishApi('service-permission.yml', namespacePreview.namespace).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - }) - }) - }) - }) - after(() => { cy.logout() - cy.clearLocalStorage({log:true}) + cy.clearLocalStorage({ log: true }) cy.deleteAllCookies() }) }) diff --git a/e2e/cypress/tests/14-namespace-preview-mode/02-namespace-preview-mode.cy.ts b/e2e/cypress/tests/13-namespace-preview-mode/02-namespace-preview-mode.cy.ts similarity index 100% rename from e2e/cypress/tests/14-namespace-preview-mode/02-namespace-preview-mode.cy.ts rename to e2e/cypress/tests/13-namespace-preview-mode/02-namespace-preview-mode.cy.ts diff --git a/e2e/cypress/tests/15-org-assignment/01-client-cred-team-access.ts b/e2e/cypress/tests/14-org-assignment/01-client-cred-team-access.ts similarity index 80% rename from e2e/cypress/tests/15-org-assignment/01-client-cred-team-access.ts rename to e2e/cypress/tests/14-org-assignment/01-client-cred-team-access.ts index 6ac09b0c5..3d491297b 100644 --- a/e2e/cypress/tests/15-org-assignment/01-client-cred-team-access.ts +++ b/e2e/cypress/tests/14-org-assignment/01-client-cred-team-access.ts @@ -8,6 +8,7 @@ import Products from '../../pageObjects/products' import ServiceAccountsPage from '../../pageObjects/serviceAccounts' import MyAccessPage from '../../pageObjects/myAccess' import ConsumersPage from '../../pageObjects/consumers' +let namespace: string describe('Add Organization to publish API', () => { const login = new LoginPage() @@ -16,6 +17,8 @@ describe('Add Organization to publish API', () => { const pd = new Products() const sa = new ServiceAccountsPage() const apiDir = new ApiDirectoryPage() + let userSession: any + before(() => { cy.visit('/') @@ -27,20 +30,36 @@ describe('Add Organization to publish API', () => { beforeEach(() => { cy.preserveCookies() cy.fixture('apiowner').as('apiowner') - // cy.visit(login.path) + cy.visit(login.path) }) - it('Authenticates api owner', () => { - cy.get('@apiowner').then(({ user, orgAssignment }: any) => { - cy.login(user.credentials.username, user.credentials.password) - // home.useNamespace(orgAssignment.namespace) + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace, false).then((value) => { + userSession = value + }) }) }) - it('Creates and activates new namespace', () => { - cy.get('@apiowner').then(({ orgAssignment }: any) => { - home.createNamespace(orgAssignment.namespace) - }) + it('Set token with gwa config command', () => { + cy.exec('gwa config set --token ' + userSession, { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('create namespace using gwa cli command', () => { + var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, ""); + cy.exec('gwa namespace create --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + assert.isNotNaN(response.stdout) + namespace = response.stdout + cy.updateJsonValue('apiowner.json', 'orgAssignment.namespace', namespace) + // cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace) + cy.executeCliCommand("gwa config set --namespace " + namespace) + }); + }) + + it('activates new namespace', () => { + home.useNamespace(namespace) }) it('creates a new service account', () => { @@ -76,13 +95,9 @@ describe('Add Organization to publish API', () => { }) it('applies authorization plugin to service published to Kong Gateway', () => { - cy.get('@apiowner').then(({ orgAssignment }: any) => { - cy.publishApi('org-service-plugin.yml', orgAssignment.namespace).then(() => { - cy.get('@publishAPIResponse').then((res: any) => { - cy.log(JSON.stringify(res.body)) - expect(res.body.message).to.contains("Sync successful") - }) - }) + cy.replaceWordInJsonObject('ns.orgassignment', 'ns.' + namespace, 'org-service-plugin.yml') + cy.publishApi('org-service-plugin.yml', namespace).then((response: any) => { + expect(response.stdout).to.contain('Sync successful'); }) }) @@ -107,7 +122,9 @@ describe('Add Organization to publish API', () => { it('Verify Organization Administrator notification banner', () => { cy.visit(apiDir.path) cy.get('@apiowner').then(({ orgAssignment }: any) => { - apiDir.checkOrgAdminNotificationBanner(orgAssignment.orgAdminNotification) + cy.replaceWord(orgAssignment.orgAdminNotification.parent, 'orgassignment', namespace).then((updatedNotification: string) => { + apiDir.checkOrgAdminNotificationBanner(updatedNotification, orgAssignment.orgAdminNotification.child) + }) }) }) @@ -138,15 +155,13 @@ describe('Org Admin approves the request', () => { }) it('Authenticates Product Owner', () => { - cy.get('@product-owner').then(({ user, namespace }: any) => { + cy.get('@product-owner').then(({ user }: any) => { cy.login(user.credentials.username, user.credentials.password) }) }) it('Select the namespace', () => { - cy.get('@product-owner').then(({ namespace }: any) => { - home.useNamespace(namespace) - }) + home.useNamespace(namespace) }) it('Clik on Enable Publishing option from Namespace Page', () => { @@ -188,9 +203,9 @@ describe('Activate the API to make it visible in API Directory', () => { }) it('Authenticates api owner', () => { - cy.get('@apiowner').then(({ user, orgAssignment }: any) => { + cy.get('@apiowner').then(({ user }: any) => { cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(orgAssignment.namespace) + home.useNamespace(namespace) }) }) @@ -217,7 +232,7 @@ describe('Activate the API to make it visible in API Directory', () => { cy.get('@apiowner').then(({ orgAssignment }: any) => { let product = orgAssignment.product.name // cy.contains('button').click() - apiDir.isProductDisplay(product,true) + apiDir.isProductDisplay(product, true) }) }) @@ -299,11 +314,9 @@ describe('Access manager approves developer access request for Kong API ACL auth }) it('Access Manager logs in', () => { - cy.get('@apiowner').then(({ orgAssignment }: any) => { - cy.get('@access-manager').then(({ user}: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(orgAssignment.namespace) - }) + cy.get('@access-manager').then(({ user }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(namespace) }) }) diff --git a/e2e/cypress/tests/15-org-assignment/02-multiple-org-admin.ts b/e2e/cypress/tests/14-org-assignment/02-multiple-org-admin.ts similarity index 71% rename from e2e/cypress/tests/15-org-assignment/02-multiple-org-admin.ts rename to e2e/cypress/tests/14-org-assignment/02-multiple-org-admin.ts index ecf53ccb7..4a04424c9 100644 --- a/e2e/cypress/tests/15-org-assignment/02-multiple-org-admin.ts +++ b/e2e/cypress/tests/14-org-assignment/02-multiple-org-admin.ts @@ -64,6 +64,9 @@ describe('Multiple Org Adming for the organization', () => { const pd = new Products() const sa = new ServiceAccountsPage() const apiDir = new ApiDirectoryPage() + const login = new LoginPage() + let userSession: any + let namespace: any before(() => { cy.visit('/') @@ -75,21 +78,40 @@ describe('Multiple Org Adming for the organization', () => { beforeEach(() => { cy.preserveCookies() cy.fixture('apiowner').as('apiowner') - // cy.visit(login.path) + cy.visit(login.path) }) - it('Authenticates api owner', () => { - cy.get('@apiowner').then(({ user }: any) => { - cy.login(user.credentials.username, user.credentials.password) + + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace, false).then((value) => { + userSession = value + }) }) }) - it('Creates and activates new namespace', () => { - cy.get('@apiowner').then(({ orgAssignmentMultipleAdmin }: any) => { - home.createNamespace(orgAssignmentMultipleAdmin.namespace) - }) + it('Set token with gwa config command', () => { + cy.exec('gwa config set --token ' + userSession, { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('create namespace using gwa cli command', () => { + var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, ""); + cy.exec('gwa namespace create --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + assert.isNotNaN(response.stdout) + namespace = response.stdout + cy.updateJsonValue('apiowner.json', 'orgAssignment.namespace', namespace) + // cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace) + cy.executeCliCommand("gwa config set --namespace " + namespace) + }); + }) + + it('activates new namespace', () => { + home.useNamespace(namespace) }) + it('creates a new service account', () => { cy.visit(sa.path) cy.get('@apiowner').then(({ serviceAccount }: any) => { diff --git a/e2e/cypress/tests/15-org-assignment/03-multiple-org-admin-org-unit.ts b/e2e/cypress/tests/14-org-assignment/03-multiple-org-admin-org-unit.ts similarity index 74% rename from e2e/cypress/tests/15-org-assignment/03-multiple-org-admin-org-unit.ts rename to e2e/cypress/tests/14-org-assignment/03-multiple-org-admin-org-unit.ts index 512a0987a..2d10435b5 100644 --- a/e2e/cypress/tests/15-org-assignment/03-multiple-org-admin-org-unit.ts +++ b/e2e/cypress/tests/14-org-assignment/03-multiple-org-admin-org-unit.ts @@ -81,6 +81,9 @@ describe('Multiple Org Admin for the organization', () => { const pd = new Products() const sa = new ServiceAccountsPage() const apiDir = new ApiDirectoryPage() + const login = new LoginPage() + let userSession: any + let namespace: any before(() => { cy.visit('/') @@ -92,20 +95,36 @@ describe('Multiple Org Admin for the organization', () => { beforeEach(() => { cy.preserveCookies() cy.fixture('apiowner').as('apiowner') - // cy.visit(login.path) + cy.visit(login.path) }) - it('Authenticates api owner', () => { - cy.get('@apiowner').then(({ user }: any) => { - cy.login(user.credentials.username, user.credentials.password) + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace, false).then((value) => { + userSession = value + }) }) }) - it('Creates and activates new namespace', () => { - cy.get('@apiowner').then(({ orgAssignmentOrgUnit }: any) => { - home.createNamespace(orgAssignmentOrgUnit.namespace) - // home.useNamespace(orgAssignmentMultipleAdmin.namespace) - }) + it('Set token with gwa config command', () => { + cy.exec('gwa config set --token ' + userSession, { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('create namespace using gwa cli command', () => { + var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, ""); + cy.exec('gwa namespace create --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + assert.isNotNaN(response.stdout) + namespace = response.stdout + cy.updateJsonValue('apiowner.json', 'orgAssignment.namespace', namespace) + // cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace) + cy.executeCliCommand("gwa config set --namespace " + namespace) + }); + }) + + it('activates new namespace', () => { + home.useNamespace(namespace) }) it('creates a new service account', () => { diff --git a/e2e/cypress/tests/15-aps-api/01-create-api.cy.ts b/e2e/cypress/tests/15-aps-api/01-create-api.cy.ts new file mode 100644 index 000000000..d47a5fa60 --- /dev/null +++ b/e2e/cypress/tests/15-aps-api/01-create-api.cy.ts @@ -0,0 +1,73 @@ +import HomePage from '../../pageObjects/home' +import LoginPage from '../../pageObjects/login' +import Products from '../../pageObjects/products' +import ServiceAccountsPage from '../../pageObjects/serviceAccounts' + +describe('Create API Spec', () => { + const login = new LoginPage() + const home = new HomePage() + const sa = new ServiceAccountsPage() + const pd = new Products() + let userSession: any + let namespace: any + + before(() => { + cy.visit('/') + cy.deleteAllCookies() + cy.reload() + cy.resetState() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('apiowner').as('apiowner') + cy.fixture('api').as('api') + cy.visit(login.path) + }) + + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace, false).then((value) => { + userSession = value + }) + }) + }) + + it('Set token with gwa config command', () => { + cy.exec('gwa config set --token ' + userSession, { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('create namespace using gwa cli command', () => { + var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, ""); + cy.exec('gwa namespace create --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + assert.isNotNaN(response.stdout) + namespace = response.stdout + cy.updateJsonValue('apiowner.json', 'apiTest.namespace', namespace) + cy.updateJsonValue('api.json', 'organization.expectedNamespace.name', namespace) + // cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace) + cy.executeCliCommand("gwa config set --namespace " + namespace) + }); + }) + + it('activates new namespace', () => { + home.useNamespace(namespace) + }) + + it('Associate Namespace to the organization Unit', () => { + cy.get('@api').then(({ organization }: any) => { + cy.setHeaders(organization.headers) + cy.setAuthorizationToken(userSession) + cy.makeAPIRequest(organization.endPoint + '/' + organization.orgName + '/' + organization.orgExpectedList.name + '/namespaces/' + namespace, 'PUT').then((response) => { + expect(response.status).to.be.equal(200) + }) + }) + }) + + after(() => { + cy.logout() + cy.clearLocalStorage({log:true}) + cy.deleteAllCookies() + }) +}) diff --git a/e2e/cypress/tests/16-aps-api/02-organization.cy.ts b/e2e/cypress/tests/15-aps-api/02-organization.cy.ts similarity index 92% rename from e2e/cypress/tests/16-aps-api/02-organization.cy.ts rename to e2e/cypress/tests/15-aps-api/02-organization.cy.ts index feb5a92a4..5b9649af9 100644 --- a/e2e/cypress/tests/16-aps-api/02-organization.cy.ts +++ b/e2e/cypress/tests/15-aps-api/02-organization.cy.ts @@ -54,7 +54,7 @@ describe('Verify /Organization/{Org} end point', () => { it('Verify the status code and response message for invalid organization name', () => { cy.get('@api').then(({ organization }: any) => { - cy.makeAPIRequest(organization.endPoint + '/health' , 'GET').then((response) => { + cy.makeAPIRequest(organization.endPoint + '/health', 'GET').then((response) => { expect(response.status).to.be.oneOf([404, 422]) expect(response.body.message).to.be.equal("Organization not found.") }) @@ -123,6 +123,20 @@ describe('Get the Organization Role', () => { }) }) + it('Get the list of roles and verify the success code in the response', () => { + cy.makeAPIRequest('ds/api/v2/roles', 'GET').then((res) => { + expect(res.status).to.be.equal(200) + response = res.body + }) + }) + + it('Compare the roles values in response against the expected values', () => { + cy.get('@api').then(({ organization }: any) => { + expectedResponse = organization.expectedRoles + cy.compareJSONObjects(response, expectedResponse) + }) + }) + }) describe('Get the Namespace associated with the organization', () => { @@ -156,6 +170,7 @@ describe('Get the Namespace associated with the organization', () => { cy.get('@api').then(({ organization }: any) => { expectedResponse = organization.expectedNamespace // assert.isTrue(Cypress._.isEqual(response, expectedResponse)) + debugger cy.compareJSONObjects(response, expectedResponse, true) }) }) @@ -246,7 +261,7 @@ describe('Add and Get Organization Access', () => { after(() => { cy.logout() - cy.clearLocalStorage({log:true}) + cy.clearLocalStorage({ log: true }) cy.deleteAllCookies() - }) + }) }) \ No newline at end of file diff --git a/e2e/cypress/tests/16-aps-api/03-documentation.cy.ts b/e2e/cypress/tests/15-aps-api/03-documentation.cy.ts similarity index 81% rename from e2e/cypress/tests/16-aps-api/03-documentation.cy.ts rename to e2e/cypress/tests/15-aps-api/03-documentation.cy.ts index b41c52f69..9f749ba12 100644 --- a/e2e/cypress/tests/16-aps-api/03-documentation.cy.ts +++ b/e2e/cypress/tests/15-aps-api/03-documentation.cy.ts @@ -2,7 +2,8 @@ import HomePage from "../../pageObjects/home" import LoginPage from "../../pageObjects/login" let userSession: any let slugValue: string - +let namespace: string +let updatedDocumentEndPoint: string describe('Get the user session token', () => { const login = new LoginPage() @@ -24,6 +25,7 @@ describe('Get the user session token', () => { cy.get('@apiowner').then(({ apiTest }: any) => { cy.getUserSessionTokenValue(apiTest.namespace).then((value) => { userSession = value + namespace = apiTest.namespace }) }) }) @@ -48,8 +50,11 @@ describe('API Tests for Updating documentation', () => { it('Put the resource and verify the success code in the response', () => { cy.get('@api').then(({ documentation }: any) => { - cy.makeAPIRequest(documentation.endPoint, 'PUT').then((response) => { - expect(response.status).to.be.equal(200) + cy.replaceWord(documentation.endPoint, 'apiplatform', namespace).then((updatedEndPoint: string) => { + updatedDocumentEndPoint = updatedEndPoint + cy.makeAPIRequest(updatedDocumentEndPoint, 'PUT').then((response) => { + expect(response.status).to.be.equal(200) + }) }) }) }) @@ -74,12 +79,10 @@ describe('API Tests for Fetching documentation', () => { }) it('Get the resource and verify the success code in the response', () => { - cy.get('@api').then(({ documentation }: any) => { - cy.makeAPIRequest(documentation.endPoint, 'GET').then((res) => { - expect(res.status).to.be.equal(200) - slugValue = res.body[0].slug - response = res.body[0] - }) + cy.makeAPIRequest(updatedDocumentEndPoint, 'GET').then((res) => { + expect(res.status).to.be.equal(200) + slugValue = res.body[0].slug + response = res.body[0] }) }) @@ -109,19 +112,16 @@ describe('API Tests for Deleting documentation', () => { }) it('Verify the status code and response message for invalid slugvalue', () => { - cy.get('@api').then(({ documentation }: any) => { - cy.makeAPIRequest(documentation.endPoint + '/platform_test', 'DELETE').then((response) => { - expect(response.status).to.be.oneOf([404, 422]) - expect(response.body.message).to.be.equal("Content not found") - }) + cy.makeAPIRequest(updatedDocumentEndPoint + '/platform_test', 'DELETE').then((response) => { + expect(response.status).to.be.oneOf([404, 422]) + expect(response.body.message).to.be.equal("Content not found") }) }) + it('Delete the documentation', () => { - cy.get('@api').then(({ documentation }: any) => { - cy.makeAPIRequest(documentation.endPoint + '/' + slugValue, 'DELETE').then((response) => { - expect(response.status).to.be.equal(200) - }) + cy.makeAPIRequest(updatedDocumentEndPoint + '/' + slugValue, 'DELETE').then((response) => { + expect(response.status).to.be.equal(200) }) }) }) @@ -144,11 +144,9 @@ describe('API Tests to verify no value in Get call after deleting document conte }) it('Delete the documentation', () => { - cy.get('@api').then(({ documentation }: any) => { - cy.makeAPIRequest(documentation.endPoint, 'GET').then((response) => { - expect(response.status).to.be.equal(200) - expect(response.body).to.be.empty - }) + cy.makeAPIRequest(updatedDocumentEndPoint, 'GET').then((response) => { + expect(response.status).to.be.equal(200) + expect(response.body).to.be.empty }) }) }) @@ -180,10 +178,8 @@ describe('API Tests to verify Get documentation content', () => { }) it('Put the resource and verify the success code in the response', () => { - cy.get('@api').then(({ documentation }: any) => { - cy.makeAPIRequest(documentation.endPoint, 'PUT').then((response) => { - expect(response.status).to.be.equal(200) - }) + cy.makeAPIRequest(updatedDocumentEndPoint, 'PUT').then((response) => { + expect(response.status).to.be.equal(200) }) }) diff --git a/e2e/cypress/tests/16-aps-api/04-keycloak-shared-IDP-config.cy.ts b/e2e/cypress/tests/15-aps-api/04-keycloak-shared-IDP-config.cy.ts similarity index 100% rename from e2e/cypress/tests/16-aps-api/04-keycloak-shared-IDP-config.cy.ts rename to e2e/cypress/tests/15-aps-api/04-keycloak-shared-IDP-config.cy.ts diff --git a/e2e/cypress/tests/15-aps-api/05-authorizationProfiles.cy.ts b/e2e/cypress/tests/15-aps-api/05-authorizationProfiles.cy.ts new file mode 100644 index 000000000..5417e4c65 --- /dev/null +++ b/e2e/cypress/tests/15-aps-api/05-authorizationProfiles.cy.ts @@ -0,0 +1,300 @@ +import AuthorizationProfile from "../../pageObjects/authProfile" +import HomePage from "../../pageObjects/home" +import login from "../../pageObjects/login" +import LoginPage from "../../pageObjects/login" +let userSession: any +let testData = require("../../fixtures/test_data/authorizationProfile.json") +let namespace: string +let updatedAuthProfileEndPoint: string + +describe('Get the user session token', () => { + + const login = new LoginPage() + const home = new HomePage() + + before(() => { + cy.visit('/') + cy.deleteAllCookies() + cy.reload() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('apiowner').as('apiowner') + cy.visit(login.path) + }) + + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace).then((value) => { + userSession = value + namespace = apiTest.namespace + }) + }) + }) + + it('Set token with gwa config command', () => { + cy.exec('gwa config set --token ' + userSession, { timeout: 3000, failOnNonZeroExit: false }).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) +}) + +testData.forEach((testCase: any) => { + describe('API Tests for Authorization Profiles', () => { + + var response: any + var actualResponse: any = {} + var expectedResponse: any = {} + + beforeEach(() => { + cy.fixture('api').as('api') + }) + + it('Prepare the Request Specification for the API', () => { + cy.get('@api').then(({ authorizationProfiles }: any) => { + cy.setHeaders(authorizationProfiles.headers) + cy.setAuthorizationToken(userSession) + cy.setRequestBody(testCase.body) + }) + }) + + it('Put the resource and verify the success code in the response', () => { + cy.get('@api').then(({ authorizationProfiles }: any) => { + cy.replaceWord(authorizationProfiles.endPoint, 'apiplatform', namespace).then((updatedEndPoint: string) => { + updatedAuthProfileEndPoint = updatedEndPoint + cy.makeAPIRequest(updatedAuthProfileEndPoint, 'PUT').then((response) => { + expect(response.status).to.be.equal(200) + }) + }) + }) + }) + + it('Get the resource and verify the success code in the response', () => { + cy.makeAPIRequest(updatedAuthProfileEndPoint, 'GET').then((res) => { + expect(res.status).to.be.equal(200) + response = res.body + }) + }) + + it('Compare the values in response against the values passed in the request', () => { + cy.get('@api').then(({ authorizationProfiles }: any) => { + actualResponse = response + expectedResponse = testCase.body + cy.compareJSONObjects(actualResponse, expectedResponse, true) + }) + }) + + it('Delete the authorization profile', () => { + cy.makeAPIRequest(updatedAuthProfileEndPoint + '/' + testCase.body.name, 'DELETE').then((response) => { + expect(response.status).to.be.equal(200) + }) + }) + + + it('Verify that the authorization profile is deleted', () => { + cy.makeAPIRequest(updatedAuthProfileEndPoint, 'GET').then((response) => { + expect(response.status).to.be.equal(200) + expect(response.body.length).to.be.equal(0) + }) + }) + }) + + after(() => { + cy.clearLocalStorage({ log: true }) + cy.deleteAllCookies() + }) +}) + +describe('API Tests for Authorization Profiles created with inheritFrom attribute set to a valid shared Issuer', () => { + + let response: any + let actualResponse: any + let expectedResponse: any + + beforeEach(() => { + cy.fixture('api').as('api') + cy.fixture('apiowner').as('apiowner') + }) + + it('Prepare the Request Specification to create a shared IDP profile', () => { + cy.get('@api').then(({ authorizationProfiles }: any) => { + cy.setHeaders(authorizationProfiles.headers) + cy.setAuthorizationToken(userSession) + cy.setRequestBody(authorizationProfiles.shared_IDP_body) + }) + }) + + it('Put the resource to create shared IDP profile and verify the success code in the response', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.makeAPIRequest('ds/api/v2/namespaces/' + apiTest.namespace + '/issuers', 'PUT').then((response) => { + expect(response.status).to.be.equal(200) + }) + }) + }) + + it('Prepare the Request Specification to create a shared IDP profile using inheritFrom attribute', () => { + cy.get('@api').then(({ authorizationProfiles }: any) => { + cy.setHeaders(authorizationProfiles.headers) + cy.setAuthorizationToken(userSession) + cy.setRequestBody(authorizationProfiles.shared_IDP_inheritFrom) + }) + }) + + it('Create an authorization profile using inheritFrom attribute and verify the success code in the response', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.makeAPIRequest('ds/api/v2/namespaces/' + apiTest.namespace + '/issuers', 'PUT').then((response) => { + expect(response.status).to.be.equal(200) + expect(response.body.result).to.be.equal("created") + }) + }) + }) + + it('Get list of authorization profile and verify the success code in the response', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.makeAPIRequest('ds/api/v2/namespaces/' + apiTest.namespace + '/issuers', 'GET').then((res) => { + expect(res.status).to.be.equal(200) + response = res.body + }) + }) + }) + + it('Compare the values in response against the values passed in the request', () => { + cy.get('@api').then(({ authorizationProfiles }: any) => { + actualResponse = response + expectedResponse = authorizationProfiles.shared_IDP_inheritFrom_expectedResponse + cy.compareJSONObjects(actualResponse, expectedResponse, true) + }) + }) + +}) + +describe('Published a shared authorization profile', () => { + + let response: any + let actualResponse: any + let expectedResponse: any + + beforeEach(() => { + cy.fixture('api').as('api') + cy.fixture('apiowner').as('apiowner') + }) + + it('Prepare the Request Specification to create a shared IDP profile', () => { + cy.get('@api').then(({ authorizationProfiles }: any) => { + cy.setHeaders(authorizationProfiles.headers) + cy.setAuthorizationToken(userSession) + cy.setRequestBody(authorizationProfiles.shared_gwa) + }) + }) + + it('Create a shared credential issuer', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.makeAPIRequest('ds/api/v2/namespaces/' + apiTest.namespace + '/issuers', 'PUT').then((response) => { + expect(response.status).to.be.equal(200) + expect(response.body.result).to.be.equal("created") + }) + }) + }) + + it('Get list of authorization profile and verify the success code in the response', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.makeAPIRequest('ds/api/v2/namespaces/' + apiTest.namespace + '/issuers', 'GET').then((res) => { + expect(res.status).to.be.equal(200) + response = res.body + }) + }) + }) + + after(() => { + cy.logout() + cy.clearLocalStorage({ log: true }) + cy.deleteAllCookies() + }) + +}) + +describe('Deleted shared auth profile', () => { + + const login = new LoginPage() + const home = new HomePage() + const authProfile = new AuthorizationProfile() + + before(() => { + cy.visit('/') + cy.deleteAllCookies() + cy.reload() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('apiowner').as('apiowner') + cy.fixture('api').as('api') + }) + + it('Authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace).then((value) => { + userSession = value + namespace = apiTest.namespace + home.useNamespace(namespace); + }) + }) + }) + + it('Navigate to authorization profile page', () => { + cy.visit(authProfile.path) + }) + + it('Delete the authorizarion profile inherited from shared IDP', () => { + cy.get('@api').then(({ authorizationProfiles }: any) => { + authProfile.deleteAuthProfile(authorizationProfiles.shared_IDP_inheritFrom_expectedResponse.name) + }) + }) + + after(() => { + cy.logout() + cy.clearLocalStorage({ log: true }) + cy.deleteAllCookies() + }) +}) + +describe('Verify that client ID of deleted shared auth profile in IDP', () => { + + var nameSpace: string + const home = new HomePage() + const authProfile = new AuthorizationProfile() + + before(() => { + cy.visit(Cypress.env('KEYCLOAK_URL')) + cy.deleteAllCookies() + cy.reload() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('developer').as('developer') + cy.fixture('apiowner').as('apiowner') + cy.fixture('state/regen').as('regen') + cy.fixture('admin').as('admin') + cy.fixture('api').as('api') + }) + + it('Authenticates Admin owner', () => { + cy.get('@admin').then(({ user }: any) => { + cy.contains('Administration Console').click({ force: true }) + cy.keycloakLogin(user.credentials.username, user.credentials.password) + }) + }) + + it('Navigate to Clients', () => { + cy.contains('Clients').click() + }) + + it('Verify that the client id of deleted shared auth profile does not display', () => { + cy.get('@api').then(({ authorizationProfiles }: any) => { + cy.contains(authorizationProfiles.shared_IDP_inheritFrom_expectedResponse.name).should('not.exist') + }) + }) + +}) \ No newline at end of file diff --git a/e2e/cypress/tests/16-aps-api/06-products.cy.ts b/e2e/cypress/tests/15-aps-api/06-products.cy.ts similarity index 80% rename from e2e/cypress/tests/16-aps-api/06-products.cy.ts rename to e2e/cypress/tests/15-aps-api/06-products.cy.ts index f9e69a7f5..0b9053cb1 100644 --- a/e2e/cypress/tests/16-aps-api/06-products.cy.ts +++ b/e2e/cypress/tests/15-aps-api/06-products.cy.ts @@ -4,6 +4,8 @@ import Products from "../../pageObjects/products" let userSession: any let productID: string let envID: string +let updatedProductEndPoint: string +let namespace: string describe('Get the user session token to check ', () => { @@ -27,6 +29,7 @@ describe('Get the user session token to check ', () => { cy.get('@apiowner').then(({ user, apiTest }: any) => { cy.login(user.credentials.username, user.credentials.password) home.useNamespace(apiTest.namespace) + namespace = apiTest.namespace cy.get('@login').then(function (xhr: any) { userSession = xhr.response.headers['x-auth-request-access-token'] }) @@ -56,20 +59,24 @@ describe('API Tests for Updating Products', () => { it('Put the resource and verify the success code in the response', () => { cy.get('@api').then(({ products }: any) => { - cy.makeAPIRequest(products.endPoint, 'PUT').then((response) => { - expect(response.status).to.be.equal(200) + cy.replaceWord(products.endPoint, 'apiplatform', namespace).then((updatedEndPoint: string) => { + updatedProductEndPoint = updatedEndPoint + cy.makeAPIRequest(updatedProductEndPoint, 'PUT').then((response) => { + expect(response.status).to.be.equal(200) + }) }) }) }) it('Get the resource and verify the success code and product name in the response', () => { cy.get('@api').then(({ products }: any) => { - cy.makeAPIRequest(products.endPoint, 'GET').then((res) => { + cy.makeAPIRequest(updatedProductEndPoint, 'GET').then((res) => { expect(res.status).to.be.equal(200) let index = res.body.findIndex((x: { name: string }) => x.name === products.body.name) response = res.body[index] productID = res.body[index].appId envID = res.body[index].environments[0].appId + debugger }) }) }) @@ -102,6 +109,7 @@ describe('Verify that created Product is displayed in UI', () => { it('authenticates Janis (api owner) to get the user session token', () => { cy.get('@apiowner').then(({ apiTest }: any) => { cy.getUserSessionTokenValue(apiTest.namespace).then((value) => { + home.useNamespace(apiTest.namespace) userSession = value }) }) @@ -134,15 +142,17 @@ describe('API Tests for Delete Products', () => { it('Delete the product environment and verify the success code in the response', () => { cy.get('@api').then(({ products }: any) => { - cy.makeAPIRequest(products.deleteEnvironmentEndPoint + '/' + envID, 'Delete').then((response) => { - expect(response.status).to.be.equal(200) + cy.replaceWord(products.deleteEnvironmentEndPoint, 'apiplatform', namespace).then((updatedEndPoint: string) => { + cy.makeAPIRequest(updatedEndPoint + '/' + envID, 'Delete').then((response) => { + expect(response.status).to.be.equal(200) + }) }) }) }) it('Get the resource and verify that product environment is deleted', () => { cy.get('@api').then(({ products }: any) => { - cy.makeAPIRequest(products.endPoint, 'GET').then((res) => { + cy.makeAPIRequest(updatedProductEndPoint, 'GET').then((res) => { expect(res.status).to.be.equal(200) let index = res.body.findIndex((x: { name: string }) => x.name === products.body.name) expect(res.body[index].environments).to.be.empty @@ -151,16 +161,14 @@ describe('API Tests for Delete Products', () => { }) it('Delete the product and verify the success code in the response', () => { - cy.get('@api').then(({ products }: any) => { - cy.makeAPIRequest(products.endPoint + '/' + productID, 'Delete').then((response) => { - expect(response.status).to.be.equal(200) - }) + cy.makeAPIRequest(updatedProductEndPoint + '/' + productID, 'Delete').then((response) => { + expect(response.status).to.be.equal(200) }) }) it('Get the resource and verify that product is deleted', () => { cy.get('@api').then(({ products }: any) => { - cy.makeAPIRequest(products.endPoint, 'GET').then((res) => { + cy.makeAPIRequest(updatedProductEndPoint, 'GET').then((res) => { expect(res.status).to.be.equal(200) response = res.body assert.equal(response.findIndex((x: { name: string }) => x.name === products.body.name), -1) diff --git a/e2e/cypress/tests/16-aps-api/07-api-directory.cy.ts b/e2e/cypress/tests/15-aps-api/07-api-directory.cy.ts similarity index 85% rename from e2e/cypress/tests/16-aps-api/07-api-directory.cy.ts rename to e2e/cypress/tests/15-aps-api/07-api-directory.cy.ts index ce6c1311f..19309fcd2 100644 --- a/e2e/cypress/tests/16-aps-api/07-api-directory.cy.ts +++ b/e2e/cypress/tests/15-aps-api/07-api-directory.cy.ts @@ -104,12 +104,10 @@ describe('API Tests for Updating dataset', () => { }) it('Get the resource (/organizations/{org}/datasets/{name}) and verify the success code in the response', () => { - cy.get('@apiowner').then(({ apiTest }: any) => { - cy.get('@api').then(({ apiDirectory, organization }: any) => { - cy.makeAPIRequest(apiDirectory.orgEndPoint + '/' + organization.orgName + '/datasets/' + apiDirectory.body.name, 'GET').then((res) => { - expect(res.status).to.be.equal(200) - response = res.body - }) + cy.get('@api').then(({ apiDirectory, organization }: any) => { + cy.makeAPIRequest(apiDirectory.orgEndPoint + '/' + organization.orgName + '/datasets/' + apiDirectory.body.name, 'GET').then((res) => { + expect(res.status).to.be.equal(200) + response = res.body }) }) }) @@ -121,12 +119,10 @@ describe('API Tests for Updating dataset', () => { }) it('Get the resource (/organizations/{org}/datasets) and verify the success code in the response', () => { - cy.get('@apiowner').then(({ apiTest }: any) => { - cy.get('@api').then(({ apiDirectory, organization }: any) => { - cy.makeAPIRequest(apiDirectory.orgEndPoint + '/' + organization.orgName + '/datasets/', 'GET').then((res) => { - expect(res.status).to.be.equal(200) - response = res.body - }) + cy.get('@api').then(({ apiDirectory, organization }: any) => { + cy.makeAPIRequest(apiDirectory.orgEndPoint + '/' + organization.orgName + '/datasets/', 'GET').then((res) => { + expect(res.status).to.be.equal(200) + response = res.body }) }) }) @@ -150,7 +146,7 @@ describe('API Tests for Updating dataset', () => { it('Verify the expected directory details are display in the response', () => { cy.get('@api').then(({ apiDirectory }: any) => { - // cy.compareJSONObjects(response, apiDirectory.directory, true) + cy.compareJSONObjects(response, apiDirectory.directory, true) }) }) @@ -187,11 +183,11 @@ describe('API Tests for Updating dataset', () => { }) }) - // it('Verify the expected namespace directory details are display in the response', () => { - // cy.get('@api').then(({ apiDirectory }: any) => { - // cy.compareJSONObjects(response, apiDirectory.directory, true) - // }) - // }) + it('Verify the expected namespace directory details are display in the response', () => { + cy.get('@api').then(({ apiDirectory }: any) => { + cy.compareJSONObjects(response, apiDirectory.directory, false) + }) + }) it('Get the namespace directory details by its ID (/namespaces/{ns}/directory/{id}) and verify the success code in the response', () => { cy.get('@apiowner').then(({ namespace }: any) => { @@ -215,11 +211,9 @@ describe('API Tests for Updating dataset', () => { }) it('Delete the dataset (/organizations/{org}/datasets/{name}) and verify the success code in the response', () => { - cy.get('@apiowner').then(({ apiTest }: any) => { - cy.get('@api').then(({ apiDirectory, organization }: any) => { - cy.makeAPIRequest(apiDirectory.orgEndPoint + '/' + organization.orgName + '/datasets/' + apiDirectory.body.name, 'DELETE').then((res) => { - expect(res.status).to.be.equal(200) - }) + cy.get('@api').then(({ apiDirectory, organization }: any) => { + cy.makeAPIRequest(apiDirectory.orgEndPoint + '/' + organization.orgName + '/datasets/' + apiDirectory.body.name, 'DELETE').then((res) => { + expect(res.status).to.be.equal(200) }) }) }) diff --git a/e2e/cypress/tests/15-aps-api/08-namespaces.cy.ts b/e2e/cypress/tests/15-aps-api/08-namespaces.cy.ts new file mode 100644 index 000000000..8a050f7e4 --- /dev/null +++ b/e2e/cypress/tests/15-aps-api/08-namespaces.cy.ts @@ -0,0 +1,294 @@ +import HomePage from "../../pageObjects/home" +import LoginPage from "../../pageObjects/login" +let testData = require("../../fixtures/apiowner.json") +let userSession: any +let nameSpace: string + +describe('Get the user session token to pass it as authorization token to make the API call ', () => { + + const login = new LoginPage() + const home = new HomePage() + + before(() => { + cy.visit('/') + cy.deleteAllCookies() + cy.reload() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('apiowner').as('apiowner') + cy.visit(login.path) + }) + + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace).then((value) => { + userSession = value + }) + nameSpace = apiTest.namespace + }) + }) +}) + +describe('API Tests for Namespace Report', () => { + + const login = new LoginPage() + const home = new HomePage() + var response: any + + beforeEach(() => { + cy.fixture('api').as('api') + }) + + it('Prepare the Request Specification for the API', () => { + cy.get('@api').then(({ namespaces }: any) => { + cy.setHeaders(namespaces.headers) + cy.setAuthorizationToken(userSession) + }) + }) + + it('Get the resource and verify the success code in the response', () => { + cy.get('@api').then(({ namespaces }: any) => { + cy.makeAPIRequest(namespaces.endPoint + "/report", 'GET').then((response) => { + // expect(response.status).to.be.equal(200) + }) + }) + }) +}) + +describe('API Tests for Namespace List', () => { + + const login = new LoginPage() + const home = new HomePage() + var response: any + + beforeEach(() => { + cy.fixture('api').as('api') + }) + + it('Prepare the Request Specification for the API', () => { + cy.get('@api').then(({ namespaces }: any) => { + cy.setHeaders(namespaces.headers) + cy.setAuthorizationToken(userSession) + }) + }) + + it('Get the resource and verify the success code in the response', () => { + cy.get('@api').then(({ namespaces }: any) => { + cy.makeAPIRequest(namespaces.endPoint, 'GET').then((res) => { + expect(res.status).to.be.equal(200) + response = res.body + }) + }) + }) + + it('Verify that the selected Namespace is displayed in the Response list in the response', () => { + expect(response).to.be.contain(nameSpace) + }) +}) + +describe('API Tests for Namespace Activities', () => { + + const login = new LoginPage() + const home = new HomePage() + var response: any + + beforeEach(() => { + cy.fixture('api').as('api') + }) + + it('Prepare the Request Specification for the API', () => { + cy.get('@api').then(({ namespaces }: any) => { + cy.setHeaders(namespaces.headers) + cy.setAuthorizationToken(userSession) + }) + }) + + it('Get the resource and verify the success code in the response', () => { + cy.get('@api').then(({ namespaces }: any) => { + cy.makeAPIRequest(namespaces.endPoint + "/" + nameSpace + "/activity", 'GET').then((res) => { + expect(res.status).to.be.equal(200) + }) + }) + }) +}) + +describe('API Tests for Namespace Summary', () => { + + const login = new LoginPage() + const home = new HomePage() + var response: any + + beforeEach(() => { + cy.fixture('api').as('api') + cy.fixture('apiowner').as('apiowner') + }) + + it('Prepare the Request Specification for the API', () => { + cy.get('@api').then(({ namespaces }: any) => { + cy.setHeaders(namespaces.headers) + cy.setAuthorizationToken(userSession) + }) + }) + + it('Get the resource for namespace summary and verify the success code in the response', () => { + cy.get('@apiowner').then(({ namespace }: any) => { + cy.get('@api').then(({ namespaces }: any) => { + cy.makeAPIRequest(namespaces.endPoint + "/" + namespace, 'GET').then((res) => { + expect(res.status).to.be.equal(200) + response = res.body.name + }) + }) + }) + }) + + it('Verify that expected namespace summary details are display in the response', () => { + cy.get('@api').then(({ namespaces }: any) => { + // cy.compareJSONObjects(response, namespaces.activity) + }) + }) +}) + +describe('API Tests for Create Namespace', () => { + + const login = new LoginPage() + const home = new HomePage() + var response: any + + beforeEach(() => { + cy.fixture('api').as('api') + cy.fixture('apiowner').as('apiowner') + }) + + it('Prepare the Request Specification for the API', () => { + cy.get('@api').then(({ namespaces }: any) => { + cy.setHeaders(namespaces.headers) + cy.setAuthorizationToken(userSession) + }) + }) + + it('Create system generated namespace when user does not specify namespace name', () => { + cy.get('@api').then(({ namespaces }: any) => { + cy.makeAPIRequest(namespaces.endPoint, 'POST').then((res) => { + expect(res.status).to.be.equal(200) + expect(res.body.displayName).to.be.equal(null) + nameSpace = res.body.name + }) + }) + }) + + it('Verify that the generated namespace is displayed in the namespace list', () => { + cy.get('@api').then(({ namespaces }: any) => { + cy.makeAPIRequest(namespaces.endPoint, 'GET').then((res) => { + expect(res.status).to.be.equal(200) + expect(res.body).to.be.contain(nameSpace) + }) + }) + }) + + it('Create users own namespace with its description', () => { + cy.get('@api').then(({ namespaces }: any) => { + cy.setRequestBody(namespaces.userDefinedNamespace) + cy.makeAPIRequest(namespaces.endPoint, 'POST').then((res) => { + expect(res.status).to.be.equal(200) + expect(res.body.displayName).to.be.equal(namespaces.userDefinedNamespace.displayName) + nameSpace = res.body.name + }) + }) + }) + + it('Verify that the generated namespace is displayed in the namespace list', () => { + cy.get('@api').then(({ namespaces }: any) => { + cy.makeAPIRequest(namespaces.endPoint, 'GET').then((res) => { + expect(res.status).to.be.equal(200) + expect(res.body).to.be.contain(nameSpace) + }) + }) + }) +}) + +describe('API Tests for invalid namespace name', () => { + + beforeEach(() => { + cy.fixture('api').as('api') + cy.fixture('apiowner').as('apiowner') + }) + + it('Verify validation message in response when user creat namespace using invalid name', () => { + cy.get('@api').then(({ namespaces }: any) => { + cy.fixture('apiowner').then((testdata: any) => { + let namespaceName: Array = testdata.invalid_namespace + testdata + namespaceName.forEach((name: any) => { + cy.setHeaders(namespaces.headers) + // cy.setRequestBody('{"name": "' + name + '","displayName": "Test for GWA test"}') + cy.updateJsonBoby(namespaces.inValidNamespace, 'name', name).then((updatedBody) => { + cy.setRequestBody(updatedBody) + cy.makeAPIRequest(namespaces.endPoint, 'POST').then((res) => { + expect(res.status).to.be.equal(422) + expect(res.body.message).to.be.equal('Validation Failed') + }) + }) + }) + }) + }) + }) +}) + +// describe('API Tests for Deleting Namespace', () => { + +// const login = new LoginPage() +// const home = new HomePage() + + +// beforeEach(() => { +// cy.fixture('api').as('api') +// cy.fixture('apiowner').as('apiowner') +// }) + +// it('Prepare the Request Specification for the API', () => { +// cy.get('@api').then(({ namespaces }: any) => { +// cy.setHeaders(namespaces.headers) +// cy.setAuthorizationToken(userSession) +// }) +// }) + +// it('Delete the namespace and verify the Validation to prevent deleting the namespace', () => { +// cy.get('@apiowner').then(({ namespace }: any) => { +// cy.get('@api').then(({ namespaces }: any) => { +// cy.makeAPIRequest(namespaces.endPoint + "/" + namespace, 'DELETE').then((res) => { +// expect(res.status).to.be.equal(422) +// }) +// }) +// }) +// }) + +// it('Force delete the namespace and verify the success code in the response', () => { +// cy.get('@apiowner').then(({ namespace }: any) => { +// cy.get('@api').then(({ namespaces }: any) => { +// cy.makeAPIRequest(namespaces.endPoint + "/" + namespace + '?force=true', 'DELETE').then((res) => { +// expect(res.status).to.be.equal(200) +// }) +// }) +// }) +// }) + +// //need to confirm with Aidan - service returns 500 status code if there is no any namespaces +// // it('Verify that deleted namespace does not display in Get namespace list', () => { +// // let response: any +// // cy.get('@api').then(({ namespaces }: any) => { +// // cy.makeAPIRequest(namespaces.endPoint, 'GET').then((res) => { +// // // expect(res.status).to.be.equal(200) +// // response = res.body +// // expect(response).to.not.contain(nameSpace) +// // }) +// // }) +// // }) + +// after(() => { +// cy.logout() +// cy.clearLocalStorage({ log: true }) +// cy.deleteAllCookies() +// }) +// }) diff --git a/e2e/cypress/tests/16-aps-api/01-create-api.cy.ts b/e2e/cypress/tests/16-aps-api/01-create-api.cy.ts deleted file mode 100644 index 3f314bd82..000000000 --- a/e2e/cypress/tests/16-aps-api/01-create-api.cy.ts +++ /dev/null @@ -1,44 +0,0 @@ -import HomePage from '../../pageObjects/home' -import LoginPage from '../../pageObjects/login' -import Products from '../../pageObjects/products' -import ServiceAccountsPage from '../../pageObjects/serviceAccounts' - -describe('Create API Spec', () => { - const login = new LoginPage() - const home = new HomePage() - const sa = new ServiceAccountsPage() - const pd = new Products() - - before(() => { - cy.visit('/') - cy.deleteAllCookies() - cy.reload() - cy.resetState() - }) - - beforeEach(() => { - cy.preserveCookies() - cy.fixture('apiowner').as('apiowner') - cy.visit(login.path) - }) - - it('authenticates Janis (api owner)', () => { - cy.get('@apiowner').then(({ user }: any) => { - cy.login(user.credentials.username, user.credentials.password) - }) - }) - - it('creates and activates new namespace', () => { - cy.get('@apiowner').then(({ apiTest }: any) => { - home.createNamespace(apiTest.namespace) - // home.createNamespace(apiTest.delete_namespace) - }) - }) - - - after(() => { - cy.logout() - cy.clearLocalStorage({log:true}) - cy.deleteAllCookies() - }) -}) diff --git a/e2e/cypress/tests/16-aps-api/05-authorizationProfiles.cy.ts b/e2e/cypress/tests/16-aps-api/05-authorizationProfiles.cy.ts deleted file mode 100644 index a75bd2580..000000000 --- a/e2e/cypress/tests/16-aps-api/05-authorizationProfiles.cy.ts +++ /dev/null @@ -1,161 +0,0 @@ -import HomePage from "../../pageObjects/home" -import LoginPage from "../../pageObjects/login" -let userSession: any -let testData = require("../../fixtures/test_data/authorizationProfile.json") - -describe('Get the user session token', () => { - - const login = new LoginPage() - const home = new HomePage() - - before(() => { - cy.visit('/') - cy.deleteAllCookies() - cy.reload() - }) - - beforeEach(() => { - cy.preserveCookies() - cy.fixture('apiowner').as('apiowner') - cy.visit(login.path) - }) - - it('authenticates Janis (api owner) to get the user session token', () => { - cy.get('@apiowner').then(({ apiTest }: any) => { - cy.getUserSessionTokenValue(apiTest.namespace).then((value) => { - userSession = value - }) - }) - }) -}) - -testData.forEach((testCase: any) => { - describe('API Tests for Authorization Profiles', () => { - - var response: any - var actualResponse: any = {} - var expectedResponse: any = {} - - beforeEach(() => { - cy.fixture('api').as('api') - }) - - it('Prepare the Request Specification for the API', () => { - cy.get('@api').then(({ authorizationProfiles }: any) => { - cy.setHeaders(authorizationProfiles.headers) - cy.setAuthorizationToken(userSession) - cy.setRequestBody(testCase.body) - }) - }) - - it('Put the resource and verify the success code in the response', () => { - cy.get('@api').then(({ authorizationProfiles }: any) => { - cy.makeAPIRequest(authorizationProfiles.endPoint, 'PUT').then((response) => { - expect(response.status).to.be.equal(200) - }) - }) - }) - - it('Get the resource and verify the success code in the response', () => { - cy.get('@api').then(({ authorizationProfiles }: any) => { - cy.makeAPIRequest(authorizationProfiles.endPoint, 'GET').then((res) => { - expect(res.status).to.be.equal(200) - response = res.body - }) - }) - }) - - it('Compare the values in response against the values passed in the request', () => { - cy.get('@api').then(({ authorizationProfiles }: any) => { - actualResponse = response - expectedResponse = testCase.body - cy.compareJSONObjects(actualResponse, expectedResponse, true) - }) - }) - - it('Delete the authorization profile', () => { - cy.get('@api').then(({ authorizationProfiles }: any) => { - cy.makeAPIRequest(authorizationProfiles.endPoint + '/' + testCase.body.name, 'DELETE').then((response) => { - expect(response.status).to.be.equal(200) - }) - }) - }) - - it('Verify that the authorization profile is deleted', () => { - cy.get('@api').then(({ authorizationProfiles }: any) => { - cy.makeAPIRequest(authorizationProfiles.endPoint, 'GET').then((response) => { - expect(response.status).to.be.equal(200) - expect(response.body.length).to.be.equal(0) - }) - }) - }) - }) - - after(() => { - cy.clearLocalStorage({ log: true }) - cy.deleteAllCookies() - }) -}) - -describe('API Tests for Authorization Profiles created with inheritFrom attribute set to a valid shared Issuer', () => { - - let response: any - let actualResponse: any - let expectedResponse: any - - beforeEach(() => { - cy.fixture('api').as('api') - cy.fixture('apiowner').as('apiowner') - }) - - it('Prepare the Request Specification to create a shared IDP profile', () => { - cy.get('@api').then(({ authorizationProfiles }: any) => { - cy.setHeaders(authorizationProfiles.headers) - cy.setAuthorizationToken(userSession) - cy.setRequestBody(authorizationProfiles.shared_IDP_body) - }) - }) - - it('Put the resource to create shared IDP profile and verify the success code in the response', () => { - cy.get('@apiowner').then(({ apiTest }: any) => { - cy.makeAPIRequest('ds/api/v2/namespaces/' + apiTest.namespace + '/issuers', 'PUT').then((response) => { - expect(response.status).to.be.equal(200) - }) - }) - }) - - it('Prepare the Request Specification to create a shared IDP profile using inheritFrom attribute', () => { - cy.get('@api').then(({ authorizationProfiles }: any) => { - cy.setHeaders(authorizationProfiles.headers) - cy.setAuthorizationToken(userSession) - cy.setRequestBody(authorizationProfiles.shared_IDP_inheritFrom) - }) - }) - - it('Create an authorization profile using inheritFrom attribute and verify the success code in the response', () => { - cy.get('@apiowner').then(({ apiTest }: any) => { - cy.makeAPIRequest('ds/api/v2/namespaces/' + apiTest.namespace + '/issuers', 'PUT').then((response) => { - expect(response.status).to.be.equal(200) - expect(response.body.result).to.be.equal("created") - }) - }) - }) - - it('Get list of authorization profile and verify the success code in the response', () => { - cy.get('@apiowner').then(({ apiTest }: any) => { - cy.makeAPIRequest('ds/api/v2/namespaces/' + apiTest.namespace + '/issuers', 'GET').then((res) => { - expect(res.status).to.be.equal(200) - response = res.body - }) - }) - }) - - it('Compare the values in response against the values passed in the request', () => { - cy.get('@api').then(({ authorizationProfiles }: any) => { - actualResponse = response - expectedResponse = authorizationProfiles.shared_IDP_inheritFrom_expectedResponse - cy.compareJSONObjects(actualResponse, expectedResponse, true) - }) - }) - -}) \ No newline at end of file diff --git a/e2e/cypress/tests/16-aps-api/08-namespaces.cy.ts b/e2e/cypress/tests/16-aps-api/08-namespaces.cy.ts deleted file mode 100644 index 81bac4693..000000000 --- a/e2e/cypress/tests/16-aps-api/08-namespaces.cy.ts +++ /dev/null @@ -1,207 +0,0 @@ -import HomePage from "../../pageObjects/home" -import LoginPage from "../../pageObjects/login" -let userSession: any -let nameSpace: string - -describe('Get the user session token to pass it as authorization token to make the API call ', () => { - - const login = new LoginPage() - const home = new HomePage() - - before(() => { - cy.visit('/') - cy.deleteAllCookies() - cy.reload() - }) - - beforeEach(() => { - cy.preserveCookies() - cy.fixture('apiowner').as('apiowner') - cy.visit(login.path) - }) - - it('authenticates Janis (api owner) to get the user session token', () => { - cy.get('@apiowner').then(({ apiTest }: any) => { - cy.getUserSessionTokenValue(apiTest.namespace).then((value) => { - userSession = value - }) - nameSpace = apiTest.namespace - }) - }) -}) - -describe('API Tests for Namespace Report', () => { - - const login = new LoginPage() - const home = new HomePage() - var response: any - - beforeEach(() => { - cy.fixture('api').as('api') - }) - - it('Prepare the Request Specification for the API', () => { - cy.get('@api').then(({ namespaces }: any) => { - cy.setHeaders(namespaces.headers) - cy.setAuthorizationToken(userSession) - }) - }) - - it('Get the resource and verify the success code in the response', () => { - cy.get('@api').then(({ namespaces }: any) => { - cy.makeAPIRequest(namespaces.endPoint + "/report", 'GET').then((response) => { - // expect(response.status).to.be.equal(200) - }) - }) - }) -}) - -describe('API Tests for Namespace List', () => { - - const login = new LoginPage() - const home = new HomePage() - var response: any - - beforeEach(() => { - cy.fixture('api').as('api') - }) - - it('Prepare the Request Specification for the API', () => { - cy.get('@api').then(({ namespaces }: any) => { - cy.setHeaders(namespaces.headers) - cy.setAuthorizationToken(userSession) - }) - }) - - it('Get the resource and verify the success code in the response', () => { - cy.get('@api').then(({ namespaces }: any) => { - cy.makeAPIRequest(namespaces.endPoint, 'GET').then((res) => { - expect(res.status).to.be.equal(200) - response = res.body - }) - }) - }) - - it('Verify that the selected Namespace is displayed in the Response list in the response', () => { - expect(response).to.be.contain(nameSpace) - }) -}) - -describe('API Tests for Namespace Activities', () => { - - const login = new LoginPage() - const home = new HomePage() - var response: any - - beforeEach(() => { - cy.fixture('api').as('api') - }) - - it('Prepare the Request Specification for the API', () => { - cy.get('@api').then(({ namespaces }: any) => { - cy.setHeaders(namespaces.headers) - cy.setAuthorizationToken(userSession) - }) - }) - - it('Get the resource and verify the success code in the response', () => { - cy.get('@api').then(({ namespaces }: any) => { - cy.makeAPIRequest(namespaces.endPoint + "/" + nameSpace + "/activity", 'GET').then((res) => { - expect(res.status).to.be.equal(200) - }) - }) - }) -}) - -describe('API Tests for Namespace Summary', () => { - - const login = new LoginPage() - const home = new HomePage() - var response: any - - beforeEach(() => { - cy.fixture('api').as('api') - cy.fixture('apiowner').as('apiowner') - }) - - it('Prepare the Request Specification for the API', () => { - cy.get('@api').then(({ namespaces }: any) => { - cy.setHeaders(namespaces.headers) - cy.setAuthorizationToken(userSession) - }) - }) - - it('Get the resource for namespace summary and verify the success code in the response', () => { - cy.get('@apiowner').then(({ namespace }: any) => { - cy.get('@api').then(({ namespaces }: any) => { - cy.makeAPIRequest(namespaces.endPoint + "/" + namespace, 'GET').then((res) => { - expect(res.status).to.be.equal(200) - response = res.body - }) - }) - }) - }) - - it('Verify that expected namespace summary details are display in the response', () => { - cy.get('@api').then(({ namespaces }: any) => { - // cy.compareJSONObjects(response, namespaces.activity) - }) - }) -}) - -describe('API Tests for Deleting Namespace', () => { - - const login = new LoginPage() - const home = new HomePage() - - - beforeEach(() => { - cy.fixture('api').as('api') - cy.fixture('apiowner').as('apiowner') - }) - - it('Prepare the Request Specification for the API', () => { - cy.get('@api').then(({ namespaces }: any) => { - cy.setHeaders(namespaces.headers) - cy.setAuthorizationToken(userSession) - }) - }) - - it('Delete the namespace and verify the Validation to prevent deleting the namespace', () => { - cy.get('@apiowner').then(({ namespace }: any) => { - cy.get('@api').then(({ namespaces }: any) => { - cy.makeAPIRequest(namespaces.endPoint + "/" + namespace, 'DELETE').then((res) => { - expect(res.status).to.be.equal(422) - }) - }) - }) - }) - - it('Force delete the namespace and verify the success code in the response', () => { - cy.get('@apiowner').then(({ namespace }: any) => { - cy.get('@api').then(({ namespaces }: any) => { - cy.makeAPIRequest(namespaces.endPoint + "/" + namespace + '?force=true', 'DELETE').then((res) => { - expect(res.status).to.be.equal(200) - }) - }) - }) - }) - - //need to confirm with Aidan - service returns 500 status code if there is no any namespaces - // it('Verify that deleted namespace does not display in Get namespace list', () => { - // let response: any - // cy.get('@api').then(({ namespaces }: any) => { - // cy.makeAPIRequest(namespaces.endPoint, 'GET').then((res) => { - // // expect(res.status).to.be.equal(200) - // response = res.body - // expect(response).to.not.contain(nameSpace) - // }) - // }) - // }) - - after(() => { - cy.logout() - cy.clearLocalStorage({ log: true }) - cy.deleteAllCookies() - }) -}) diff --git a/e2e/cypress/tests/16-gwa-cli/01-cli-commands.ts b/e2e/cypress/tests/16-gwa-cli/01-cli-commands.ts new file mode 100644 index 000000000..fb4bd7390 --- /dev/null +++ b/e2e/cypress/tests/16-gwa-cli/01-cli-commands.ts @@ -0,0 +1,102 @@ +import LoginPage from '../../pageObjects/login' +import ApplicationPage from '../../pageObjects/applications' +import ApiDirectoryPage from '../../pageObjects/apiDirectory' +import MyAccessPage from '../../pageObjects/myAccess' +const YAML = require('yamljs'); +let userSession: any +let cli = require("../../fixtures/test_data/gwa-cli.json") +var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, ""); +const jose = require('node-jose') + +describe('Verify CLI commands', () => { + const login = new LoginPage() + const apiDir = new ApiDirectoryPage() + const app = new ApplicationPage() + const ma = new MyAccessPage() + let namespace: string + + before(() => { + // cy.visit('/') + cy.deleteAllCookies() + cy.reload() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('apiowner').as('apiowner') + // cy.visit(login.path) + }) + + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace, false).then((value) => { + userSession = value + }) + }) + }) + + + it('Check gwa command to login with client ID and secret', () => { + let clientID = cli.credentials.clientID + let clientSecret = cli.credentials.clientSecret + cy.log('gwa login --host ${url} --scheme http') + cy.executeCliCommand('gwa login --client-id ' + clientID + ' --client-secret ' + clientSecret + ' --host ' + cleanedUrl + ' --scheme http').then((response) => { + expect(response.stdout).to.contain('Successfully logged in'); + }); + }) + + it('Check gwa command for login with invalid client id', () => { + let clientID = "dummy-client" + let clientSecret = cli.credentials.clientSecret + cy.executeCliCommand('gwa login --client-id ' + clientID + ' --client-secret ' + clientSecret + ' --host ' + cleanedUrl + ' --scheme http').then((response) => { + assert.equal(response.stderr, "Error: unauthorized_client\nINVALID_CREDENTIALS: Invalid client credentials") + }); + }) + + it('Check gwa command for login with invalid client secret', () => { + let clientID = cli.credentials.clientID + let clientSecret = "dummy-client-secret" + cy.executeCliCommand('gwa login --client-id ' + clientID + ' --client-secret ' + clientSecret + ' --host ' + cleanedUrl + ' --scheme http').then((response) => { + assert.equal(response.stderr, "Error: unauthorized_client\nINVALID_CREDENTIALS: Invalid client credentials") + }); + }) + + + it('Check gwa config command to set environment', () => { + var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, ""); + cy.executeCliCommand('gwa config set --host ' + cleanedUrl + ' --scheme http').then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('Check gwa config command to set token', () => { + cy.executeCliCommand('gwa config set --token ' + userSession).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('Check gwa command to create namespace', () => { + cy.executeCliCommand('gwa namespace create --host ' + cleanedUrl + ' --scheme http').then((response) => { + assert.isNotNaN(response.stdout) + namespace = response.stdout + }); + }) + + + it('Check gwa namespace list command and verify the created namespace in the list', () => { + cy.executeCliCommand('gwa namespace list --host ' + cleanedUrl + ' --scheme http').then((response) => { + expect(response.stdout).to.contain(namespace); + }); + }) + + it('Delete Exsting config file', () => { + cy.deleteFileInE2EFolder('gw-config.yml') + }) + + after(() => { + cy.logout() + cy.clearLocalStorage({ log: true }) + cy.deleteAllCookies() + }) + +}) \ No newline at end of file diff --git a/e2e/cypress/tests/16-gwa-cli/02-cli-generate-config.ts b/e2e/cypress/tests/16-gwa-cli/02-cli-generate-config.ts new file mode 100644 index 000000000..7ced10b71 --- /dev/null +++ b/e2e/cypress/tests/16-gwa-cli/02-cli-generate-config.ts @@ -0,0 +1,101 @@ +import LoginPage from '../../pageObjects/login' +import ApplicationPage from '../../pageObjects/applications' +import ApiDirectoryPage from '../../pageObjects/apiDirectory' +import MyAccessPage from '../../pageObjects/myAccess' +import HomePage from '../../pageObjects/home'; +import Products from '../../pageObjects/products'; +const YAML = require('yamljs'); +let userSession: any +let cli = require("../../fixtures/test_data/gwa-cli.json") + +const jose = require('node-jose') + +describe('Verify CLI commands for generate/apply config', () => { + const login = new LoginPage() + const apiDir = new ApiDirectoryPage() + const app = new ApplicationPage() + const ma = new MyAccessPage() + const pd = new Products() + let namespace: string + const home = new HomePage() + + before(() => { + // cy.visit('/') + cy.deleteAllCookies() + cy.reload() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('apiowner').as('apiowner') + // cy.visit(login.path) + }) + + it('authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace, false).then((value) => { + userSession = value + }) + }) + }) + + it('Check gwa config command to set token', () => { + cy.executeCliCommand('gwa config set --token ' + userSession).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('Check gwa command to generate config for client credential template', () => { + cy.executeCliCommand('gwa generate-config --template client-credentials-shared-idp --service my-service --upstream https://httpbin.org --org ministry-of-health --org-unit planning-and-innovation-division').then((response) => { + assert.equal(response.stdout, "File gw-config.yml created") + }); + }) + + it('Check gwa command to apply generated config', () => { + cy.executeCliCommand('gwa apply').then((response) => { + let wordOccurrences = (response.stdout.match(/\bcreated\b/g) || []).length; + expect(wordOccurrences).to.equal(3) + namespace = response.stdout.split('\n')[0] + namespace = namespace.replace('-', '').trim() + }); + }) + + it('Check gwa command to generate config for kong httpbin template', () => { + cy.executeCliCommand('gwa generate-config --template kong-httpbin --service my-service --upstream https://httpbin.org --org ministry-of-health --org-unit planning-and-innovation-division').then((response) => { + assert.equal(response.stdout, "File gw-config.yml created") + }); + }) + + it('activates new namespace', () => { + home.useNamespace(namespace) + }) + + it('Verify that the product created through gwa command is displayed in the portal', () => { + cy.visit(pd.path) + pd.editProductEnvironment('my-service API', 'dev') + }) + + it('Verify the Authorization scope and issuer details for the product', () => { + pd.verifyAuthScope('Oauth2 Client Credentials Flow') + }) + + it('Verify the issuer details for the product', () => { + pd.verifyIssuer(namespace + ' default (test)') + }) + + it('Verify that the dataset created through GWA comand is assocuated with the product', () => { + cy.visit(pd.path) + pd.verifyDataset('my-service', 'my-service API') + }) + + it('Navigate to home path', () => { + cy.visit(login.path) + }) + + after(() => { + cy.logout() + cy.clearLocalStorage({ log: true }) + cy.deleteAllCookies() +}) + +}) \ No newline at end of file diff --git a/e2e/cypress/tests/17-CORS/01-create-api.cy.ts b/e2e/cypress/tests/17-CORS/01-create-api.cy.ts deleted file mode 100644 index e7a84a363..000000000 --- a/e2e/cypress/tests/17-CORS/01-create-api.cy.ts +++ /dev/null @@ -1,126 +0,0 @@ -import WebAppPage from '../../pageObjects/webApp' - -describe('Create API Spec', () => { - const webApp = new WebAppPage() - let updatedBody: any - let pluginID: string - let serviceID: string - before(() => { - cy.visit(Cypress.env('WEBAPP_URL')) - // cy.visit(Cypress.env('WEBAPP_URL')) - cy.deleteAllCookies() - cy.reload() - }) - - beforeEach(() => { - cy.fixture('apiowner').as('apiowner') - cy.fixture('cors/kong-cors-plugin-config.json').as('kong-cors-plugin-config') - cy.preserveCookies() - }) - serviceID = 'ce5d3e76-1d35-47f0-8ddf-fad087b1f969' - pluginID = '73a51e86-23ec-43c2-97fc-b96ed9f5bd90' - - // it('Create a route for the service in Kong', () => { - // cy.readFile('cypress/fixtures/state/store.json').then((store_cred) => { - // serviceID = store_cred.servicesid - // cy.get('@kong-cors-plugin-config').then(({ createRoute }: any) => { - // cy.updateJsonValue(JSON.stringify(createRoute), '$.service.id', serviceID).then((updatedValue) => { - // cy.updateKongPluginForJSONRequest(updatedValue, 'routes').then((response) => { - // expect(response.status).to.be.equal(201) - // expect(response.statusText).to.be.equal('Created') - // }) - // }) - // }) - // }) - // }) - - // it('Publish CORS plugin to kong with a valid origins value', () => { - // cy.get('@kong-cors-plugin-config').then(({ uploadCORSPlugin }: any) => { - // debugger - // cy.updateKongPluginForJSONRequest(uploadCORSPlugin, 'services/'+serviceID+'/plugins').then((response) => { - // debugger - // expect(response.status).to.be.equal(201) - // expect(response.statusText).to.be.equal('Created') - // pluginID=response.body.id - // }) - // }) - // }) - - // it('Verify for successful CORS call for valid origin value', () => { - // webApp.getStatusAfterClickOnCORS().then((statusText)=>{ - // expect(statusText).to.be.equal('Response Code: 200') - // }) - // }) - - it('Set incorrrect origin name in CORS plugin', () => { - cy.get('@kong-cors-plugin-config').then(({ uploadCORSPlugin }: any) => { - debugger - cy.updateJsonValue(JSON.stringify(uploadCORSPlugin), '$.config.origins[0]', 'https://google.com').then((updatedValue) => { - updatedBody = updatedValue - cy.updateKongPluginForJSONRequest(updatedBody, 'services/' + serviceID + '/plugins/' + pluginID, 'PUT').then((response) => { - debugger - expect(response.status).to.be.equal(200) - }) - }) - }) - }) - - it('Verify for successful CORS call for valid origin value', () => { - // cy.origin(Cypress.env('WEBAPP_URL'), () => { - // cy.wait(5000) - // cy.get('[id="corsButton"]').click({ force: true }) - // cy.wait(8000) - // cy.visit('/') - - webApp.getStatusAfterClickOnCORS().then((statusText) => { - expect(statusText).to.be.equal('Error: Failed to fetch') - }) - }) - - - // it('Allow all origin name in CORS plugin', () => { - // cy.get('@kong-cors-plugin-config').then(({ uploadCORSPlugin }: any) => { - // debugger - // cy.updateJsonValue(JSON.stringify(uploadCORSPlugin), '$.config.origins[0]', '*').then((updatedValue) => { - // updatedBody = updatedValue - // cy.updateKongPluginForJSONRequest(updatedBody, 'services/'+serviceID+'/plugins/'+pluginID, 'PUT').then((response) => { - // debugger - // expect(response.status).to.be.equal(200) - // }) - // }) - // }) - // }) - - // it('Verify for successful CORS call for valid origin value', () => { - // webApp.getStatusAfterClickOnCORS().then((statusText)=>{ - // expect(statusText).to.be.equal('Response Code: 200') - // }) - // }) - - // it('Verify for successful CORS call for invalid header', () => { - // webApp.getStatusAfterClickOnCORSForHeaders().then((statusText)=>{ - // expect(statusText).to.be.equal('Error: Failed to fetch') - // }) - // }) - - // it('Set the header name as Access-Control-Allow-Headers in CORS plugin', () => { - // cy.get('@kong-cors-plugin-config').then(({ uploadCORSPlugin }: any) => { - // debugger - // cy.updateJsonValue(JSON.stringify(uploadCORSPlugin), '$.config.headers[4]', 'X-PINGOTHER').then((updatedValue) => { - // updatedBody = updatedValue - // cy.updateKongPluginForJSONRequest(updatedBody, 'services/'+serviceID+'/plugins/'+pluginID, 'PUT').then((response) => { - // debugger - // expect(response.status).to.be.equal(200) - // }) - // }) - // }) - // }) - - // it('Verify for successful CORS call after setting the header in Access-Control-Allow-Headers list', () => { - // webApp.getStatusAfterClickOnCORSForHeaders().then((statusText)=>{ - // expect(statusText).to.be.equal('Response Code: 200') - // }) - // }) - -}) - diff --git a/e2e/cypress/tests/13-delete-application/01-delete-application-without-access.cy.ts b/e2e/cypress/tests/17-delete-application/01-delete-application-without-access.cy.ts similarity index 100% rename from e2e/cypress/tests/13-delete-application/01-delete-application-without-access.cy.ts rename to e2e/cypress/tests/17-delete-application/01-delete-application-without-access.cy.ts diff --git a/e2e/cypress/tests/13-delete-application/02-delete-application-with-pending-request.cy.ts b/e2e/cypress/tests/17-delete-application/02-delete-application-with-pending-request.cy.ts similarity index 100% rename from e2e/cypress/tests/13-delete-application/02-delete-application-with-pending-request.cy.ts rename to e2e/cypress/tests/17-delete-application/02-delete-application-with-pending-request.cy.ts diff --git a/e2e/cypress/tests/13-delete-application/03-delete-application-with-approved-request.cy.ts b/e2e/cypress/tests/17-delete-application/03-delete-application-with-approved-request.cy.ts similarity index 92% rename from e2e/cypress/tests/13-delete-application/03-delete-application-with-approved-request.cy.ts rename to e2e/cypress/tests/17-delete-application/03-delete-application-with-approved-request.cy.ts index b1c91207c..ad189ce02 100644 --- a/e2e/cypress/tests/13-delete-application/03-delete-application-with-approved-request.cy.ts +++ b/e2e/cypress/tests/17-delete-application/03-delete-application-with-approved-request.cy.ts @@ -62,8 +62,8 @@ describe('Approve Pending Request Spec', () => { cy.visit('/') cy.deleteAllCookies() cy.reload() - cy.getServiceOrRouteID('services') - cy.getServiceOrRouteID('routes') + // cy.getServiceOrRouteID('services') + // cy.getServiceOrRouteID('routes') }) beforeEach(() => { @@ -76,9 +76,11 @@ describe('Approve Pending Request Spec', () => { }) it('authenticates Mark (Access-Manager)', () => { - cy.get('@access-manager').then(({ user, namespace }: any) => { - cy.login(user.credentials.username, user.credentials.password) - home.useNamespace(namespace); + cy.get('@access-manager').then(({ user }: any) => { + cy.get('@apiowner').then(({ namespace }: any) => { + cy.login(user.credentials.username, user.credentials.password) + home.useNamespace(namespace); + }) }) }) diff --git a/e2e/cypress/tests/17-delete-application/04-delete-namespace-gwa.ts b/e2e/cypress/tests/17-delete-application/04-delete-namespace-gwa.ts new file mode 100644 index 000000000..219282ac6 --- /dev/null +++ b/e2e/cypress/tests/17-delete-application/04-delete-namespace-gwa.ts @@ -0,0 +1,82 @@ +import LoginPage from "../../pageObjects/login" + +describe('Verify namespace delete using gwa command', () => { + const login = new LoginPage() + let _namespace: string + let userSession: any + + before(() => { + // cy.visit('/') + cy.deleteAllCookies() + cy.reload() + }) + + beforeEach(() => { + cy.preserveCookies() + cy.fixture('apiowner').as('apiowner') + cy.visit(login.path) + }) + + it('Authenticates Janis (api owner) to get the user session token', () => { + cy.get('@apiowner').then(({ apiTest }: any) => { + cy.getUserSessionTokenValue(apiTest.namespace, false).then((value) => { + userSession = value + }) + }) + }) + + it('Set token using gwa config command', () => { + cy.executeCliCommand('gwa config set --token ' + userSession).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + }); + }) + + it('Create namespace using gwa cli command', () => { + cy.executeCliCommand('gwa namespace create').then((response) => { + assert.isNotNaN(response.stdout) + _namespace = response.stdout + }); + }) + + it('Check gwa namespace destroy command for soft deleting namespace', () => { + cy.executeCliCommand('gwa namespace destroy ' + _namespace).then((response) => { + expect(response.stdout).to.contain('Namespace destroyed: ' + _namespace); + }); + }) + + it('Check that deleted namespace does not display in gwa namespace list command', () => { + cy.executeCliCommand('gwa namespace list').then((response) => { + expect(response.stdout).not.to.contain(_namespace); + }); + }) + + it('Check gwa namespace destroy command for the namespace associated with services', () => { + cy.get('@apiowner').then(({ namespace }: any) => { + _namespace = namespace + cy.executeCliCommand('gwa config set --namespace ' + namespace).then((response) => { + expect(response.stdout).to.contain("Config settings saved") + cy.executeCliCommand('gwa namespace destroy').then((response) => { + expect(response.stderr).to.contain('services have been configured in this namespace'); + }); + }) + }) + }) + + it('Check gwa namespace destroy command for hard deleting namespace', () => { + cy.executeCliCommand('gwa namespace destroy --force').then((response) => { + expect(response.stdout).to.contain('Namespace destroyed: ' + _namespace); + }); + }) + + it('Check that deleted namespace does not display in gwa namespace list command', () => { + cy.executeCliCommand('gwa namespace list').then((response) => { + expect(response.stdout).not.to.contain(_namespace); + }); + }) + + after(() => { + cy.logout() + cy.clearLocalStorage({ log: true }) + cy.deleteAllCookies() + }) +}) \ No newline at end of file diff --git a/e2e/gw-config.yml b/e2e/gw-config.yml new file mode 100644 index 000000000..3b0034ccf --- /dev/null +++ b/e2e/gw-config.yml @@ -0,0 +1,36 @@ +kind: DraftDataset +name: gwa-auto-test-product +license_title: Open Government Licence - British Columbia +security_class: PUBLIC +view_audience: Public +download_audience: Public +record_publish_date: '2017-09-05' +notes: For Test Purpose +title: GWA Auto Test Product +tags: + - tag1 + - tag2 +organization: ministry-of-health +organizationUnit: planning-and-innovation-division +isInCatalog: true +isDraft: false +--- +kind: Product +name: GWA Auto Test Product +appId: 'KFH78YU956RE' +environments: + - name: dev + active: false + approval: false + flow: public + appId: '406CB7CF' +# --- +# kind: ProductEnvironment +# name: dev +# product: my-service API +# appId: '5F194B28' +# active: false +# approval: true +# flow: client-credentials +# credentialIssuer: gw-1977c default +# services: [my-service-dev] diff --git a/e2e/package-lock.json b/e2e/package-lock.json index 01b3db0b0..5df9ae714 100644 --- a/e2e/package-lock.json +++ b/e2e/package-lock.json @@ -14,6 +14,7 @@ "cypress-ntlm-auth": "^4.1.2", "cypress-xpath": "^1.6.2", "dotenv": "^10.0.0", + "js-yaml": "^4.1.0", "jsonwebtoken": "^8.5.1", "lodash": "^4.17.21", "mochawesome": "^7.1.3", @@ -83,6 +84,18 @@ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", "integrity": "sha512-bCK/2Z4zLidyB4ReuIsvALH6w31YfAQDmXMqMx6FyfHqvBxtjC0eRumeSu4Bs3XtXwpyIywtSTrVT99BxY1f9w==" }, + "node_modules/@atomist/yaml-updater/node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/@babel/code-frame": { "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", @@ -1892,6 +1905,19 @@ } } }, + "node_modules/@cypress/code-coverage/node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/@cypress/code-coverage/node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -2085,6 +2111,20 @@ "node": ">= 4" } }, + "node_modules/@eslint/eslintrc/node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "peer": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/@eslint/eslintrc/node_modules/type-fest": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", @@ -2140,6 +2180,18 @@ "node": ">=8" } }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/@istanbuljs/schema": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", @@ -4976,6 +5028,20 @@ "node": ">= 4" } }, + "node_modules/eslint/node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "peer": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/eslint/node_modules/semver": { "version": "7.3.7", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", @@ -6662,17 +6728,21 @@ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, + "node_modules/js-yaml/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, "node_modules/jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", @@ -7404,12 +7474,6 @@ "url": "https://opencollective.com/mochajs" } }, - "node_modules/mocha/node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "peer": true - }, "node_modules/mocha/node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -7426,18 +7490,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/mocha/node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "peer": true, - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/mocha/node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -10714,6 +10766,15 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", "integrity": "sha512-bCK/2Z4zLidyB4ReuIsvALH6w31YfAQDmXMqMx6FyfHqvBxtjC0eRumeSu4Bs3XtXwpyIywtSTrVT99BxY1f9w==" + }, + "js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } } } }, @@ -12007,6 +12068,16 @@ "ms": "2.1.2" } }, + "js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -12169,6 +12240,17 @@ "dev": true, "peer": true }, + "js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "peer": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, "type-fest": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", @@ -12212,6 +12294,17 @@ "get-package-type": "^0.1.0", "js-yaml": "^3.13.1", "resolve-from": "^5.0.0" + }, + "dependencies": { + "js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + } } }, "@istanbuljs/schema": { @@ -14200,6 +14293,17 @@ "dev": true, "peer": true }, + "js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "peer": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, "semver": { "version": "7.3.7", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", @@ -15629,12 +15733,18 @@ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "argparse": "^2.0.1" + }, + "dependencies": { + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + } } }, "jsbn": { @@ -16203,12 +16313,6 @@ "yargs-unparser": "2.0.0" }, "dependencies": { - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "peer": true - }, "find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -16219,15 +16323,6 @@ "path-exists": "^4.0.0" } }, - "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "peer": true, - "requires": { - "argparse": "^2.0.1" - } - }, "locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", diff --git a/e2e/package.json b/e2e/package.json index 6e1eca52b..1726f71fc 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -50,6 +50,7 @@ "cypress-ntlm-auth": "^4.1.2", "cypress-xpath": "^1.6.2", "dotenv": "^10.0.0", + "js-yaml": "^4.1.0", "jsonwebtoken": "^8.5.1", "lodash": "^4.17.21", "mochawesome": "^7.1.3", diff --git a/local/feeder-init/init.sh b/local/feeder-init/init.sh index 8d3536eb5..45c62582b 100755 --- a/local/feeder-init/init.sh +++ b/local/feeder-init/init.sh @@ -15,7 +15,7 @@ while true; do curl http://feeder.localtest.me:6000/push -F yaml=@shared-idp.yaml curl http://feeder.localtest.me:6000/push -F yaml=@platform-gwa-api.yaml curl http://feeder.localtest.me:6000/push -F yaml=@organization-unit.yaml - curl http://feeder.localtest.me:6000/push -F yaml=@dataset-gwa.yaml + # curl http://feeder.localtest.me:6000/push -F yaml=@dataset-gwa.yaml curl http://feeder.localtest.me:6000/push -F yaml=@org-dataset.yaml # curl http://feeder.localtest.me:6000/push -F yaml=@product-initializer.yaml # curl http://feeder.localtest.me:6000/push -F yaml=@product-initializer-permission.yaml diff --git a/local/oauth2-proxy/oauth2-proxy-local.cfg b/local/oauth2-proxy/oauth2-proxy-local.cfg index 749890067..2c7281267 100644 --- a/local/oauth2-proxy/oauth2-proxy-local.cfg +++ b/local/oauth2-proxy/oauth2-proxy-local.cfg @@ -21,7 +21,7 @@ set_xauthrequest="true" skip_jwt_bearer_tokens="false" set_authorization_header="false" pass_authorization_header="false" -skip_auth_regex="/login|/health|/public|/docs|/redirect|/_next|/images|/devportal|/manager|/about|/maintenance|/admin/session|/ds/api|/feed/|/signout|^[/]$" +skip_auth_regex="/login|/health|/public|/docs|/redirect|/_next|/images|/devportal|/manager|/about|/maintenance|/admin/session|/ds/api|/gw/api|/feed/|/signout|^[/]$" whitelist_domains="keycloak.localtest.me:9080" upstreams=["http://apsportal.localtest.me:3000"] skip_provider_button='true'