Skip to content

Commit 212e2e6

Browse files
Fixing the test coverage and fixing bug in API
Signed-off-by: Lukasz Gryglicki <[email protected]> Assisted by [OpenAI](https://platform.openai.com/) Assisted by [GitHub Copilot](https://github.com/features/copilot)
1 parent 9ec747e commit 212e2e6

File tree

70 files changed

+4504
-4316
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+4504
-4316
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,4 @@ cover.out
258258
src.txt
259259
src.txt.*
260260
out.json
261+
body.json

cla-backend-go/v2/cla_manager/service.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,14 @@ func (s *service) NotifyCLAManagers(ctx context.Context, notifyCLAManagers *mode
11671167
// Search for Easy CLA User
11681168
log.WithFields(f).Debugf("Getting user by ID: %s", notifyCLAManagers.UserID)
11691169
userModel, userErr := s.easyCLAUserService.GetUser(notifyCLAManagers.UserID)
1170+
// log.WithFields(f).Debugf("Got user by ID: %s -> (%+v, %+v)", notifyCLAManagers.UserID, userModel, userErr)
11701171
if userErr != nil {
1171-
msg := fmt.Sprintf("Problem getting user by ID: %s ", notifyCLAManagers.UserID)
1172+
msg := fmt.Sprintf("Problem getting user by ID: %s: %v", notifyCLAManagers.UserID, userErr)
1173+
log.WithFields(f).Warn(msg)
1174+
return ErrCLAUserNotFound
1175+
}
1176+
if userModel == nil {
1177+
msg := fmt.Sprintf("Problem getting user by ID: %s", notifyCLAManagers.UserID)
11721178
log.WithFields(f).Warn(msg)
11731179
return ErrCLAUserNotFound
11741180
}

cla-backend-go/v2/signatures/service.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ func (s *Service) InvalidateICLA(ctx context.Context, claGroupID string, userID
381381
log.WithFields(f).Debug("unable to get user record")
382382
return userErr
383383
}
384+
if user == nil {
385+
log.WithFields(f).Debug("unable to get user record")
386+
return fmt.Errorf("user not found for userID: %s", userID)
387+
}
384388

385389
log.WithFields(f).Debug("invalidating signature record ...")
386390
note := fmt.Sprintf("Signature invalidated (approved set to false) by %s for %s ", authUser.UserName, utils.GetBestUsername(user))

tests/functional/cypress.config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ export default defineConfig({
1212
setupNodeEvents(on, config) {
1313
on('task', {
1414
log(message: string) {
15-
console.log(message);
15+
if (process.env.DEBUG) {
16+
console.log(message);
17+
}
1618
return null;
1719
},
1820
table(rows: any[]) {
19-
console.table(rows);
21+
if (process.env.DEBUG) {
22+
console.table(rows);
23+
}
2024
return null;
2125
},
2226
});

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export const appConfig = {
1515
user_id: '8f3e52b8-0072-11ee-9def-0ef17207dfe8', //[email protected]
1616
userEmail: '[email protected]',
1717
user_id2: '4a4c1dba-407f-11ed-8c58-a6b0f8fb81a9', //[email protected]
18+
user_id3: '9dcf5bbc-2492-11ed-97c7-3e2a23ea20b5', // lgryglicki
19+
userEmail3: '[email protected]',
1820

1921
/*events*/
2022
companyID: 'f7c7ac9c-4dbf-4104-ab3f-6b38a26d82dc', //infosys limited
@@ -31,6 +33,7 @@ export const appConfig = {
3133

3234
/*cla-manager*/
3335
userIdclaManager: 'c5ac2857-c263-11ed-94d1-d2349de32229', //veerendrat
36+
userIdclaManager2: '9dcf5bbc-2492-11ed-97c7-3e2a23ea20b5', // lgryglicki
3437
claGroupId_projectSFID: '01af041c-fa69-4052-a23c-fb8c1d3bef24', //sun project claGroupID
3538

3639
/* project */
@@ -48,4 +51,11 @@ export const appConfig = {
4851
gitUsernameApprovalList: 'vrthakur',
4952
gitLabOrgApprovalList: 'https://gitlab.com/veerendrat1',
5053
domainApprovalList: 'proximabiz.com',
54+
// lgryglicki
55+
lfid2: 'lgryglicki',
56+
emailApprovalList2: '[email protected]',
57+
gitOrgApprovalList2: 'o2.pl',
58+
gitUsernameApprovalList2: 'lukaszgryglicki',
59+
gitLabOrgApprovalList2: 'https://gitlab.com/lukaszgryglicki',
60+
domainApprovalList2: 'o2.pl',
5161
};

tests/functional/cypress/e2e/cla-group.cy.ts

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { validateApiResponse, validate_200_Status, validate_404_Status, getTokenKey } from '../support/commands';
1+
import {
2+
validateApiResponse,
3+
validate_200_Status,
4+
validate_404_Status,
5+
getTokenKey,
6+
getAPIBaseURL,
7+
getXACLHeader,
8+
} from '../support/commands';
29

310
describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on child project", function () {
411
// Define a variable for the environment
@@ -14,7 +21,7 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch
1421

1522
//Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/cla-group
1623

17-
const claEndpoint = `${Cypress.env('APP_URL')}cla-service/v4`;
24+
const claEndpoint = getAPIBaseURL('v4');
1825
let claGroupId: string = '';
1926

2027
//Variable for create cla group
@@ -49,9 +56,9 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch
4956
it('Creates a new CLA Group at child level - Record should return 200 Response', function () {
5057
cy.request({
5158
method: 'POST',
52-
url: `${claEndpoint}/cla-group`,
59+
url: `${claEndpoint}cla-group`,
5360
failOnStatusCode: allowFail,
54-
61+
headers: getXACLHeader(),
5562
auth: {
5663
bearer: bearerToken,
5764
},
@@ -106,9 +113,9 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch
106113
it('Get list of cla group associated with project - Record should return 200 Response', function () {
107114
cy.request({
108115
method: 'GET',
109-
url: `${claEndpoint}/foundation/${projectSfid}/cla-groups`,
116+
url: `${claEndpoint}foundation/${projectSfid}/cla-groups`,
110117
failOnStatusCode: allowFail,
111-
118+
headers: getXACLHeader(),
112119
auth: {
113120
bearer: bearerToken,
114121
},
@@ -130,8 +137,9 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch
130137
it('Attempt to get list of cla group associated with project given by wrong SFID - Record should Return 404 Response', function () {
131138
cy.request({
132139
method: 'GET',
133-
url: `${claEndpoint}/foundation/${projectSfid}-xyz/cla-groups`,
140+
url: `${claEndpoint}foundation/${projectSfid}-xyz/cla-groups`,
134141
failOnStatusCode: false,
142+
headers: getXACLHeader(),
135143
auth: {
136144
bearer: bearerToken,
137145
},
@@ -145,9 +153,9 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch
145153
it('Updates a CLA Group details - Record should return 200 Response', function () {
146154
cy.request({
147155
method: 'PUT',
148-
url: `${claEndpoint}/cla-group/${claGroupId}`,
156+
url: `${claEndpoint}cla-group/${claGroupId}`,
149157
failOnStatusCode: allowFail,
150-
158+
headers: getXACLHeader(),
151159
auth: {
152160
bearer: bearerToken,
153161
},
@@ -171,9 +179,9 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch
171179
it('Enroll projects in a CLA Group - Record should return 200 Response', function () {
172180
cy.request({
173181
method: 'PUT',
174-
url: `${claEndpoint}/cla-group/${claGroupId}/enroll-projects`,
182+
url: `${claEndpoint}cla-group/${claGroupId}/enroll-projects`,
175183
failOnStatusCode: allowFail,
176-
184+
headers: getXACLHeader(),
177185
auth: {
178186
bearer: bearerToken,
179187
},
@@ -186,9 +194,9 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch
186194
// Run the second API request
187195
cy.request({
188196
method: 'GET',
189-
url: `${claEndpoint}/foundation/${projectSfid}/cla-groups`,
197+
url: `${claEndpoint}foundation/${projectSfid}/cla-groups`,
190198
failOnStatusCode: allowFail,
191-
199+
headers: getXACLHeader(),
192200
auth: {
193201
bearer: bearerToken,
194202
},
@@ -209,9 +217,9 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch
209217
it('Unenroll projects in a CLA Group - Record should return 200 Response', function () {
210218
cy.request({
211219
method: 'PUT',
212-
url: `${claEndpoint}/cla-group/${claGroupId}/unenroll-projects`,
220+
url: `${claEndpoint}cla-group/${claGroupId}/unenroll-projects`,
213221
failOnStatusCode: allowFail,
214-
222+
headers: getXACLHeader(),
215223
auth: {
216224
bearer: bearerToken,
217225
},
@@ -225,9 +233,9 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch
225233
it('Get list of Github organization associated with project - Record should return 200 Response', function () {
226234
cy.request({
227235
method: 'GET',
228-
url: `${claEndpoint}/project/${projectSfidOrg}/github/organizations`,
236+
url: `${claEndpoint}project/${projectSfidOrg}/github/organizations`,
229237
failOnStatusCode: allowFail,
230-
238+
headers: getXACLHeader(),
231239
auth: {
232240
bearer: bearerToken,
233241
},
@@ -248,9 +256,9 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch
248256
it('Update GitHub Organization Configuration - Record should return 200 Response', function () {
249257
cy.request({
250258
method: 'PUT',
251-
url: `${claEndpoint}/project/${projectSfidOrg}/github/organizations/${gitHubOrgName}/config`,
259+
url: `${claEndpoint}project/${projectSfidOrg}/github/organizations/${gitHubOrgName}/config`,
252260
failOnStatusCode: allowFail,
253-
261+
headers: getXACLHeader(),
254262
auth: {
255263
bearer: bearerToken,
256264
},
@@ -268,9 +276,9 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch
268276
if (claGroupId != null) {
269277
cy.request({
270278
method: 'DELETE',
271-
url: `${claEndpoint}/cla-group/${claGroupId}`,
279+
url: `${claEndpoint}cla-group/${claGroupId}`,
272280
failOnStatusCode: allowFail,
273-
281+
headers: getXACLHeader(),
274282
auth: {
275283
bearer: bearerToken,
276284
},
@@ -281,9 +289,9 @@ describe("To Validate 'GET, CREATE, UPDATE and DELETE' CLA groups API call on ch
281289
// Run the second API request
282290
cy.request({
283291
method: 'GET',
284-
url: `${claEndpoint}/foundation/${projectSfid}/cla-groups`,
292+
url: `${claEndpoint}foundation/${projectSfid}/cla-groups`,
285293
failOnStatusCode: allowFail,
286-
294+
headers: getXACLHeader(),
287295
auth: {
288296
bearer: bearerToken,
289297
},

0 commit comments

Comments
 (0)