Skip to content

Commit

Permalink
Added cypress test case for company API
Browse files Browse the repository at this point in the history
Signed-off-by: veerendra thakur <[email protected]>
  • Loading branch information
thakurveerendras committed Sep 4, 2023
1 parent 2303999 commit dae00a3
Show file tree
Hide file tree
Showing 8 changed files with 608 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/functional/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig } from 'cypress'

export default defineConfig({
defaultCommandTimeout: 20000,
requestTimeout: 30000,
requestTimeout: 90000,
"reporter": "cypress-mochawesome-reporter",
e2e: {
// baseUrl: 'http://localhost:1234',
Expand Down
297 changes: 297 additions & 0 deletions tests/functional/cypress/e2e/company.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands'
describe("To Validate & get GitHub Activity Callback via API call", function () {
//Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/github-activity
const claBaseEndpoint = `${Cypress.env("APP_URL")}cla-service/v4/`;
const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4/company/`;
let companyName="Infosys Limited";
let companyExternalID="";
let companyID="fcf59557-9708-4b2f-8200-4e6448761c0a";//Microsoft Corporation

let signingEntityName="";
const projectSFID="a09P000000DsCE5IAN";
let claGroupId="";

const user_id="8f3e52b8-0072-11ee-9def-0ef17207dfe8";//[email protected]
const userEmail= "[email protected]";
const user_id2="4a4c1dba-407f-11ed-8c58-a6b0f8fb81a9"//[email protected]

let bearerToken: string = null;
before(() => {

getTokenKey(bearerToken);
cy.window().then((win) => {
bearerToken = win.localStorage.getItem('bearerToken');
});

});

it("Gets the company by name", function () {
getCompanyByName();
});

it("Get Company By Internal ID", function () {
cy.request({
method: 'GET',
url: `${claEndpoint}${companyID}`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
let list=response.body;
companyExternalID=list.companyExternalID;
companyID=list.companyID;
signingEntityName=list.signingEntityName;
validateApiResponse("company/getCompanyByName.json",response)
});
});

it("Gets the company by signing entity name", function () {
cy.request({
method: 'GET',
url: `${claEndpoint}entityname/${signingEntityName}`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
let list=response.body;
companyExternalID=list.companyExternalID;
companyID=list.companyID;
signingEntityName=list.signingEntityName;
companyExternalID=list.companyExternalID;
validateApiResponse("company/getCompanyByName.json",response)
});
});

it("Search companies from organization service", function () {
cy.request({
method: 'GET',
url: `${claEndpoint}lookup?companyName=${companyName}`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
validateApiResponse("company/searchCompanyLookup.json",response)
});
});

it("Get active CLA list of company for particular project/foundation", function () {
cy.request({
method: 'GET',
url: `${claEndpoint}${companyID}/project/${projectSFID}/active-cla-list`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
validateApiResponse("company/getCompanyProjectActiveCla.json",response)
});
});

it("Get Company by External SFID", function () {
cy.request({
method: 'GET',
url: `${claEndpoint}external/${companyExternalID}`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
let list=response.body;
companyExternalID=list.companyExternalID;
companyID=list.companyID;
signingEntityName=list.signingEntityName;
validateApiResponse("company/getCompanyByName.json",response)
});
});

it("Returns the CLA Groups associated with the Project and Company", function () {
cy.request({
method: 'GET',
url: `${claEndpoint}${companyExternalID}/project/${projectSFID}/cla`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
let list=response.body.list;
if (list[0].signed_cla_list.length > 0 &&'cla_group_id' in list[0].signed_cla_list[0]) {
claGroupId=list[0].signed_cla_list[0].cla_group_id;
}else{
claGroupId=list[0].unsigned_project_list[0].cla_group_id;
}
});
});

it("Get list of CLA managers based on the CLA Group and v1 Company ID", function () {
cy.request({
method: 'GET',
url: `${claEndpoint}${companyID}/cla-group/${claGroupId}/cla-managers`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
});
});

it("Get active CLA list of company for particular project/foundation", function () {
cy.request({
method: 'GET',
url: `${claEndpoint}${companyID}/project/${projectSFID}/active-cla-list`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
});
});

it("Get CLA manager of company for particular project/foundation", function () {
cy.request({
method: 'GET',
url: `${claEndpoint}${companyID}/project/${projectSFID}/cla-managers`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
});
});

it("Get corporate contributors for project", function () {
cy.request({
method: 'GET',
url: `${claEndpoint}${companyID}/project/${projectSFID}/contributors`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
validateApiResponse("company/getCompanyProjectContributors.json",response)
});
});

it("Returns a list of Company Admins (salesforce)", function () {
cy.request({
method: 'GET',
url: `${claEndpoint}${companyExternalID}/admin`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
validateApiResponse("company/getCompanyAdmins.json",response)
});
});

it.skip("Associates a contributor with a company", function () {
cy.request({
method: 'POST',
url: `${claEndpoint}${companyExternalID}/contributorAssociation`,
auth: {
'bearer': bearerToken,
},
body:{

"userEmail": "[email protected]"
}
}).then((response) => {
validate_200_Status(response);
validateApiResponse("company/getCompanyAdmins.json",response)
});
});

it("Creates a new salesforce company", function () {
cy.request({
method: 'POST',
url: `${claBaseEndpoint}user/${user_id}/company`,
auth: {
'bearer': bearerToken,
},
body:{
"companyName": "lfx dev Test",
"companyWebsite": "https://lfxdevtest.org",
"note": "Added via automation",
"signingEntityName": "lfx dev Test",
"userEmail": userEmail
}
}).then((response) => {
validate_200_Status(response);
companyName="lfx dev Test";
companyID=response.body.companyID;
getCompanyByName();
});
});

it.skip("Deletes the company by the SFID", function () {
cy.request({
method: 'DELETE',
url: `${claEndpoint}sfid/${companyExternalID}`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
expect(response.status).to.eq(204);
});
});

it.skip("Deletes the company by ID", function () {
cy.request({
method: 'DELETE',
url: `${claEndpoint}id/${companyID}`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
expect(response.status).to.eq(204);
});
});

it.skip("Request Company Admin based on user request to sign CLA", function () {
cy.request({
method: 'POST',
url: `${claBaseEndpoint}user/${user_id2}/company`,
auth: {
'bearer': bearerToken,
},
body:{
"claManagerEmail": "[email protected]",
"claManagerName": "veerendra thakur",
"companyName": "Infosys Limited",
"companyWebsite":"wwww.infosys.com",
"contributorEmail": "[email protected]",
"contributorName": "vthakur lfitstaff",
"projectName": "SUN",
"version": "v1"
}
}).then((response) => {
validate_200_Status(response);
companyName="lfx dev Test";
companyID=response.body.companyID;
getCompanyByName();
});
});

function getCompanyByName(){
cy.request({
method: 'GET',
url: `${claEndpoint}name/${companyName}`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
validate_200_Status(response);
let list=response.body;
companyExternalID=list.companyExternalID;
companyID=list.companyID;
signingEntityName=list.signingEntityName;
validateApiResponse("company/getCompanyByName.json",response)
});
}

});


33 changes: 33 additions & 0 deletions tests/functional/cypress/fixtures/company/getCompanyAdmins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"list": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"email": {
"type": "string"
},
"id": {
"type": "string"
},
"username": {
"type": "string"
}
},
"required": [
"email",
"id",
"username"
]
}
]
}
},
"required": [
"list"
]
}
52 changes: 52 additions & 0 deletions tests/functional/cypress/fixtures/company/getCompanyByName.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"companyACL": {
"type": "array",
"items": [
{
"type": "string"
}
]
},
"companyExternalID": {
"type": "string"
},
"companyID": {
"type": "string"
},
"companyManagerID": {
"type": "string"
},
"companyName": {
"type": "string"
},
"created": {
"type": "string"
},
"note": {
"type": "string"
},
"signingEntityName": {
"type": "string"
},
"updated": {
"type": "string"
},
"version": {
"type": "string"
}
},
"required": [
"companyACL",
"companyExternalID",
"companyID",
"companyName",
"created",
"note",
"signingEntityName",
"updated",
"version"
]
}
Loading

0 comments on commit dae00a3

Please sign in to comment.