Skip to content

Commit aeebdae

Browse files
Merge pull request #4783 from linuxfoundation/unicron-4762-cypress-apis-test-coverage-4
Fixing test coverage #4762
2 parents 27f7d4b + f4b4afa commit aeebdae

File tree

4 files changed

+126
-66
lines changed

4 files changed

+126
-66
lines changed

BOT_ALLOWLIST.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ To add first `skip_cla` value for an organization:
146146
```
147147
aws --profile lfproduct-prod --region us-east-1 dynamodb update-item --table-name "cla-prod-github-orgs" --key '{"organization_name": {"S": "open-telemetry"}}' --update-expression 'SET skip_cla = :val' --expression-attribute-values '{":val": {"M": {"otel-arrow":{"S":";re:^\\d+\\+Copilot@users\\.noreply\\.github\\.com$;copilot-swe-agent[bot]"}}}}'
148148
aws --profile lfproduct-prod --region us-east-1 dynamodb update-item --table-name "cla-prod-github-orgs" --key '{"organization_name": {"S": "openfga"}}' --update-expression 'SET skip_cla = :val' --expression-attribute-values '{":val": {"M": {"vscode-ext":{"S":";re:^\\d+\\+Copilot@users\\.noreply\\.github\\.com$;copilot-swe-agent[bot]"}}}}'
149+
aws --profile lfproduct-prod --region us-east-1 dynamodb update-item --table-name "cla-prod-github-orgs" --key '{"organization_name": {"S": "eslint"}}' --update-expression 'SET skip_cla = :val' --expression-attribute-values '{":val": {"M": {"*":{"S":"[Copilot;re:^\\d+\\+Copilot@users\\.noreply\\.github\\.com$;copilot-swe-agent[bot]||;re:^\\d+\\+Copilot@users\\.noreply\\.github\\.com$;copilot-swe-agent[bot]||Copilot;re:^\\d+\\+copilot@users\\.noreply\\.github\\.com$;Copilot]"}}}}'
149150
```
150151

151152
To add additional repositories entries without overwriting the existing `skip_cla` value:

