Skip to content

Commit

Permalink
Merge pull request wso2#400 from binodmx/main
Browse files Browse the repository at this point in the history
Add UI test to verify gateway environments
  • Loading branch information
binodmx authored Dec 6, 2022
2 parents b8dc76b + 5d1c9cf commit 90509c1
Show file tree
Hide file tree
Showing 5 changed files with 236 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Setup build environment
> **_Note :-_**
>
> You can skip following steps if you don not want to build [product-apim](https://github.com/wso2/product-apim) binaries
> You can skip following steps if you do not want to build [product-apim](https://github.com/wso2/product-apim) binaries
>
2. Install Maven from [https://maven.apache.org/download.cgi](https://maven.apache.org/download.cgi). * For Maven 3.8 and up, please check the Troubleshoot section.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2129,7 +2129,7 @@ export default function Environments() {
</TableCell>
{allEnvDeployments[row.name].revision != null ? (
<>
<TableCell align='left'>
<TableCell align='left' id='gateway-access-url-cell'>
<div className={classes.primaryEndpoint}>
{api.isWebSocket()
? getGatewayAccessUrl(allEnvDeployments[row.name]
Expand Down
40 changes: 40 additions & 0 deletions tests/cypress/fixtures/multipleDeployments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"count": 1,
"list": [
{
"displayName": "Revision 1",
"id": "1f4733db-2c48-449a-9fea-e5fd7068430a",
"description": "test",
"createdTime": 1670230943000,
"apiInfo": {
"id": "e2e5c296-0569-4074-9794-974131b65363"
},
"deploymentInfo": [
{
"revisionUuid": "1f4733db-2c48-449a-9fea-e5fd7068430a",
"name": "Default",
"vhost": "localhost",
"displayOnDevportal": true,
"deployedTime": 1670230943000,
"successDeployedTime": null
},
{
"revisionUuid": "1f4733db-2c48-449a-9fea-e5fd7068430a",
"name": "WSO2",
"vhost": "wso2.com",
"displayOnDevportal": true,
"deployedTime": 1670230943000,
"successDeployedTime": null
},
{
"revisionUuid": "1f4733db-2c48-449a-9fea-e5fd7068430a",
"name": "APIM",
"vhost": "apim.com",
"displayOnDevportal": true,
"deployedTime": 1670230943000,
"successDeployedTime": null
}
]
}
]
}
132 changes: 132 additions & 0 deletions tests/cypress/fixtures/multipleEnvironments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"devportalUrl": "https://localhost:9443/devportal",
"environment": [
{
"id": "Default",
"name": "Default",
"displayName": "Default",
"type": "hybrid",
"serverUrl": "https://localhost:9443/services/",
"provider": "wso2",
"showInApiConsole": true,
"vhosts": [
{
"host": "localhost",
"httpContext": "",
"httpPort": 8280,
"httpsPort": 8243,
"wsPort": 9099,
"wssPort": 8099,
"websubHttpPort": 9021,
"websubHttpsPort": 8021
}
],
"endpointURIs": [],
"additionalProperties": []
},
{
"id": "WSO2",
"name": "WSO2",
"displayName": "WSO2",
"type": "hybrid",
"serverUrl": "https://localhost:9443/services/",
"provider": "wso2",
"showInApiConsole": true,
"vhosts": [
{
"host": "wso2.com",
"httpContext": "",
"httpPort": -1,
"httpsPort": 443,
"wsPort": 9100,
"wssPort": 8100,
"websubHttpPort": 9022,
"websubHttpsPort": 8022
}
],
"endpointURIs": [],
"additionalProperties": []
},
{
"id": "APIM",
"name": "APIM",
"displayName": "APIM",
"type": "hybrid",
"serverUrl": "https://localhost:9443/services/",
"provider": "wso2",
"showInApiConsole": true,
"vhosts": [
{
"host": "apim.com",
"httpContext": "",
"httpPort": 8280,
"httpsPort": -1,
"wsPort": 9100,
"wssPort": 8100,
"websubHttpPort": 9022,
"websubHttpsPort": 8022
}
],
"endpointURIs": [],
"additionalProperties": []
}
],
"scopes": [
"apim:admin",
"apim:api_create",
"apim:api_definition_view",
"apim:api_delete",
"apim:api_generate_key",
"apim:api_import_export",
"apim:api_list_view",
"apim:api_manage",
"apim:api_mediation_policy_manage",
"apim:api_product_import_export",
"apim:api_publish",
"apim:api_view",
"apim:app_import_export",
"apim:client_certificates_add",
"apim:client_certificates_manage",
"apim:client_certificates_update",
"apim:client_certificates_view",
"apim:comment_manage",
"apim:comment_view",
"apim:comment_write",
"apim:common_operation_policy_manage",
"apim:common_operation_policy_view",
"apim:document_create",
"apim:document_manage",
"apim:ep_certificates_add",
"apim:ep_certificates_manage",
"apim:ep_certificates_update",
"apim:ep_certificates_view",
"apim:mediation_policy_create",
"apim:mediation_policy_manage",
"apim:mediation_policy_view",
"apim:pub_alert_manage",
"apim:publisher_settings",
"apim:shared_scope_manage",
"apim:subscription_block",
"apim:subscription_manage",
"apim:subscription_view",
"apim:threat_protection_policy_create",
"apim:threat_protection_policy_manage",
"apim:tier_manage",
"apim:tier_view",
"openid"
],
"monetizationAttributes": [],
"securityAuditProperties": {
"isGlobal": null,
"overrideGlobal": null,
"apiToken": null,
"collectionId": null,
"baseUrl": null
},
"externalStoresEnabled": false,
"docVisibilityEnabled": false,
"crossTenantSubscriptionEnabled": false,
"defaultAdvancePolicy": "Unlimited",
"defaultSubscriptionPolicy": "Unlimited",
"authorizationHeader": "Authorization"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import Utils from "@support/utils";

describe("publisher-015-02 : Verify Gateway Environments", () => {
const { publisher, password, superTenant, testTenant} = Utils.getUserInfo();

const verifyGatewayEnvironments = (tenant) => {
cy.loginToPublisher(publisher, password, tenant);
Utils.addAPIWithEndpoints({}).then((apiId) => {
cy.intercept('GET', `/api/am/publisher/v3/settings`, {fixture:'multipleEnvironments.json'}).as('settings');
cy.intercept('GET', `/api/am/publisher/v3/apis/${apiId}/revisions?query=deployed%3Atrue`,
{fixture:'multipleDeployments.json'}).as('revisions');

// Go to overview page
cy.visit(`/publisher/apis/${apiId}/overview`);

// Go to deployments page
cy.get('#left-menu-itemdeployments').click();
cy.wait(2000);

// Deploy API
cy.get('#Default').click({ "force": true });
cy.get('#add-description-btn').scrollIntoView().click({ "force": true });
cy.get('#add-description').click({ "force": true });
cy.get('#add-description').type('test');
cy.get('#deploy-btn').should('not.have.class', 'Mui-disabled').click();
cy.get('#undeploy-btn').should('not.have.class', 'Mui-disabled').should('exist');
cy.wait(2000);

// Verify environments
cy.get('#gateway-access-url-cell > div').should('have.text',
'http://localhost:8280https://localhost:8243https://wso2.comhttp://apim.com:8280').should('exist');

// Delete API
Utils.deleteAPI(apiId);
});
}

it.only("Verify Gateway Environments - super admin", () => {
verifyGatewayEnvironments(superTenant);
});
it.only("Verify Gateway Environments - tenant user", () => {
verifyGatewayEnvironments(testTenant);
});
});

0 comments on commit 90509c1

Please sign in to comment.