Skip to content

Commit 443706e

Browse files
Update V3 test coverage
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io> Assisted by [OpenAI](https://platform.openai.com/) Assisted by [GitHub Copilot](https://github.com/features/copilot)
1 parent eaddfda commit 443706e

File tree

12 files changed

+209
-387
lines changed

12 files changed

+209
-387
lines changed

cla-backend-go/company/handlers.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,11 @@ func Configure(api *operations.ClaAPI, service IService, usersService users.Serv
363363

364364
result, err := service.SearchOrganizationByName(ctx, companyName, websiteName, utils.BoolValue(params.IncludeSigningEntityName), filter)
365365
if err != nil {
366-
log.Warnf("error occurred while search org %s. error = %s", *params.CompanyName, err.Error())
366+
companyName := "<nil>"
367+
if params.CompanyName != nil {
368+
companyName = *params.CompanyName
369+
}
370+
log.Warnf("error occurred while search org %s. error = %s", companyName, err.Error())
367371
return organization.NewSearchOrganizationInternalServerError().WithXRequestID(reqID).WithPayload(errorResponse(err))
368372
}
369373
return organization.NewSearchOrganizationOK().WithXRequestID(reqID).WithPayload(result)

tests/functional/cypress/e2e/v3/cla-manager.cy.ts

Lines changed: 0 additions & 182 deletions
This file was deleted.

tests/functional/cypress/e2e/v3/docs.cy.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
1-
import {
2-
validate_200_Status,
3-
getTokenKey,
4-
getAPIBaseURL,
5-
getXACLHeaders,
6-
validate_expected_status,
7-
} from '../../support/commands';
1+
import { validate_200_Status, getAPIBaseURL, validate_expected_status } from '../../support/commands';
82

93
describe('To Validate & test Documentation APIs via API call (V3)', function () {
104
const claEndpoint = getAPIBaseURL('v3');
115
let allowFail: boolean = !(Cypress.env('ALLOW_FAIL') === 1);
126
const timeout = 180000;
137
const local = Cypress.env('LOCAL');
148

15-
let bearerToken: string = null;
16-
before(() => {
17-
if (bearerToken == null) {
18-
getTokenKey(bearerToken);
19-
cy.window().then((win) => {
20-
bearerToken = win.localStorage.getItem('bearerToken');
21-
});
22-
}
23-
});
24-
259
it('Get API Documentation - Record should return 200 Response', function () {
2610
cy.request({
2711
method: 'GET',

tests/functional/cypress/e2e/v3/health.cy.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
1-
import {
2-
validate_200_Status,
3-
getTokenKey,
4-
getAPIBaseURL,
5-
getXACLHeaders,
6-
validate_expected_status,
7-
} from '../../support/commands';
1+
import { validate_200_Status, getAPIBaseURL, validate_expected_status } from '../../support/commands';
82

93
describe('To Validate & test Health APIs via API call (V3)', function () {
104
const claEndpoint = getAPIBaseURL('v3');
115
let allowFail: boolean = !(Cypress.env('ALLOW_FAIL') === 1);
126
const timeout = 180000;
137
const local = Cypress.env('LOCAL');
148

15-
let bearerToken: string = null;
16-
before(() => {
17-
if (bearerToken == null) {
18-
getTokenKey(bearerToken);
19-
cy.window().then((win) => {
20-
bearerToken = win.localStorage.getItem('bearerToken');
21-
});
22-
}
23-
});
24-
259
it('Returns the Health of the application - Record should return 200 Response', function () {
2610
cy.request({
2711
method: 'GET',

tests/functional/cypress/e2e/v3/organization.cy.ts

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import {
22
validate_200_Status,
33
validate_401_Status,
4-
getTokenKey,
54
getAPIBaseURL,
6-
getXACLHeaders,
75
validate_expected_status,
86
} from '../../support/commands';
97

@@ -13,14 +11,6 @@ describe('To Validate & test Organization APIs via API call (V3)', function () {
1311
const timeout = 180000;
1412
const local = Cypress.env('LOCAL');
1513

16-
let bearerToken: string = null;
17-
before(() => {
18-
getTokenKey(bearerToken);
19-
cy.window().then((win) => {
20-
bearerToken = win.localStorage.getItem('bearerToken');
21-
});
22-
});
23-
2414
it('Search Organization by company name - Record should return 200 Response', function () {
2515
const companyName = 'Linux Foundation';
2616
cy.request({
@@ -29,11 +19,12 @@ describe('To Validate & test Organization APIs via API call (V3)', function () {
2919
timeout: timeout,
3020
failOnStatusCode: allowFail,
3121
}).then((response) => {
32-
validate_200_Status(response);
33-
expect(response.body).to.be.an('object');
34-
if (response.body.list) {
22+
return cy.logJson('response', response).then(() => {
23+
validate_200_Status(response);
24+
expect(response.body).to.be.an('object');
3525
expect(response.body.list).to.be.an('array');
36-
}
26+
expect(response.body.list.length).to.be.greaterThan(0);
27+
});
3728
});
3829
});
3930

@@ -43,13 +34,14 @@ describe('To Validate & test Organization APIs via API call (V3)', function () {
4334
method: 'GET',
4435
url: `${claEndpoint}organization/search?websiteName=${encodeURIComponent(websiteName)}`,
4536
timeout: timeout,
46-
failOnStatusCode: allowFail,
37+
failOnStatusCode: false, // Handle connection issues for local
4738
}).then((response) => {
48-
validate_200_Status(response);
49-
expect(response.body).to.be.an('object');
50-
if (response.body.list) {
39+
return cy.logJson('response', response).then(() => {
40+
validate_200_Status(response);
41+
expect(response.body).to.be.an('object');
5142
expect(response.body.list).to.be.an('array');
52-
}
43+
expect(response.body.list.length).to.be.greaterThan(0);
44+
});
5345
});
5446
});
5547

@@ -62,11 +54,29 @@ describe('To Validate & test Organization APIs via API call (V3)', function () {
6254
timeout: timeout,
6355
failOnStatusCode: allowFail,
6456
}).then((response) => {
65-
validate_200_Status(response);
66-
expect(response.body).to.be.an('object');
67-
if (response.body.list) {
57+
return cy.logJson('response', response).then(() => {
58+
validate_200_Status(response);
59+
expect(response.body).to.be.an('object');
60+
expect(response.body.list).to.be.an('array');
61+
expect(response.body.list.length).to.be.greaterThan(0);
62+
});
63+
});
64+
});
65+
66+
it('Search Organization by non-existing company name - Record should return 200 Response', function () {
67+
const companyName = 'Non-existing XYZ';
68+
cy.request({
69+
method: 'GET',
70+
url: `${claEndpoint}organization/search?companyName=${encodeURIComponent(companyName)}`,
71+
timeout: timeout,
72+
failOnStatusCode: allowFail,
73+
}).then((response) => {
74+
return cy.logJson('response', response).then(() => {
75+
validate_200_Status(response);
76+
expect(response.body).to.be.an('object');
6877
expect(response.body.list).to.be.an('array');
69-
}
78+
expect(response.body.list.length).to.eq(0);
79+
});
7080
});
7181
});
7282

@@ -86,7 +96,7 @@ describe('To Validate & test Organization APIs via API call (V3)', function () {
8696
method: 'GET',
8797
url: `${claEndpoint}organization/search`,
8898
expectedStatus: 400,
89-
expectedMessage: 'companyName or websiteName',
99+
expectedMessage: 'companyName or websiteName or filter at least one required',
90100
expectedMessageContains: true,
91101
},
92102
{
@@ -96,6 +106,7 @@ describe('To Validate & test Organization APIs via API call (V3)', function () {
96106
expectedStatus: 422,
97107
expectedMessage: 'websiteName in query should match',
98108
expectedMessageContains: true,
109+
expectedCode: 605,
99110
},
100111
];
101112

0 commit comments

Comments
 (0)