tests/functional/cypress/appConfig/config.dev.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export const appConfig = {
3838

3939
/* project */
4040
projectName: 'easyAutom-child2',
41+
projectName2: 'child-2-cla-group',
42+
projectSFID2: 'a092h000004wlQQAAY',
43+
projectSFID3: 'a0941000002wBz4AAE',
44+
projectID2: 'e48f8c9f-2d24-4d3f-9123-51eabe34bcc0',
4145

4246
/* GitLab-Organization*/
4347
gitLabOrganizationName: 'sunGitlabGroup',
@@ -58,4 +62,5 @@ export const appConfig = {
5862
gitUsernameApprovalList2: 'lukaszgryglicki',
5963
gitLabOrgApprovalList2: 'https://gitlab.com/lukaszgryglicki',
6064
domainApprovalList2: 'o2.pl',
65+
lfid3: 'vthakur.github',
6166
};

tests/functional/cypress/e2e/projects.cy.ts

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ describe('To Validate & get projects Activity Callback via API call', function (
2323
let foundationSFID = appConfig.foundationSFID; //project name: easyAutom foundation
2424
let bearerToken: string = null;
2525
let projectSfid = appConfig.foundationSFID; //project name: easyAutom foundation
26+
let projectSfid2 = appConfig.projectSFID2;
27+
let projectSfid3 = appConfig.projectSFID3;
28+
let projectId2 = appConfig.projectID2;
2629
let externalID = appConfig.foundationSFID; //project name: easyAutom foundation
2730
let projectName = appConfig.projectName;
31+
let projectName2 = appConfig.projectName2;
2832
let allowFail: boolean = !(Cypress.env('ALLOW_FAIL') === 1);
2933

3034
before(() => {
@@ -63,19 +67,28 @@ describe('To Validate & get projects Activity Callback via API call', function (
6367
bearer: bearerToken,
6468
},
6569
}).then((response) => {
66-
validate_200_Status(response);
67-
let list = response.body.list;
68-
projectSfid = list[0].project_sfid;
69-
externalID = projectSfid;
70-
projectName = list[0].project_name;
71-
validateApiResponse('projects/getCLAProjectsByID.json', response);
70+
return cy.logJson('response', response).then(() => {
71+
validate_200_Status(response);
72+
let list = response.body.list;
73+
let projectItem = list.find((item) => item.project_type === 'Project');
74+
if (!projectItem) {
75+
throw new Error("No project with type 'Project' found in response");
76+
}
77+
projectSfid = projectItem.project_sfid;
78+
externalID = projectSfid;
79+
projectName = projectItem.project_name;
80+
validateApiResponse('projects/getCLAProjectsByID.json', response);
81+
});
7282
});
7383
});
7484

7585
it('Get CLA Groups By SFDC ID', function () {
86+
externalID = appConfig.foundationSFID;
87+
let url = `${claEndpoint}/external/${externalID}`;
88+
cy.task('log', 'Getting project by externalID with URL: ' + url);
7689
cy.request({
7790
method: 'GET',
78-
url: `${claEndpoint}/external/${externalID}`,
91+
url: url,
7992
timeout: 180000,
8093
failOnStatusCode: allowFail,
8194
headers: getXACLHeader(),
@@ -89,49 +102,60 @@ describe('To Validate & get projects Activity Callback via API call', function (
89102
});
90103

91104
it('Get Project By Name', function () {
105+
let url = `${claEndpoint}/name/${projectName2}`;
106+
cy.task('log', 'Getting project by name with URL: ' + url);
92107
cy.request({
93108
method: 'GET',
94-
url: `${claEndpoint}/name/${projectName}`,
109+
url: url,
95110
timeout: 180000,
96111
failOnStatusCode: allowFail,
97112
headers: getXACLHeader(),
98113
auth: {
99114
bearer: bearerToken,
100115
},
101116
}).then((response) => {
102-
validate_200_Status(response);
117+
return cy.logJson('response', response).then(() => {
118+
validate_200_Status(response);
119+
});
103120
});
104121
});
105122

106123
it('Get Project by ID', function () {
124+
let url = `${claEndpoint}/${projectId2}`;
125+
cy.task('log', 'Getting project by ID with URL: ' + url);
107126
cy.request({
108127
method: 'GET',
109-
url: `${claEndpoint}/${projectSfid}`,
128+
url: url,
110129
timeout: 180000,
111130
failOnStatusCode: allowFail,
112131
headers: getXACLHeader(),
113132
auth: {
114133
bearer: bearerToken,
115134
},
116135
}).then((response) => {
117-
validate_200_Status(response);
136+
return cy.logJson('response', response).then(() => {
137+
validate_200_Status(response);
138+
});
118139
});
119140
});
120141

121-
it('Get SF Project Info by ID', function () {
142+
// This endpoint is not used by consumers and is not considered in ACS.
143+
it.skip('Get SF Project Info by ID', function () {
144+
let url = `${claEndpoint}-info/${projectSfid3}`;
145+
cy.task('log', 'Getting project info by ID with URL: ' + url);
122146
cy.request({
123147
method: 'GET',
124-
url: `${claEndpoint}-info/${projectSfid}`,
148+
url: url,
125149
timeout: 180000,
126150
failOnStatusCode: allowFail,
127151
headers: getXACLHeader(),
128152
auth: {
129153
bearer: bearerToken,
130154
},
131155
}).then((response) => {
132-
// validate_200_Status(response);
133-
const jsonResponse = JSON.stringify(response.body, null, 2);
134-
cy.log(jsonResponse);
156+
return cy.logJson('response', response).then(() => {
157+
validate_200_Status(response);
158+
});
135159
});
136160
});
137161

tests/functional/cypress/e2e/signatures.cy.ts

Lines changed: 80 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
2222
const claEndpoint = getAPIBaseURL('v4');
2323
const claGroupID = appConfig.claGroupId_projectSFID; //Sun
2424
const lfid = appConfig.lfid;
25+
const lfid2 = appConfig.lfid2;
26+
const lfid3 = appConfig.lfid3;
2527
const companyID = appConfig.companyID; //Infosys Limited
2628
const companyName = appConfig.companyName; //Infosys Limited
2729
const projectSFID = appConfig.projectSFID; //sun
2830
const userID = appConfig.userIdclaManager; //veerendrat
31+
const userID2 = appConfig.userIdclaManager2;
2932

3033
//Aprroval list veriable
3134
const emailApprovalList = appConfig.emailApprovalList;
@@ -51,50 +54,59 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
5154
});
5255

5356
it('Returns a list of corporate contributor for the CLA Group', function () {
57+
let url = `${claEndpoint}cla-group/${claGroupID}/corporate-contributors?companyID=${companyID}&pageSize=100`;
58+
cy.task('log', 'Returns a list of corporate contributor for the CLA Group URL: ' + url);
5459
cy.request({
5560
method: 'GET',
56-
url: `${claEndpoint}cla-group/${claGroupID}/corporate-contributors?companyID=${companyID}`,
61+
url: url,
5762
failOnStatusCode: allowFail,
5863
headers: getXACLHeader(),
5964
auth: {
6065
bearer: bearerToken,
6166
},
6267
timeout: 180000,
6368
}).then((response) => {
64-
validate_200_Status(response);
65-
let list = response.body.list;
66-
for (let i = 0; i <= list.length - 1; i++) {
67-
if (list[i].linux_foundation_id === lfid) {
68-
if (list[i].signatureApproved === true) {
69-
expect(list[i].signatureApproved).to.be.true;
70-
signatureApproved = true;
71-
} else if (list[i].signatureApproved === false) {
72-
expect(list[i].signatureApproved).to.be.false;
73-
signatureApproved = false;
69+
return cy.logJson('response', response).then(() => {
70+
validate_200_Status(response);
71+
let list = response.body.list;
72+
for (let i = 0; i <= list.length - 1; i++) {
73+
if (list[i].linux_foundation_id === lfid3) {
74+
if (list[i].signatureApproved === true) {
75+
expect(list[i].signatureApproved).to.be.true;
76+
signatureApproved = true;
77+
} else if (list[i].signatureApproved === false) {
78+
expect(list[i].signatureApproved).to.be.false;
79+
signatureApproved = false;
80+
}
81+
signatureCclaID = list[i].signatureID;
82+
break;
7483
}
75-
signatureCclaID = list[i].signatureID;
76-
break;
7784
}
78-
}
79-
validateApiResponse('signatures/listClaGroupCorporateContributors.json', response);
85+
cy.task('log', 'Signature ID: ' + signatureCclaID + ' and Approved: ' + signatureApproved);
86+
validateApiResponse('signatures/listClaGroupCorporateContributors.json', response);
87+
});
8088
});
8189
});
8290

8391
it('Returns the signature when provided the signature ID, ecla records', function () {
92+
let url = `${claEndpoint}signatures/id/${signatureCclaID}`;
93+
cy.task('log', 'Returns the signature when provided the signature ID, ecla records URL: ' + url);
8494
cy.request({
8595
method: 'GET',
86-
url: `${claEndpoint}signatures/id/${signatureCclaID}`,
96+
url: url,
8797
timeout: 180000,
8898
failOnStatusCode: allowFail,
8999
headers: getXACLHeader(),
90100
auth: {
91101
bearer: bearerToken,
92102
},
93103
}).then((response) => {
94-
validate_200_Status(response);
95-
let list = response.body;
96-
expect(list.signatureApproved).to.eql(signatureApproved);
97-
expect(list.signatureType).to.eql('ecla');
104+
return cy.logJson('response', response).then(() => {
105+
validate_200_Status(response);
106+
let list = response.body;
107+
expect(list.signatureApproved).to.eql(signatureApproved);
108+
expect(list.signatureType).to.eql('ecla');
109+
});
98110
});
99111
});
100112

@@ -336,24 +348,29 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
336348
});
337349

338350
it('Returns a list of user signatures when provided the user ID', function () {
351+
let url = `${claEndpoint}signatures/user/${userID2}`;
352+
cy.task('log', 'Returns a list of user signatures when provided the user ID URL: ' + url);
339353
cy.request({
340354
method: 'GET',
341-
url: `${claEndpoint}signatures/user/${userID}`,
355+
url: url,
342356
timeout: 180000,
343357
failOnStatusCode: allowFail,
344358
headers: getXACLHeader(),
345359
auth: {
346360
bearer: bearerToken,
347361
},
348362
}).then((response) => {
349-
validate_200_Status(response);
350-
let signatures = response.body.signatures;
351-
for (let i = 0; i <= signatures.length - 1; i++) {
352-
expect(signatures[i].companyName).to.eql(companyName);
353-
expect(signatures[i].signatureReferenceType).to.eql('user');
354-
signatureID = signatures[i].signatureID;
355-
}
356-
validateApiResponse('signatures/getProjectCompanySignatures.json', response);
363+
return cy.logJson('response', response).then(() => {
364+
validate_200_Status(response);
365+
let signatures = response.body.signatures;
366+
for (let i = 0; i <= signatures.length - 1; i++) {
367+
// LG: API /signatures/user/{userID} internally skips ECLA records, and for ICLA we never have company
368+
expect(signatures[i].companyName).to.be.undefined;
369+
expect(signatures[i].signatureReferenceType).to.eql('user');
370+
signatureID = signatures[i].signatureID;
371+
}
372+
validateApiResponse('signatures/getProjectCompanySignatures.json', response);
373+
});
357374
});
358375
});
359376

@@ -410,9 +427,11 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
410427
/* Below test case for Updates the Project / Organization/Company Approval list */
411428

412429
it('Add Email as Approval List to the Project/Company', function () {
430+
let url = `${claEndpoint}signatures/project/${projectSFID}/company/${companyID}/clagroup/${claGroupID}/approval-list`;
431+
cy.task('log', 'Add Email as Approval List to the Project/Company URL: ' + url);
413432
cy.request({
414433
method: 'PUT',
415-
url: `${claEndpoint}signatures/project/${projectSFID}/company/${companyID}/clagroup/${claGroupID}/approval-list`,
434+
url: url,
416435
timeout: 180000,
417436
failOnStatusCode: allowFail,
418437
headers: getXACLHeader(),
@@ -423,9 +442,11 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
423442
AddEmailApprovalList: [emailApprovalList],
424443
},
425444
}).then((response) => {
426-
validate_200_Status(response);
427-
let list = response.body.emailApprovalList;
428-
expect(list[0]).to.eql(emailApprovalList);
445+
return cy.logJson('response', response).then(() => {
446+
validate_200_Status(response);
447+
let list = response.body.emailApprovalList;
448+
expect(list).to.include(emailApprovalList);
449+
});
429450
});
430451
});
431452

@@ -454,9 +475,11 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
454475
});
455476

456477
it('Add GithubOrg as Approval List to the Project/Company', function () {
478+
let url = `${claEndpoint}signatures/project/${projectSFID}/company/${companyID}/clagroup/${claGroupID}/approval-list`;
479+
cy.task('log', 'Add GithubOrg as Approval List to the Project/Company URL: ' + url);
457480
cy.request({
458481
method: 'PUT',
459-
url: `${claEndpoint}signatures/project/${projectSFID}/company/${companyID}/clagroup/${claGroupID}/approval-list`,
482+
url: url,
460483
timeout: 180000,
461484
failOnStatusCode: allowFail,
462485
headers: getXACLHeader(),
@@ -467,9 +490,11 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
467490
AddGithubOrgApprovalList: [gitOrgApprovalList],
468491
},
469492
}).then((response) => {
470-
validate_200_Status(response);
471-
let list = response.body.githubOrgApprovalList;
472-
expect(list[0]).to.eql(gitOrgApprovalList);
493+
return cy.logJson('response', response).then(() => {
494+
validate_200_Status(response);
495+
let list = response.body.githubOrgApprovalList;
496+
expect(list).to.include(gitOrgApprovalList);
497+
});
473498
});
474499
});
475500

@@ -774,29 +799,34 @@ describe('To Validate & get list of signatures of ClaGroups via API call', funct
774799
//Invalidates a given ICLA record for a user
775800
//worked only ine time, So skiping this test case, Refer screenshot: https://prnt.sc/ti6ERw8XZur0
776801

777-
it('Invalidates a given ICLA record for a user', function () {
802+
// LG:skip
803+
it.skip('Invalidates a given ICLA record for a user', function () {
778804
let user_id = '23121f2a-d48b-11ed-b70f-d2f23b35d89e';
805+
let url = `${claEndpoint}cla-group/${claGroupID}/user/${user_id}/icla`;
806+
cy.task('log', 'Invalidates a given ICLA record for a user URL: ' + url);
779807
cy.request({
780808
method: 'PUT',
781-
url: `${claEndpoint}cla-group/${claGroupID}/user/${user_id}/icla`,
809+
url: url,
782810
timeout: 180000,
783811
failOnStatusCode: allowFail,
784812
headers: getXACLHeader(),
785813
auth: {
786814
bearer: bearerToken,
787815
},
788816
}).then((response) => {
789-
if (response.status === 500) {
790-
Cypress.on('test:after:run', (test, runnable) => {
791-
const testName = `${test.title}`;
792-
const jsonResponse = JSON.stringify(response.body, null, 2);
793-
cy.log(jsonResponse);
794-
console.log(testName);
795-
console.error('User_id not available for invalidate : ', jsonResponse);
796-
});
797-
} else {
798-
validate_200_Status(response);
799-
}
817+
return cy.logJson('response', response).then(() => {
818+
if (response.status === 500) {
819+
Cypress.on('test:after:run', (test, runnable) => {
820+
const testName = `${test.title}`;
821+
const jsonResponse = JSON.stringify(response.body, null, 2);
822+
cy.log(jsonResponse);
823+
console.log(testName);
824+
console.error('User_id not available for invalidate : ', jsonResponse);
825+
});
826+
} else {
827+
validate_200_Status(response);
828+
}
829+
});
800830
});
801831
});
802832
});

0 commit comments

Comments
 (0)