Skip to content

Commit

Permalink
Merge pull request #45 from wso2/aw/2
Browse files Browse the repository at this point in the history
Remove constant folders
  • Loading branch information
asekawa authored Feb 13, 2024
2 parents fbc0188 + f99b561 commit f0e2ae1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 124 deletions.
30 changes: 14 additions & 16 deletions src/api/commands/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,9 @@
import { RequestContentTypes } from "../models/api-requests";

/**
* This command use to get the Authentication method with the prefered token and grant type
* @example cy.scimCreateUser("https://<hostname>/domain/", "admin", "admin123",reqBody, true)
* @param {string} serverHost - Host name
* @param {string} username - API authetication username/client-ID
* @param {string} password - API authetication credentials password/client-secret
* @param {jsonbody} grantType - Prefeered grant type
* @param {boolean} authType - Prefeered authentication type
*
* Ex:
* if using the Basic Authentication ,
* cy.getAuthorization("https://localhost:9443/t/carbon.super","admin","admin","","Basic" )
*
* if using Bearer Authentication
* cy.getAuthorization("https://localhost:9443/t/carbon.super","admin","admin","client_credentails","Bearer" )
* This command use to get the Basic Authorization token
* @param {string} username - API authetication username
* @param {string} password - API authetication user password
*/
Cypress.Commands.add("getBasicAuthentication", (username: string, password: string) => {

Expand All @@ -33,17 +22,26 @@ Cypress.Commands.add("getBasicAuthentication", (username: string, password: stri

});

/**
* This command use to get the Bearer Authorization token
* @param {string} token - Authentication token via a specific grant type ex:Client Credential
*/
Cypress.Commands.add("getBearerAuthentication", (token: string) => {


return cy.wrap(`Bearer ${token}`);

});

/**
* This command use to get the Authentication token via a specific grant type
* @param {string} serverHost - Server host endopoint
* @param {string} clientID - API authetication application client ID
* @param {string} clientSecret - API authetication application client Secret
*/
Cypress.Commands.add("getTokenViaClientCredential", (serverHost: string, clientID: string, clientSecret: string) => {

const encodedCredentials = btoa(clientID + ":" + clientSecret);
// Retrieve a bearer token from Bearer auth type `oauth2/token` endpoint.
// Retrieve a token from Basic auth type via `oauth2/token` endpoint .

return cy.request({
body: {
Expand Down
13 changes: 5 additions & 8 deletions src/api/commands/user-managment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,22 @@

/// <reference types="cypress" />

import { UserManagmentConstants } from "../constants/user-management-constants";
import { UserManagmentConstants } from "../models/user-management";
import { RequestContentTypes, RequestType } from "../models/api-requests";

/**
* This command use to create users from scim2.0 POST method
* @example cy.scimCreateUser("https://<hostname>/domain/", "admin", "admin123",reqBody, true)
* @param {string} host - host
* @param {string} authrzUserName - API authetication credentials user name
* @param {string} authrzPassword - API authetication credentials passowrd
* @param {jsonbody} reqBody - request body with user profile informations
* @param {boolean} failOnStatusCode- Whether to fail on response codes other than 2xx and 3xx
* @param {string} authzHeader - Authorization token
* @param {jsonbody} reqBody - Request body with user profile informations
* @param {boolean} failOnStatusCode - Whether to fail on response codes other than 2xx and 3xx
* */
Cypress.Commands.add("createUserViaAPI", (host: string ,authzHeader: string, reqBody: Cypress.ObjectLike,
failOnStatusCode = true ) => {

return cy.request({
"method": RequestType.POST,
"url": host + UserManagmentConstants.SCIM2_ENDPOINT + UserManagmentConstants.SCIM2_USER_ENDPOINT,
"url": host + UserManagmentConstants.SCIM2_END_POINT + UserManagmentConstants.SCIM2_USER_ENDPOINT,
"failOnStatusCode": failOnStatusCode,
"headers": {
"Content-Type": RequestContentTypes.SCIMJSON,
Expand All @@ -44,5 +42,4 @@ Cypress.Commands.add("createUserViaAPI", (host: string ,authzHeader: string, req
},
"body": reqBody
});

});
41 changes: 0 additions & 41 deletions src/api/constants/api-constants.ts

This file was deleted.

24 changes: 0 additions & 24 deletions src/api/constants/index.ts

This file was deleted.

34 changes: 0 additions & 34 deletions src/api/constants/user-management-constants.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@

import "./commands";

export * from "./constants";
export * from "./models";

0 comments on commit f0e2ae1

Please sign in to comment.