Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added cypress test case for cla-manager API #4098

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/functional/cypress.env.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"AUTH0_TOKEN_API":"https://linuxfoundation-dev.auth0.com/oauth/token",
"AUTH0_USER_NAME":"vthakur",
"AUTH0_PASSWORD":"Test@123",
"LFX_API_TOKEN":"gDYBt6VYW6cmXelL/a3wTmHMa9sD37Xo9gsgaIjncbw=",
"AUTH0_CLIENT_SECRET":"eyJuYW1lIjoiYXV0aDAuanMtdWxwIiwidmVyc2lvbiI6IjkuMTIuMiJ9",
"AUTH0_CLIENT_ID":"hquZHO8JNsaIScoayPtCS5VELdn7TnVq"
}
231 changes: 231 additions & 0 deletions tests/functional/cypress/e2e/cla-manager.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
import {validateApiResponse,validate_200_Status} 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
/*
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";
const projectSFID="a09P000000DsCE5IAN";//sun
const projectSFID_Designee="a09P000000DsNH2IAN"
const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4/`;
let bearerToken: string = "";
const claGroupID="1baf67ab-d894-4edf-b6fc-c5f939db59f7";
const sun_claGroupID="01af041c-fa69-4052-a23c-fb8c1d3bef24"
const userEmail="[email protected]";
let companyName="Infosys limited";
let organization_id="";
let organization_name="";
let companySFID="";
let userLFID="veerendrat";
let userId="c5ac2857-c263-11ed-94d1-d2349de32229";//veerendrat

before(() => {

cy.request({
method: 'POST',
url: Cypress.env("AUTH0_TOKEN_API"),

body: {
"grant_type": "http://auth0.com/oauth/grant-type/password-realm",
"realm": "Username-Password-Authentication",
"username":Cypress.env("AUTH0_USER_NAME"),
"password":Cypress.env("AUTH0_PASSWORD"),
"client_id":Cypress.env("AUTH0_CLIENT_ID"),
"audience": "https://api-gw.dev.platform.linuxfoundation.org/",
"scope": "access:api openid profile email"
}
}).then(response => {
expect(response.status).to.eq(200);
bearerToken = response.body.access_token;

});
});

it("Assigns CLA Manager designee to a given user.", function () {
cy.request({
method: 'POST',
url: `${claEndpoint}company/${companyID}/claGroup/${claGroupID}/cla-manager-designee`,

auth: {
'bearer': bearerToken,
},
body:{
"userEmail": userEmail
}
}).then((response) => {
// expect(response.duration).to.be.lessThan(20000);
validate_200_Status(response);
companySFID=response.body.list[0].company_sfid;
userLFID=response.body.list[0].lf_username;
cy.log('company_sfid : '+ companySFID);
cy.log('lf_username : '+ userLFID);
//To validate Post response
if (response.status === 200) {
getClaManager();
}
validateApiResponse("cla-manager/assignCLAManager.json",response)
});
});

it("Allows an existing CLA Manager to add another CLA Manager to the specified Company and Project.", function () {
cy.request({
method: 'POST',
url: `${claEndpoint}company/${companyID}/project/${projectSFID}/cla-manager`,

auth: {
'bearer': bearerToken,
},
failOnStatusCode: false,
body:{

"firstName": "veerendrat",
"lastName": "thakur",
"userEmail": userEmail

}
}).then((response) => {

// expect(response.duration).to.be.lessThan(20000);

if(response.status === 200) {
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{
expect(response.body.Message).to.include('error: manager already in signature ACL');
}
validateApiResponse("cla-manager/createCLAManager.json",response)
});
});

it("Deletes the CLA Manager from CLA Manager list for specified Company and Project", function () {
cy.request({
method: 'DELETE',
url: `${claEndpoint}company/${companyID}/project/${projectSFID}/cla-manager/${userLFID}`,

auth: {
'bearer': bearerToken,
},

}).then((response) => {
// expect(response.duration).to.be.lessThan(20000);
expect(response.status).to.eq(204);
});
});

it("Assigns CLA Manager designee to a given user", function () {
cy.request({
method: 'POST',
url: `${claEndpoint}company/${companyID}/project/${projectSFID_Designee}/cla-manager-designee`,

auth: {
'bearer': bearerToken,
},
body:{
"userEmail": userEmail
}
}).then((response) => {
// expect(response.duration).to.be.lessThan(20000);
validate_200_Status(response);
// Validate specific data in the response
expect(response.body.project_sfid).to.eql(projectSFID_Designee)
if (response.status === 200) {
getClaManager();
}
validateApiResponse("cla-manager/createCLAManagerDesignee.json",response)
});
});

it("Adds a CLA Manager Designee to the specified Company and Project", function () {
cy.request({
method: 'POST',
url: `${claEndpoint}company/${companyID}/project/${projectSFID_Designee}/cla-manager/requests`,

auth: {
'bearer': bearerToken,
},
body:{
"contactAdmin": false,
"fullName": "veerendrat cla",
"userEmail": "[email protected]"
}
}).then((response) => {
// expect(response.duration).to.be.lessThan(20000);
validate_200_Status(response);
// Validate specific data in the response
expect(response.body.project_sfid).to.eql(projectSFID_Designee)
//To validate schema of response
validateApiResponse("cla-manager/createCLAManagerDesignee.json",response)
});
});

it("Send Notification to CLA Managaers", function () {
cy.request({
method: 'POST',
url: `${claEndpoint}notify-cla-managers`,

auth: {
'bearer': bearerToken,
},
body:{
"claGroupID": claGroupID,
"companyName": companyName,
"list": [
{
"email": "[email protected]",
"name": "vthakur"
}
],
"signingEntityName": "Linux Foundation",
"userID": userId
}
}).then((response) => {
// expect(response.duration).to.be.lessThan(20000);
expect(response.status).to.eq(204);
});
});

it("Invite Company Admin based on user request to sign CLA", function () {
cy.request({
method: 'POST',
url: `${claEndpoint}user/${userId}/invite-company-admin`,

auth: {
'bearer': bearerToken,
},
body:{
"claGroupID": sun_claGroupID,
"companyID": companyID,
"contactAdmin": true,
"name": "veerendra thakur",
"userEmail": userEmail
}
}).then((response) => {
// expect(response.duration).to.be.lessThan(20000);
validate_200_Status(response);
// validateApiResponse("cla-manager/assignCLAManager.json",response)
});
});


function getClaManager(){
cy.request({
method: 'GET',
url: `${claEndpoint}company/${companySFID}/user/${userLFID}/claGroupID/${claGroupID}/is-cla-manager-designee`,
auth: {
'bearer': bearerToken,
},
}).then((response) => {
validate_200_Status(response);
expect(response.body.hasRole).to.eq(true);
expect(response.body.lfUsername).to.eq(userLFID);
// validateApiResponse("cla-manager/isCLAManagerDesignee.json",response)
})
}
});
16 changes: 9 additions & 7 deletions tests/functional/cypress/e2e/events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ describe("To Validate events are properly capture via API call", function () {
const projectSfid='a09P000000DsNH2IAN'; //project name: easyAutom-child2
const companyID="f7c7ac9c-4dbf-4104-ab3f-6b38a26d82dc";
const compProjectSFID="a092h000004x5tVAAQ";
const Ajv = require('ajv');

before(() => {
before(() => {

cy.request({
method: 'POST',
url: Cypress.env("AUTH0_TOKEN_API"),
Expand All @@ -23,6 +22,7 @@ before(() => {
"username":Cypress.env("AUTH0_USER_NAME"),
"password":Cypress.env("AUTH0_PASSWORD"),
"client_id":Cypress.env("AUTH0_CLIENT_ID"),
// "client_secret": Cypress.env("AUTH0_CLIENT_SECRET"),
"audience": "https://api-gw.dev.platform.linuxfoundation.org/",
"scope": "access:api openid profile email"
}
Expand All @@ -31,6 +31,7 @@ before(() => {
expect(response.status).to.eq(200);
bearerToken = response.body.access_token;
});

});

it("Get recent events of company and project - Record should Returns 200 Response", function () {
Expand Down Expand Up @@ -82,7 +83,7 @@ it("Get events of foundation project - Record should Returns 200 Response", func
expect(Events).to.be.an('array');
// Assert that the array has at least one item
expect(Events.length).to.be.greaterThan(0);
validateApiResponse("events/getFoundationEvents.json",list);
// validateApiResponse("events/getFoundationEvents.json",list);
fetchNextRecords(claEndpointForNextKey,NextKey);
});
});
Expand All @@ -91,13 +92,13 @@ it("Get events of foundation project - Record should Returns 200 Response", func
claEndpointForNextKey=`${claEndpoint}/project/${projectSfid}`;
cy.request({
method: 'GET',
url: `${claEndpointForNextKey}`,
url: `${claEndpoint}/project/${projectSfid}`,
auth: {
'bearer': bearerToken,
}
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.not.be.null;
expect(response.body).to.not.be.null;
let list=response.body;
// Validate specific data in the response
expect(list).to.have.property('NextKey');
Expand Down Expand Up @@ -164,7 +165,7 @@ it("Get events of foundation project - Record should Returns 200 Response", func
});

function fetchNextRecords(URL,NextKey){

if(NextKey!==undefined){
cy.request({
method: 'GET',
url: `${URL}?nextKey=${NextKey}&pageSize=50`,
Expand All @@ -180,5 +181,6 @@ it("Get events of foundation project - Record should Returns 200 Response", func
fetchNextRecords(URL,updatedNextKey);
}
});
}
}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"list": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"assigned_on": {
"type": "string"
},
"company_id": {
"type": "string"
},
"company_sfid": {
"type": "string"
},
"email": {
"type": "string"
},
"lf_username": {
"type": "string"
},
"name": {
"type": "string"
},
"project_name": {
"type": "string"
},
"project_sfid": {
"type": "string"
},
"type": {
"type": "string"
},
"user_sfid": {
"type": "string"
}
},
"required": [
"assigned_on",
"company_id",
"company_sfid",
"email",
"lf_username",
"name",
"project_name",
"project_sfid",
"type",
"user_sfid"
]
}
]
}
},
"required": [
"list"
]
}
Loading
Loading