-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cypress test case for company API
Signed-off-by: veerendra thakur <[email protected]>
- Loading branch information
1 parent
2303999
commit dae00a3
Showing
8 changed files
with
608 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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";//[email protected] | ||
const userEmail= "[email protected]"; | ||
const user_id2="4a4c1dba-407f-11ed-8c58-a6b0f8fb81a9"//[email protected] | ||
|
||
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": "[email protected]" | ||
} | ||
}).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": "[email protected]", | ||
"claManagerName": "veerendra thakur", | ||
"companyName": "Infosys Limited", | ||
"companyWebsite":"wwww.infosys.com", | ||
"contributorEmail": "[email protected]", | ||
"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) | ||
}); | ||
} | ||
|
||
}); | ||
|
||
|
33 changes: 33 additions & 0 deletions
33
tests/functional/cypress/fixtures/company/getCompanyAdmins.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |
52 changes: 52 additions & 0 deletions
52
tests/functional/cypress/fixtures/company/getCompanyByName.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |
Oops, something went wrong.