Skip to content

Commit

Permalink
fixes for policy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Celiant committed Feb 3, 2025
1 parent 1cf04ce commit 14f8f51
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ context("Contracts", { tags: ['contracts', 'firstPool', 'all'] }, () => {
}
})

cy.wait(10000)

let requestForDeviceCreationProgress = {
method: METHOD.GET,
url: API.ApiServer + API.Policies + policyId + "/" + API.Blocks + deviceGridBlockId,
Expand Down Expand Up @@ -331,6 +333,8 @@ context("Contracts", { tags: ['contracts', 'firstPool', 'all'] }, () => {
}
}

cy.wait(10000)

Checks.whileDeviceApproving("Approved", requestForDeviceApproveProgress, 0)

//Get issue data and prepare body for create
Expand Down Expand Up @@ -374,6 +378,8 @@ context("Contracts", { tags: ['contracts', 'firstPool', 'all'] }, () => {
}
}

cy.wait(10000)

Checks.whileIssueRequestCreating("Waiting for approval", requestForIssueCreationProgress, 0)
})
})
Expand Down Expand Up @@ -418,15 +424,20 @@ context("Contracts", { tags: ['contracts', 'firstPool', 'all'] }, () => {
}
}

cy.wait(10000)

Checks.whileIssueRequestApproving("Approved", requestForIssueApproveProgress, 0)


let requestForBalance = {
method: METHOD.GET,
url: API.ApiServer + API.ListOfTokens,
headers: {
authorization
}
}

cy.wait(10000)

