Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UI tests for editing claim mappings under Token Handling Options in Advanced Configurations #482

Merged
merged 4 commits into from
Jul 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
})