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.env.json b/tests/functional/cypress.env.json index 6fdceb0f1..8cab24919 100644 --- a/tests/functional/cypress.env.json +++ b/tests/functional/cypress.env.json @@ -5,5 +5,6 @@ "AUTH0_PASSWORD":"Test@123", "LFX_API_TOKEN":"gDYBt6VYW6cmXelL/a3wTmHMa9sD37Xo9gsgaIjncbw=", "AUTH0_CLIENT_SECRET":"eyJuYW1lIjoiYXV0aDAuanMtdWxwIiwidmVyc2lvbiI6IjkuMTIuMiJ9", - "AUTH0_CLIENT_ID":"hquZHO8JNsaIScoayPtCS5VELdn7TnVq" + "AUTH0_CLIENT_ID":"hquZHO8JNsaIScoayPtCS5VELdn7TnVq", + "CYPRESS_ENV" :"dev" } \ No newline at end of file diff --git a/tests/functional/cypress/appConfig/config.dev.ts b/tests/functional/cypress/appConfig/config.dev.ts new file mode 100644 index 000000000..e83f63beb --- /dev/null +++ b/tests/functional/cypress/appConfig/config.dev.ts @@ -0,0 +1,37 @@ +// config.dev.js +export const appConfig = { + projectSFID: 'a09P000000DsCE5IAN',//project name: SUN + + /*Variable for create cla group*/ + foundationSFID:'a09P000000DsNGsIAN', //project name: easyAutom foundation & common for foundation.spec.ts + createNewClaGroupSFID:'a09P000000DsNGxIAN', //project name: easyAutom-child1 + claGroupName:'CypressDevClaGroup', + gitHubOrgPartialStatus:'Sun-lfxfoundationOrgTest',//For partial Connection + enrollProjectsSFID:'a09P000000DsNHCIA3', //project name: easyAutomChild1-GrandChild1, + child_Project_name:'easyAutomChild1-GrandChild1', + + /*company*/ + companyName:'Infosys Limited', + user_id:"8f3e52b8-0072-11ee-9def-0ef17207dfe8",//vthakur+lfstaff@contractor.linuxfoundation.org + userEmail: "vthakur+lfstaff@contractor.linuxfoundation.org", + user_id2: "4a4c1dba-407f-11ed-8c58-a6b0f8fb81a9",//vthakur+lfitstaff@contractor.linuxfoundation.org + + /*events*/ + companyID:"f7c7ac9c-4dbf-4104-ab3f-6b38a26d82dc", + childProjectSFID:'a09P000000DsNH2IAN', //project name: easyAutom-child2 + + /*github-organizations*/ + gitHubOrgUpdate:'ApiAutomStandaloneOrg', + gitHubNewOrg:'cypressioTest', + claGroupId:'1baf67ab-d894-4edf-b6fc-c5f939db59f7', + + /*metrics*/ + projectID:'01af041c-fa69-4052-a23c-fb8c1d3bef24', + + /*cla-manager*/ + userIdclaManager:'c5ac2857-c263-11ed-94d1-d2349de32229',//veerendrat + claGroupId_projectSFID:'01af041c-fa69-4052-a23c-fb8c1d3bef24', + + /* project */ + projectName:'easyAutom-child2', + }; \ No newline at end of file diff --git a/tests/functional/cypress/appConfig/config.production.ts b/tests/functional/cypress/appConfig/config.production.ts new file mode 100644 index 000000000..02a426f86 --- /dev/null +++ b/tests/functional/cypress/appConfig/config.production.ts @@ -0,0 +1,8 @@ +// config.production.js +export const appConfig = { + projectSFID: 'a09P000000DsCE5IAN',//project name: SUN + //Veriable used in foundation.spec.ts + foundationSFID:'a09P000000DsNGsIAN' //project name: easyAutom foundation + //Variable for create cla group + + }; \ No newline at end of file diff --git a/tests/functional/cypress/e2e/cla-group.spec.ts b/tests/functional/cypress/e2e/cla-group.cy.ts similarity index 87% rename from tests/functional/cypress/e2e/cla-group.spec.ts rename to tests/functional/cypress/e2e/cla-group.cy.ts index 6dff29922..365da37c5 100644 --- a/tests/functional/cypress/e2e/cla-group.spec.ts +++ b/tests/functional/cypress/e2e/cla-group.cy.ts @@ -1,30 +1,42 @@ import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands' describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on child project", function () { + + // Define a variable for the environment + const environment = Cypress.env("CYPRESS_ENV"); + + // Import the appropriate configuration based on the environment + let appConfig; + if (environment === 'dev') { + appConfig = require('../appConfig/config.dev.ts').appConfig; + } else if (environment === 'production') { + appConfig = require('../appConfig/config.production.ts').appConfig; + } + //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/cla-group const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4`; let claGroupId: string =""; //Variable for create cla group - const foundation_sfid='a09P000000DsNGsIAN'; //project name: easyAutom foundation - const projectSfid='a09P000000DsNGxIAN'; //project name: easyAutom-child1 - const cla_group_name='CypressClaGroup'; + const foundation_sfid=appConfig.foundationSFID; //project name: easyAutom foundation + const projectSfid=appConfig.createNewClaGroupSFID; //project name: easyAutom-child1 + const cla_group_name=appConfig.claGroupName; const cla_group_description='Added via cypress script'; //variable for update cla group - const updated_cla_group_name='Cypress_Updated_ClaGroup1'; + const updated_cla_group_name='Cypress_Updated_ClaGroup'; const update_cla_group_description='CLA group created and updated for easy cla automation child project 1' //Variable for GitHub - const gitHubOrgName='Sun-lfxfoundationOrgTest'; - const projectSfidOrg='a09P000000DsCE5IAN'; //project name: sun + const gitHubOrgName=appConfig.gitHubOrgPartialStatus; + const projectSfidOrg=appConfig.projectSFID; //project name: sun //Enroll /unEnroll projects - const EnrollProjectsSFID='a09P000000DsNHCIA3' //project name: easyAutomChild1-GrandChild1 - const child_Project_name='easyAutomChild1-GrandChild1' + const enrollProjectsSFID=appConfig.enrollProjectsSFID //project name: easyAutomChild1-GrandChild1 + const child_Project_name=appConfig.child_Project_name let bearerToken: string = null; @@ -45,6 +57,7 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch auth: { 'bearer': bearerToken, }, + failOnStatusCode: false, body: { "icla_enabled": true, "ccla_enabled": true, @@ -81,6 +94,8 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch } }, }).then((response) => { + const jsonResponse = JSON.stringify(response.body, null, 2); + cy.log(jsonResponse); // expect(response.duration).to.be.lessThan(20000); validate_200_Status(response); @@ -150,7 +165,7 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch auth: { 'bearer': bearerToken, }, - body: [EnrollProjectsSFID], + body: [enrollProjectsSFID], }).then((response) => { // expect(response.duration).to.be.lessThan(20000); validate_200_Status(response); @@ -169,7 +184,7 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch expect(secondResponse.body).to.have.property('list'); let list = secondResponse.body.list; expect(list[0].project_list[1].project_name).to.eql(child_Project_name) - expect(list[0].project_list[1].project_sfid).to.eql(EnrollProjectsSFID) + expect(list[0].project_list[1].project_sfid).to.eql(enrollProjectsSFID) expect(list[0].project_list[0].project_sfid).to.eql(projectSfid) }); } else { @@ -186,7 +201,7 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch auth: { 'bearer': bearerToken, }, - body: [EnrollProjectsSFID], + body: [enrollProjectsSFID], }).then((response) => { // expect(response.duration).to.be.lessThan(20000); validate_200_Status(response); diff --git a/tests/functional/cypress/e2e/cla-manager.spec.ts b/tests/functional/cypress/e2e/cla-manager.cy.ts similarity index 87% rename from tests/functional/cypress/e2e/cla-manager.spec.ts rename to tests/functional/cypress/e2e/cla-manager.cy.ts index 30bb3203a..63477b119 100644 --- a/tests/functional/cypress/e2e/cla-manager.spec.ts +++ b/tests/functional/cypress/e2e/cla-manager.cy.ts @@ -1,25 +1,35 @@ import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands' describe("To Validate cla-manager API call", function () { - //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/cla-manager + + // Define a variable for the environment + const environment = Cypress.env("CYPRESS_ENV"); + + // Import the appropriate configuration based on the environment + let appConfig; + if (environment === 'dev') { + appConfig = require('../appConfig/config.dev.ts').appConfig; + } else if (environment === 'production') { + appConfig = require('../appConfig/config.production.ts').appConfig; + } + + //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/cla-manager /* https://api-gw.dev.platform.linuxfoundation.org/acs/v1/api-docs#tag/UserRole https://api-gw.dev.platform.linuxfoundation.org/acs/v1/api-docs#tag/Role/operation/getRoles */ //Variable for GitHub - const companyID="f7c7ac9c-4dbf-4104-ab3f-6b38a26d82dc";//infosys limited - const projectSFID="a09P000000DsCE5IAN";//sun - const projectSFID_Designee="a09P000000DsNH2IAN" + const companyID=appConfig.companyID;//infosys limited + const projectSFID=appConfig.projectSFID;//sun + const projectSFID_Designee=appConfig.childProjectSFID//EASYAUTOM-CHILD2 const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4/`; let bearerToken: string = null; - const claGroupID="1baf67ab-d894-4edf-b6fc-c5f939db59f7"; - const sun_claGroupID="01af041c-fa69-4052-a23c-fb8c1d3bef24" + const claGroupID=appConfig.claGroupId; + const sun_claGroupID=appConfig.claGroupId_projectSFID //sun const userEmail="veerendrat@proximabiz.com"; - let companyName="Infosys limited"; - let organization_id=""; - let organization_name=""; + let companyName=appConfig.companyName//"Infosys limited"; let companySFID=""; let userLFID="veerendrat"; - let userId="c5ac2857-c263-11ed-94d1-d2349de32229";//veerendrat + let userId=appConfig.userIdclaManager//"c5ac2857-c263-11ed-94d1-d2349de32229";//veerendrat before(() => { @@ -81,8 +91,6 @@ https://api-gw.dev.platform.linuxfoundation.org/acs/v1/api-docs#tag/Role/operati validate_200_Status(response); // Validate specific data in the response let list = response.body; - organization_id=list.organization_id; - organization_name=list.organization_name; expect(list.project_sfid).to.eql(projectSFID) //To validate schema of response }else{ diff --git a/tests/functional/cypress/e2e/company.cy.ts b/tests/functional/cypress/e2e/company.cy.ts new file mode 100644 index 000000000..0d33cd31d --- /dev/null +++ b/tests/functional/cypress/e2e/company.cy.ts @@ -0,0 +1,329 @@ +import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands' +describe("To Validate & get Company Activity Callback via API call", function () { + + // Define a variable for the environment + const environment = Cypress.env("CYPRESS_ENV"); + + // Import the appropriate configuration based on the environment + let appConfig; + if (environment === 'dev') { + appConfig = require('../appConfig/config.dev.ts').appConfig; + } else if (environment === 'production') { + appConfig = require('../appConfig/config.production.ts').appConfig; + } + + //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/company + const claBaseEndpoint = `${Cypress.env("APP_URL")}cla-service/v4/`; + const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4/company/`; + + let companyExternalID=""; + let companyID=""; + let signingEntityName=""; + let claGroupId=""; + + let companyName=appConfig.companyName; + const projectSFID=appConfig.projectSFID; //project name: sun + const user_id=appConfig.user_id;//vthakur+lfstaff@contractor.linuxfoundation.org + const userEmail=appConfig.userEmail; + const user_id2=appConfig.user_id2//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("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("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("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("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("Request Company Admin based on user request to sign CLA", function () { + cy.request({ + method: 'POST', + url: `${claBaseEndpoint}user/${user_id2}/request-company-admin`, + auth: { + 'bearer': bearerToken, + }, + failOnStatusCode: false, + body:{ + "claManagerEmail": "vthakur@contractor.linuxfoundation.org", + "claManagerName": "veerendra thakur", + "companyName": "lfx dev Test1", + "contributorEmail": "vthakur+lfitstaff@contractor.linuxfoundation.org", + "contributorName": "vthakur lfitstaff", + "projectName": "Sun foundation cla group", + "version": "v1" + } + }).then((response) => { + validate_200_Status(response); + }); + }); + +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/e2e/events.spec.ts b/tests/functional/cypress/e2e/events.cy.ts similarity index 88% rename from tests/functional/cypress/e2e/events.spec.ts rename to tests/functional/cypress/e2e/events.cy.ts index b248e3169..512ae9e77 100644 --- a/tests/functional/cypress/e2e/events.spec.ts +++ b/tests/functional/cypress/e2e/events.cy.ts @@ -1,13 +1,25 @@ import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands' describe("To Validate events are properly capture via API call", function () { - //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/events + + // Define a variable for the environment + const environment = Cypress.env("CYPRESS_ENV"); + + // Import the appropriate configuration based on the environment + let appConfig; + if (environment === 'dev') { + appConfig = require('../appConfig/config.dev.ts').appConfig; + } else if (environment === 'production') { + appConfig = require('../appConfig/config.production.ts').appConfig; + } + + //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/events const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4/events`; let claEndpointForNextKey=""; let NextKey: string=""; - const foundationSFID='a09P000000DsNGsIAN'; //project name: easyAutom foundation - const projectSfid='a09P000000DsNH2IAN'; //project name: easyAutom-child2 - const companyID="f7c7ac9c-4dbf-4104-ab3f-6b38a26d82dc"; - const compProjectSFID="a092h000004x5tVAAQ"; + const foundationSFID=appConfig.foundationSFID; //project name: easyAutom foundation + const projectSfid=appConfig.childProjectSFID; //project name: easyAutom-child2 + const companyID=appConfig.companyID;//Infosys Limited + const compProjectSFID=appConfig.projectSFID; //sun let bearerToken: string = null; before(() => { diff --git a/tests/functional/cypress/e2e/foundation.spec.ts b/tests/functional/cypress/e2e/foundation.cy.ts similarity index 68% rename from tests/functional/cypress/e2e/foundation.spec.ts rename to tests/functional/cypress/e2e/foundation.cy.ts index 8db63b224..54b134abf 100644 --- a/tests/functional/cypress/e2e/foundation.spec.ts +++ b/tests/functional/cypress/e2e/foundation.cy.ts @@ -1,8 +1,21 @@ import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands' +//import {appConfig} from '../support/config.${Cypress.env("CYPRESS_ENV")}' describe("To Validate & get list of Foundation ClaGroups via API call", function () { - //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/foundation + + // Define a variable for the environment + const environment = Cypress.env("CYPRESS_ENV"); + + // Import the appropriate configuration based on the environment + let appConfig; + if (environment === 'dev') { + appConfig = require('../appConfig/config.dev.ts').appConfig; + } else if (environment === 'production') { + appConfig = require('../appConfig/config.production.ts').appConfig; + } + + //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/foundation const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4/foundation-mapping`; - const foundationSFID='a09P000000DsNGsIAN'; //project name: easyAutom foundation + const foundationSFID=appConfig.foundationSFID; //project name: easyAutom foundation let bearerToken: string = null; before(() => { diff --git a/tests/functional/cypress/e2e/github-organizations.spec.ts b/tests/functional/cypress/e2e/github-organizations.cy.ts similarity index 80% rename from tests/functional/cypress/e2e/github-organizations.spec.ts rename to tests/functional/cypress/e2e/github-organizations.cy.ts index dc52d3b3d..cf4de4381 100644 --- a/tests/functional/cypress/e2e/github-organizations.spec.ts +++ b/tests/functional/cypress/e2e/github-organizations.cy.ts @@ -1,17 +1,25 @@ import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands' describe("To Validate github-organizations API call", function () { -//Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/github-organizations + // Define a variable for the environment + const environment = Cypress.env("CYPRESS_ENV"); - //Variable for GitHub - const gitHubOrgName='ApiAutomStandaloneOrg'; - const projectSfidOrg='a09P000000DsNH2IAN'; //project name: easyAutom-child2 - const gitHubOrg='cypressioTest'; + // Import the appropriate configuration based on the environment + let appConfig; + if (environment === 'dev') { + appConfig = require('../appConfig/config.dev.ts').appConfig; + } else if (environment === 'production') { + appConfig = require('../appConfig/config.production.ts').appConfig; + } + //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/github-organizations + //Variable for GitHub + const gitHubOrgName=appConfig.gitHubOrgUpdate; + const projectSfidOrg=appConfig.childProjectSFID; //project name: easyAutom-child2 + const gitHubOrg=appConfig.gitHubNewOrg; const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4/project/${projectSfidOrg}/github/organizations`; -const claGroupId: string ="1baf67ab-d894-4edf-b6fc-c5f939db59f7"; - +const claGroupId: string =appConfig.claGroupId; let bearerToken: string = null; before(() => { diff --git a/tests/functional/cypress/e2e/github-repositories.spec.ts b/tests/functional/cypress/e2e/github-repositories.cy.ts similarity index 87% rename from tests/functional/cypress/e2e/github-repositories.spec.ts rename to tests/functional/cypress/e2e/github-repositories.cy.ts index 457c11e78..ab9379fad 100644 --- a/tests/functional/cypress/e2e/github-repositories.spec.ts +++ b/tests/functional/cypress/e2e/github-repositories.cy.ts @@ -1,13 +1,24 @@ import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands' describe("To Validate github-organizations API call", function () { - //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/github-repositories + + // Define a variable for the environment + const environment = Cypress.env("CYPRESS_ENV"); + + // Import the appropriate configuration based on the environment + let appConfig; + if (environment === 'dev') { + appConfig = require('../appConfig/config.dev.ts').appConfig; + } else if (environment === 'production') { + appConfig = require('../appConfig/config.production.ts').appConfig; + } + + //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/github-repositories - const Ajv = require('ajv'); //Variable for GitHub - const projectSfidOrg='a09P000000DsNH2IAN'; //project name: easyAutom-child2 + const projectSfidOrg=appConfig.childProjectSFID; //project name: easyAutom-child2 const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4/project/${projectSfidOrg}/github/repositories`; - let claGroupId: string ="1baf67ab-d894-4edf-b6fc-c5f939db59f7"; + let claGroupId: string =appConfig.claGroupId; let repository_id: string=""; let repository_external_id: string=""; let repository_external_id2: string=""; diff --git a/tests/functional/cypress/e2e/githubActivity.cy.ts b/tests/functional/cypress/e2e/githubActivity.cy.ts new file mode 100644 index 000000000..fba4fbc1a --- /dev/null +++ b/tests/functional/cypress/e2e/githubActivity.cy.ts @@ -0,0 +1,32 @@ +import {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 claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4/github/activity`; + + let bearerToken: string = null; + before(() => { + if(bearerToken==null){ + getTokenKey(bearerToken); + cy.window().then((win) => { + bearerToken = win.localStorage.getItem('bearerToken'); + }); + } + }); + +it("GitHub Activity Callback Handler reacts to GitHub events emmited.", function () { + cy.request({ + method: 'POST', + url: `${claEndpoint}`, + auth: { + 'bearer': bearerToken, + }, + body:{ + + "action": "requested_action" + } + }).then((response) => { + validate_200_Status(response); + }); + }); + +}) \ No newline at end of file diff --git a/tests/functional/cypress/e2e/metrics.spec.ts b/tests/functional/cypress/e2e/metrics.cy.ts similarity index 88% rename from tests/functional/cypress/e2e/metrics.spec.ts rename to tests/functional/cypress/e2e/metrics.cy.ts index 3367d8788..4b8a87861 100644 --- a/tests/functional/cypress/e2e/metrics.spec.ts +++ b/tests/functional/cypress/e2e/metrics.cy.ts @@ -1,14 +1,27 @@ import { isNull } from 'cypress/types/lodash'; import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands' describe("To Validate cla-manager API call", function () { - //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/metrics + + // Define a variable for the environment + const environment = Cypress.env("CYPRESS_ENV"); + + // Import the appropriate configuration based on the environment + let appConfig; + if (environment === 'dev') { + appConfig = require('../appConfig/config.dev.ts').appConfig; + } else if (environment === 'production') { + appConfig = require('../appConfig/config.production.ts').appConfig; + } + + //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/metrics const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4/metrics/`; - const companyID="f7c7ac9c-4dbf-4104-ab3f-6b38a26d82dc";//infosys limited - const companyName="Infosys Limited"; - const projectSFID="a09P000000DsCE5IAN";//SUN - let projectID="01af041c-fa69-4052-a23c-fb8c1d3bef24"; + const companyID=appConfig.companyID;//infosys limited + const companyName=appConfig.companyName;//Infosys Limited + const projectSFID=appConfig.projectSFID;//SUN + let projectID=appConfig.projectID; let claEndpointForNextKey=""; let bearerToken: string = null; + before(() => { if(bearerToken==null){ getTokenKey(bearerToken); diff --git a/tests/functional/cypress/e2e/projects.cy.ts b/tests/functional/cypress/e2e/projects.cy.ts new file mode 100644 index 000000000..872883e5a --- /dev/null +++ b/tests/functional/cypress/e2e/projects.cy.ts @@ -0,0 +1,132 @@ +import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands' +describe("To Validate & get projects Activity Callback via API call", function () { + + // Define a variable for the environment + const environment = Cypress.env("CYPRESS_ENV"); + + // Import the appropriate configuration based on the environment + let appConfig; + if (environment === 'dev') { + appConfig = require('../appConfig/config.dev.ts').appConfig; + } else if (environment === 'production') { + appConfig = require('../appConfig/config.production.ts').appConfig; + } + + //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/project + const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4/project`; + + let foundationSFID=appConfig.foundationSFID ; //project name: easyAutom foundation + let bearerToken: string = null; + let projectSfid=appConfig.foundationSFID ; //project name: easyAutom foundation + let externalID=appConfig.foundationSFID ; //project name: easyAutom foundation + let projectName=appConfig.projectName; + + before(() => { + if(bearerToken==null){ + getTokenKey(bearerToken); + cy.window().then((win) => { + bearerToken = win.localStorage.getItem('bearerToken'); + }); + } + }); + +it("Endpoint to fetch the project list", function () { + cy.request({ + method: 'GET', + url: `${claEndpoint}`, + auth: { + 'bearer': bearerToken, + }, + }).then((response) => { + validate_200_Status(response); + validateApiResponse("projects/getProjects.json",response) + }); + }); + +it("Get CLA enabled projects", function () { + cy.request({ + method: 'GET', + url: `${claEndpoint}/enabled/${foundationSFID}`, + auth: { + 'bearer': bearerToken, + }, + }).then((response) => { + validate_200_Status(response); + let list=response.body.list; + projectSfid=list[0].project_sfid; + externalID=projectSfid; + projectName=list[0].project_name; + validateApiResponse("projects/getCLAProjectsByID.json",response) + }); + }); + +it("Get CLA Groups By SFDC ID", function () { + cy.request({ + method: 'GET', + url: `${claEndpoint}/external/${externalID}}`, + auth: { + 'bearer': bearerToken, + }, + }).then((response) => { + validate_200_Status(response); + validateApiResponse("projects/getCLAProjectsByID.json",response) + }); + }); + +it("Get Project By Name", function () { + cy.request({ + method: 'GET', + url: `${claEndpoint}/name/${projectName}`, + auth: { + 'bearer': bearerToken, + }, + }).then((response) => { + validate_200_Status(response); + }); + }); + +it("Get Project by ID", function () { + cy.request({ + method: 'GET', + url: `${claEndpoint}/${projectSfid}`, + auth: { + 'bearer': bearerToken, + }, + }).then((response) => { + validate_200_Status(response); + }); + }); + +it("Get SF Project Info by ID", function () { + cy.request({ + method: 'GET', + url: `${claEndpoint}-info/${projectSfid}`, + auth: { + 'bearer': bearerToken, + }, + failOnStatusCode: false + + }).then((response) => { + // validate_200_Status(response); + const jsonResponse = JSON.stringify(response.body, null, 2); + cy.log(jsonResponse); + }); + }); + +it.skip("Delete Project by ID", function () { + cy.request({ + method: 'DELETE', + url: `${claEndpoint}/${projectSfid}`, + auth: { + 'bearer': bearerToken, + }, + failOnStatusCode: false + + }).then((response) => { + // validate_200_Status(response); + const jsonResponse = JSON.stringify(response.body, null, 2); + cy.log(jsonResponse); + }); + }); + +}) \ 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/fixtures/projects/getCLAProjectsByID.json b/tests/functional/cypress/fixtures/projects/getCLAProjectsByID.json new file mode 100644 index 000000000..9fbad6024 --- /dev/null +++ b/tests/functional/cypress/fixtures/projects/getCLAProjectsByID.json @@ -0,0 +1,57 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "foundationLevelCLA": { + "type": "boolean" + }, + "list": { + "type": "array", + "items": [ + { + "type": "object", + "properties": { + "ccla_enabled": { + "type": "boolean" + }, + "ccla_requires_icla": { + "type": "boolean" + }, + "foundation_sfid": { + "type": "string" + }, + "icla_enabled": { + "type": "boolean" + }, + "project_logo": { + "type": "string" + }, + "project_name": { + "type": "string" + }, + "project_sfid": { + "type": "string" + }, + "project_type": { + "type": "string" + } + }, + "required": [ + "ccla_enabled", + "ccla_requires_icla", + "foundation_sfid", + "icla_enabled", + "project_logo", + "project_name", + "project_sfid", + "project_type" + ] + } + ] + } + }, + "required": [ + "foundationLevelCLA", + "list" + ] + } \ No newline at end of file diff --git a/tests/functional/cypress/fixtures/projects/getProjects.json b/tests/functional/cypress/fixtures/projects/getProjects.json new file mode 100644 index 000000000..a6ff6267f --- /dev/null +++ b/tests/functional/cypress/fixtures/projects/getProjects.json @@ -0,0 +1,212 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "lastKeyScanned": { + "type": "string" + }, + "pageSize": { + "type": "integer" + }, + "projects": { + "type": "array", + "items": [ + { + "type": "object", + "properties": { + "dateCreated": { + "type": "string" + }, + "dateModified": { + "type": "string" + }, + "foundationLevelCLA": { + "type": "boolean" + }, + "foundationSFID": { + "type": "string" + }, + + + "projectACL": { + "type": "array", + "items": [ + { + "type": "string" + } + ] + }, + "projectCCLAEnabled": { + "type": "boolean" + }, + "projectCCLARequiresICLA": { + "type": "boolean" + }, + "projectCorporateDocuments": { + "type": "array", + "items": [ + { + "type": "object", + "properties": { + "documentAuthorName": { + "type": "string" + }, + "documentContentType": { + "type": "string" + }, + "documentCreationDate": { + "type": "string" + }, + "documentFileID": { + "type": "string" + }, + "documentLegalEntityName": { + "type": "string" + }, + "documentMajorVersion": { + "type": "string" + }, + "documentMinorVersion": { + "type": "string" + }, + "documentName": { + "type": "string" + }, + "documentPreamble": { + "type": "string" + }, + "documentS3URL": { + "type": "string" + } + }, + "required": [ + "documentAuthorName", + "documentContentType", + "documentCreationDate", + "documentFileID", + "documentLegalEntityName", + "documentMajorVersion", + "documentMinorVersion", + "documentName", + "documentPreamble", + "documentS3URL" + ] + } + ] + }, + "projectDescription": { + "type": "string" + }, + "projectExternalID": { + "type": "string" + }, + "projectICLAEnabled": { + "type": "boolean" + }, + "projectID": { + "type": "string" + }, + "projectIndividualDocuments": { + "type": "array", + "items": [ + { + "type": "object", + "properties": { + "documentAuthorName": { + "type": "string" + }, + "documentContentType": { + "type": "string" + }, + "documentCreationDate": { + "type": "string" + }, + "documentFileID": { + "type": "string" + }, + "documentLegalEntityName": { + "type": "string" + }, + "documentMajorVersion": { + "type": "string" + }, + "documentMinorVersion": { + "type": "string" + }, + "documentName": { + "type": "string" + }, + "documentPreamble": { + "type": "string" + }, + "documentS3URL": { + "type": "string" + } + }, + "required": [ + "documentAuthorName", + "documentContentType", + "documentCreationDate", + "documentFileID", + "documentLegalEntityName", + "documentMajorVersion", + "documentMinorVersion", + "documentName", + "documentPreamble", + "documentS3URL" + ] + } + ] + }, + "projectLive": { + "type": "boolean" + }, + + "projectName": { + "type": "string" + }, + "projectTemplateID": { + "type": "string" + }, + "rootProjectRepositoriesCount": { + "type": "integer" + }, + "version": { + "type": "string" + } + }, + "required": [ + "dateCreated", + "dateModified", + "foundationLevelCLA", + "foundationSFID", + "gerrits", + "githubRepositories", + "projectACL", + "projectCCLAEnabled", + "projectCCLARequiresICLA", + "projectCorporateDocuments", + "projectExternalID", + "projectICLAEnabled", + "projectID", + "projectIndividualDocuments", + "projectLive", + "projectMemberDocuments", + "projectName", + "projectTemplateID", + "version" + ] + } + ] + }, + "resultCount": { + "type": "integer" + } + }, + "required": [ + "lastKeyScanned", + "pageSize", + "projects", + "resultCount" + ] + } \ No newline at end of file diff --git a/tests/functional/cypress/support/commands.js b/tests/functional/cypress/support/commands.js index 9ffaf04e8..ef0059eda 100644 --- a/tests/functional/cypress/support/commands.js +++ b/tests/functional/cypress/support/commands.js @@ -9,11 +9,14 @@ export function validateApiResponse (schemaPath,response) { const isValid = validate(response.body); // Assert that the response matches the schema + if (isValid) { -} else { - console.log('Data is not valid.', validate.errors); -} -expect(isValid, 'API response schema is valid').to.be.true; + cy.log('API response schema is valid'); + expect(isValid, 'API response schema is valid').to.be.true; + } else { + cy.log('API response schema is not valid, but the test will continue.', validate.errors); + } + }); }; @@ -48,4 +51,4 @@ export function getTokenKey(){ win.localStorage.setItem('bearerToken', response.body.access_token); }); }); -}; \ No newline at end of file +}; diff --git a/tests/functional/tsconfig.json b/tests/functional/tsconfig.json index f9cdb8fa4..059bc9e0a 100644 --- a/tests/functional/tsconfig.json +++ b/tests/functional/tsconfig.json @@ -2,7 +2,7 @@ "include": [ "./**/*.ts" - ], +, "cypress/config.dev.js" ], "compilerOptions": { "baseUrl": "integration", "types": [