Checks.whileBalanceVerifying("10", requestForBalance, 91, tokenId)
Checks.whileBalanceVerifying("10", requestForBalance, 91, tokenId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,52 @@ context('Import policy test', { tags: ['policies', 'secondPool', 'all'] }, () =>
const SRUsername = Cypress.env('SRUser');
let policyId;


before('Import policy and dry-run it', () => {
before('Get policy id', () => {
Authorization.getAccessToken(SRUsername).then((authorization) => {
cy.request({
method: METHOD.GET,
url: API.ApiServer + API.Policies,
headers: {
authorization,
},
timeout: 180000
}).then((response) => {
expect(response.status).to.eq(STATUS_CODE.OK);
response.body.forEach(element => {
if (element.name == "iRec_2") {
policyId = element.id
}
cy.fixture("iRecDRF.policy", "binary")
.then((binary) => Cypress.Blob.binaryStringToBlob(binary))
.then((file) => {
cy.request({
method: METHOD.POST,
url: API.ApiServer + API.PolicisImportFile,
body: file,
headers: {
"content-type": "binary/octet-stream",
authorization,
},
timeout: 180000,
}).then((response) => {
expect(response.status).to.eq(STATUS_CODE.SUCCESS);
cy.request({
method: METHOD.GET,
url: API.ApiServer + API.Policies,
headers: {
authorization,
},
timeout: 180000
}).then((response) => {
expect(response.status).to.eq(STATUS_CODE.OK);
response.body.forEach(element => {
if (element.name == "iRecDRF") {
policyId = element.id
}
})
cy.request({
method: METHOD.PUT,
url:
API.ApiServer + API.Policies + policyId + "/" + API.DryRun,
headers: {
authorization,
},
timeout: 180000,
}).then((response) => {
expect(response.status).to.eq(STATUS_CODE.OK);
});
})
})
})
cy.request({
method: METHOD.PUT,
url:
API.ApiServer + API.Policies + policyId + "/" + API.DryRun,
headers: {
authorization,
},
timeout: 180000,
}).then((response) => {
expect(response.status).to.eq(STATUS_CODE.OK);
});
});
})
});
});
})

it('Import a new policy test', () => {
Authorization.getAccessToken(SRUsername).then((authorization) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ context('Start policy test', { tags: ['policies', 'secondPool', 'all'] }, () =>
before('Get test id', () => {
Authorization.getAccessToken(SRUsername).then((authorization) => {
cy.request({
method: METHOD.GET,
url: API.ApiServer + API.Policies,
headers: {
authorization,
},
timeout: 180000
}).then((response) => {
expect(response.status).to.eq(STATUS_CODE.OK);
response.body.forEach(element => {
if (element.name == "iRec_2") {
policyId = element.id
}
})
method: METHOD.GET,
url: API.ApiServer + API.Policies,
headers: {
authorization,
},
timeout: 180000
}).then((response) => {
expect(response.status).to.eq(STATUS_CODE.OK);
response.body.forEach(element => {
if (element.name == "iRecDRF") {
policyId = element.id
}
})
cy.request({
method: METHOD.GET,
url: API.ApiServer + API.Policies + policyId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ context('Get policy test result', { tags: ['policies', 'secondPool', 'all'] }, (
before('Get test id', () => {
Authorization.getAccessToken(SRUsername).then((authorization) => {
cy.request({
method: METHOD.GET,
url: API.ApiServer + API.Policies,
headers: {
authorization,
},
timeout: 180000
}).then((response) => {
expect(response.status).to.eq(STATUS_CODE.OK);
response.body.forEach(element => {
if (element.name == "iRec_2") {
policyId = element.id
}
})
method: METHOD.GET,
url: API.ApiServer + API.Policies,
headers: {
authorization,
},
timeout: 180000
}).then((response) => {
expect(response.status).to.eq(STATUS_CODE.OK);
response.body.forEach(element => {
if (element.name == "iRecDRF") {
policyId = element.id
}
})
cy.request({
method: METHOD.GET,
url: API.ApiServer + API.Policies + policyId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ context("Delete policy test", { tags: ['policies', 'secondPool', 'all'] }, () =>
}).then((response) => {
expect(response.status).to.eq(STATUS_CODE.OK);
response.body.forEach(element => {
if (element.name == "iRec_2") {
if (element.name == "iRecDRF") {
policyId = element.id
}
})
Expand All @@ -38,7 +38,7 @@ context("Delete policy test", { tags: ['policies', 'secondPool', 'all'] }, () =>
})
});

it("Deletes the policy test by User - Negative", () => {
it("Deletes the policy with the provided ID by user - Negative", () => {
Authorization.getAccessToken(UserUsername).then((authorization) => {
cy.request({
method: METHOD.DELETE,
Expand All @@ -53,7 +53,7 @@ context("Delete policy test", { tags: ['policies', 'secondPool', 'all'] }, () =>
});
});

it("Deletes the policy test without auth token - Negative", () => {
it("Deletes the policy with the provided ID without auth token - Negative", () => {
cy.request({
method: METHOD.DELETE,
url: API.ApiServer + API.Policies + policyId + "/" + API.Test + testId,
Expand All @@ -63,7 +63,7 @@ context("Delete policy test", { tags: ['policies', 'secondPool', 'all'] }, () =>
});
});

it("Deletes the policy test with invalid auth token - Negative", () => {
it("Deletes the policy with the provided ID with invalid auth token - Negative", () => {
cy.request({
method: METHOD.DELETE,
url: API.ApiServer + API.Policies + policyId + "/" + API.Test + testId,
Expand All @@ -76,7 +76,7 @@ context("Delete policy test", { tags: ['policies', 'secondPool', 'all'] }, () =>
});
});

it("Deletes the policy test with empty auth token - Negative", () => {
it("Deletes the policy with the provided ID with empty auth token - Negative", () => {
cy.request({
method: METHOD.DELETE,
url: API.ApiServer + API.Policies + policyId + "/" + API.Test + testId,
Expand Down
Binary file added e2e-tests/cypress/fixtures/iRecDRF.policy
Binary file not shown.
28 changes: 28 additions & 0 deletions e2e-tests/cypress/support/ApiUrls.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ const API = {
PolicisImportMsgPreviewPush: "policies/push/import/message/preview",
PolicyGroups: "groups/",
DryRun: "dry-run/",
DryRunUser: "dry-run/user/",
DryRunLogin: "dry-run/login/",
ChooseRegistrantRole: "tag/choose_role/blocks/",
CreateApplication: "tag/create_application/blocks",
WaitForApproveApplication: "tag/wait_for_approve",
Expand All @@ -114,12 +116,38 @@ const API = {
GetIssues: "tag/issue_requests_grid(evident)/blocks",
ApproveIssueRequestsBtn: "tag/approve_issue_requests_btn/blocks",
CreateIssue: "tag/create_issue_request_form/blocks",
Categories: "methodologies/categories",

//Records
Record: "record/",
RecordStatus: "status/",
RecordStart: "recording/start/",
RecordStop: "recording/stop/",
RecordActions: "recording/actions/",
RunningStart: "running/start/",
RunningStop: "running/stop/",
RecordResults: "running/results/",
RecordDetails: "running/details/",
RecordFastForward: "running/fast-forward/",
RecordRetry: "running/retry/",
RecordSkip: "running/skip/",

//Artifacts
Artifacts: "artifacts/",

//Tags
Tags: "tags/",
ChooseRoleTag: "tag/choose_role/",
CreateApplicationTag: "tag/create_application/",
ApproveApplicationTag: "tag/approve_registrant_btn/",
RegistrantGrid: "tag/registrants_grid/",
CreateDeviceTag: "tag/create_device_form/",
DeviceGrid: "tag/approve_devices_grid/",
ApproveDeviceTag: "tag/approve_device_btn/",
CreateIssueTag: "tag/create_issue_request_form/",
IssueGrid: "tag/issue_requests_grid(evident)/",
ApproveIssueTag: "tag/approve_issue_requests_btn/",
GetTokenAmountTag: "tag/vp_grid/",

//General
ExportCSV: "export?type=csv",
Expand Down
12 changes: 12 additions & 0 deletions e2e-tests/cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"allowJs": true,
"baseUrl": "../node_modules",
"types": [
"cypress"
]
},
"include": [
"**/*.*"
]
}

0 comments on commit 14f8f51

Please sign in to comment.