Skip to content

Commit

Permalink
Add more security commands
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <[email protected]>
  • Loading branch information
RyanL1997 committed Nov 24, 2023
1 parent beced89 commit 88b1e65
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 5 deletions.
27 changes: 27 additions & 0 deletions .cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,33 @@ Cypress.Commands.overwrite('request', (originalFn, ...args) => {
return originalFn(Object.assign({}, defaults, options));
});

Cypress.Commands.add('createTenant', (tenantID, tenantJson) => {
cy.request(
'PUT',
`${Cypress.env('openSearchUrl')}${SEC_API.TENANTS_BASE}/${tenantID}`,
tenantJson
);
cy.wait(10000);
});

Cypress.Commands.add('createInternalUser', (userID, userJson) => {
cy.request(
'PUT',
`${Cypress.env('openSearchUrl')}${SEC_API.INTERNALUSERS_BASE}/${userID}`,
userJson
);
cy.wait(10000);
});

Cypress.Commands.add('createRole', (roleID, roleJson) => {
cy.request(
'PUT',
`${Cypress.env('openSearchUrl')}${SEC_API.ROLE_BASE}/${roleID}`,
roleJson
);
cy.wait(10000);
});

Cypress.Commands.add('createRoleMapping', (roleID, rolemappingJson) => {
cy.request(
'PUT',
Expand Down
46 changes: 41 additions & 5 deletions .cypress/support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,51 @@
/// <reference types="cypress" />

declare namespace Cypress {
interface Chainable<Subject> {
/**
* Create a test tenant by calling REST API
* @example
* cy.createTenant('test_tenant', tenantJsonFixture )
*/
createTenant<S = any>(
tenantID: string,
tenantJson: string
): Chainable<S>;
}

interface Chainable<Subject> {
/**
* Create an internal user by calling REST API
* @example
* cy.createInternalUser('test_user', userJsonFixture )
*/
createInternalUser<S = any>(
userID: string,
userJson: string
): Chainable<S>;
}

interface Chainable<Subject> {
/**
* Create a role by calling REST API
* @example
* cy.createRole('role_name', roleJsonFixture )
*/
createRole<S = any>(
roleID: string,
roleJson: string
): Chainable<S>;
}

interface Chainable<Subject> {
/**
* Create a role mapping by calling REST API
* @example
* cy.createRoleMapping('role_name', rolemappingJsonFixture )
*/
createRoleMapping<S = any>(
roleID: string,
rolemappingJson: string
): Chainable<S>;
createRoleMapping<S = any>(
roleID: string,
rolemappingJson: string
): Chainable<S>;
}
}
}

0 comments on commit 88b1e65

Please sign in to comment.