diff --git a/tests/functional/cypress.config.ts b/tests/functional/cypress.config.ts index 564487f38..06e510d9b 100644 --- a/tests/functional/cypress.config.ts +++ b/tests/functional/cypress.config.ts @@ -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', diff --git a/tests/functional/cypress/e2e/company.spec.ts b/tests/functional/cypress/e2e/company.spec.ts new file mode 100644 index 000000000..5b8267b27 --- /dev/null +++ b/tests/functional/cypress/e2e/company.spec.ts @@ -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";//vthakur+lfstaff@contractor.linuxfoundation.org + const userEmail= "vthakur+lfstaff@contractor.linuxfoundation.org"; + const user_id2="4a4c1dba-407f-11ed-8c58-a6b0f8fb81a9"//vthakur+lfitstaff@contractor.linuxfoundation.org + + 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": "veerendrat@proximabiz.com" + } + }).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": "vthakur@contractor.linuxfoundation.org", + "claManagerName": "veerendra thakur", + "companyName": "Infosys Limited", + "companyWebsite":"wwww.infosys.com", + "contributorEmail": "vthakur+lfitstaff@contractor.linuxfoundation.org", + "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) + }); + } + +}); + + \ No newline at end of file diff --git a/tests/functional/cypress/fixtures/company/getCompanyAdmins.json b/tests/functional/cypress/fixtures/company/getCompanyAdmins.json new file mode 100644 index 000000000..427de7542 --- /dev/null +++ b/tests/functional/cypress/fixtures/company/getCompanyAdmins.json @@ -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" + ] + } \ No newline at end of file diff --git a/tests/functional/cypress/fixtures/company/getCompanyByName.json b/tests/functional/cypress/fixtures/company/getCompanyByName.json new file mode 100644 index 000000000..a5333d70d --- /dev/null +++ b/tests/functional/cypress/fixtures/company/getCompanyByName.json @@ -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" + ] + } \ No newline at end of file diff --git a/tests/functional/cypress/fixtures/company/getCompanyProjectActiveCla.json b/tests/functional/cypress/fixtures/company/getCompanyProjectActiveCla.json new file mode 100644 index 000000000..7f5a560a0 --- /dev/null +++ b/tests/functional/cypress/fixtures/company/getCompanyProjectActiveCla.json @@ -0,0 +1,111 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "list": { + "type": "array", + "items": [ + { + "type": "object", + "properties": { + "ccla_url": { + "type": "string" + }, + "cla_group_id": { + "type": "string" + }, + "cla_group_name": { + "type": "string" + }, + "company_id": { + "type": "string" + }, + "company_name": { + "type": "string" + }, + "company_sfid": { + "type": "string" + }, + "project_id": { + "type": "string" + }, + "project_logo": { + "type": "string" + }, + "project_name": { + "type": "string" + }, + "project_sfid": { + "type": "string" + }, + "project_type": { + "type": "string" + }, + "signatory_name": { + "type": "string" + }, + "signature_acl": { + "type": "object", + "properties": { + "username_list": { + "type": "array", + "items": [ + { + "type": "string" + } + ] + } + }, + "required": [ + "username_list" + ] + }, + "signature_id": { + "type": "string" + }, + "signed_on": { + "type": "string" + }, + "signing_entity_id": { + "type": "string" + }, + "signing_entity_name": { + "type": "string" + }, + "sub_projects": { + "type": "array", + "items": [ + { + "type": "string" + } + ] + } + }, + "required": [ + "ccla_url", + "cla_group_id", + "cla_group_name", + "company_id", + "company_name", + "company_sfid", + "project_id", + "project_logo", + "project_name", + "project_sfid", + "project_type", + "signatory_name", + "signature_acl", + "signature_id", + "signed_on", + "signing_entity_id", + "signing_entity_name", + "sub_projects" + ] + } + ] + } + }, + "required": [ + "list" + ] + } \ No newline at end of file diff --git a/tests/functional/cypress/fixtures/company/getCompanyProjectContributors.json b/tests/functional/cypress/fixtures/company/getCompanyProjectContributors.json new file mode 100644 index 000000000..baa1df66c --- /dev/null +++ b/tests/functional/cypress/fixtures/company/getCompanyProjectContributors.json @@ -0,0 +1,77 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "list": { + "type": "array", + "items": [ + { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "github_id": { + "type": "string" + }, + "linux_foundation_id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "signatureApproved": { + "type": "boolean" + }, + "signatureID": { + "type": "string" + }, + "signatureModified": { + "type": "string" + }, + "signatureSigned": { + "type": "boolean" + }, + "signature_version": { + "type": "string" + }, + "timestamp": { + "type": "string" + }, + "userDocusignDateSigned": { + "type": "string" + }, + "userDocusignName": { + "type": "string" + } + }, + "required": [ + "email", + "github_id", + "linux_foundation_id", + "name", + "signatureApproved", + "signatureID", + "signatureSigned", + "signature_version", + "timestamp" + ] + } + ] + }, + "nextKey": { + "type": "string" + }, + "resultCount": { + "type": "integer" + }, + "totalCount": { + "type": "integer" + } + }, + "required": [ + "list", + "resultCount", + "totalCount" + ] + } \ No newline at end of file diff --git a/tests/functional/cypress/fixtures/company/searchCompanyLookup.json b/tests/functional/cypress/fixtures/company/searchCompanyLookup.json new file mode 100644 index 000000000..d845d55c6 --- /dev/null +++ b/tests/functional/cypress/fixtures/company/searchCompanyLookup.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "Employees": { + "type": "string" + }, + "ID": { + "type": "string" + }, + "Industry": { + "type": "string" + }, + "Link": { + "type": "string" + }, + "Name": { + "type": "string" + }, + "Sector": { + "type": "string" + }, + "Source": { + "type": "string" + } + + + + }, + "required": [ + "Employees", + "ID", + "Link", + "Name" + ] + } \ No newline at end of file diff --git a/tests/functional/cypress/support/commands.js b/tests/functional/cypress/support/commands.js index 9ffaf04e8..7c5ee2b94 100644 --- a/tests/functional/cypress/support/commands.js +++ b/tests/functional/cypress/support/commands.js @@ -48,4 +48,4 @@ export function getTokenKey(){ win.localStorage.setItem('bearerToken', response.body.access_token); }); }); -}; \ No newline at end of file +};