Skip to content

Commit

Permalink
Merge pull request #482 from thisaltennakoon/main
Browse files Browse the repository at this point in the history
Add UI tests for editing claim mappings under Token Handling Options in Advanced Configurations
  • Loading branch information
thisaltennakoon authored Jul 12, 2023
2 parents c86cd47 + 2ecb88d commit 764eef7
Showing 1 changed file with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
* under the License.
*/

import Utils from "@support/utils";

describe("Add key manager", () => {
const carbonUsername = 'admin';
const carbonPassword = 'admin';

before(function () {
cy.loginToAdmin(carbonUsername, carbonPassword);
})
it.only("Add key manager", () => {
const { carbonUsername, carbonPassword, tenant, superTenant } = Utils.getUserInfo();

const addKeyManager = (usernameLocal, passwordLocal) => {
cy.loginToAdmin(usernameLocal, passwordLocal);
const km = 'myAuth0';
const wellKnowUrl = 'https://my-tenant.us.auth0.com/.well-known/openid-configuration';
const clientId = 'test';
Expand All @@ -32,6 +32,10 @@ describe("Add key manager", () => {
const introspectionEp = 'https://my-tenant.auth0.com/oauth/token';
const userInfoEp = 'https://my-tenant.auth0.com/oauth/userInfo';
const scopeManagementEp = 'https://my-tenant.auth0.com/oauth/scope';
const claimKey1 = 'claimKey1';
const claimValueRegex1 = 'claimValueRegex1';
const claimKey2 = 'claimKey2';
const claimValueRegex2 = 'claimValueRegex2';

cy.get('[data-testid="Key Managers"]').click();
cy.get('.MuiButton-label').contains('Add Key Manager').click();
Expand All @@ -51,16 +55,47 @@ describe("Add key manager", () => {
cy.get('input[name="client_id"]').type(clientId);
cy.get('input[name="client_secret"]').type(clientSecret);
cy.get('input[name="audience"]').type(audience);
// adding claims under Token Handling Options for JWT type
cy.get('#mui-component-select-type').click();
cy.contains('li', 'JWT').click();
cy.get('input[name="claimKey"]').type(claimKey1);
cy.get('input[name="claimValueRegex"]').type(claimValueRegex1);
cy.get('[aria-label="[object Object]"]').click();
cy.get('input[name="claimKey"]').type(claimKey2);
cy.get('input[name="claimValueRegex"]').type(claimValueRegex2);
cy.get('[aria-label="[object Object]"]').click();
// validating added claims
cy.contains(claimKey1).should('exist');
cy.contains(claimValueRegex1).should('exist');
cy.contains(claimKey2).should('exist');
cy.contains(claimValueRegex2).should('exist');
cy.get('button.MuiButton-containedPrimary span').contains('Add').click();
cy.wait(1000);

// validating
cy.get('td > div').contains(km).should('exist');
});

// edit key manager
cy.get('td > div').contains(km).click();
// editing claims under Token Handling Options for JWT type (adding one more claim and deleting one claim)
cy.get('input[name="claimKey"]').type('claimKey3');
cy.get('input[name="claimValueRegex"]').type('claimValueRegex3');
cy.get('[aria-label="[object Object]"]').click();
// deleting claimKey1
cy.contains(claimKey1).parents('tr').find('button').click();
cy.contains(claimKey1).should('not.exist');
cy.get('button.MuiButton-containedPrimary span').contains('Update').click();

// delete
cy.get(`[data-testid="${km}-actions"] > span:first-child svg`).click();
cy.get('button > span').contains('Delete').click();
cy.get('td > div').contains(km).should('not.exist');
}
it.only("Add key manager - super admin", () => {
addKeyManager(carbonUsername, carbonPassword);
});

})
it.only("Add key manager - tenant user", () => {
addKeyManager(Utils.getTenantUser(carbonUsername, tenant), carbonPassword);
});
})

0 comments on commit 764eef7

Please sign in to comment.