From ee50735fc86e3161fd347d5f919dfb9e7a6dcd11 Mon Sep 17 00:00:00 2001 From: Celiant Date: Thu, 30 Jan 2025 17:41:20 +0400 Subject: [PATCH] update test for add, run and delete policy test --- .../000_importPolicyTest.cy.js | 33 ++++++++++++------- .../003_deletePolicyTest.cy.js | 8 ++--- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/e2e-tests/cypress/e2e/api-tests/016_policy_test/000_importPolicyTest.cy.js b/e2e-tests/cypress/e2e/api-tests/016_policy_test/000_importPolicyTest.cy.js index c5281edd6b..ce8ebe3008 100644 --- a/e2e-tests/cypress/e2e/api-tests/016_policy_test/000_importPolicyTest.cy.js +++ b/e2e-tests/cypress/e2e/api-tests/016_policy_test/000_importPolicyTest.cy.js @@ -6,25 +6,34 @@ context('Import policy test', { tags: ['policies', 'secondPool', 'all'] }, () => const SRUsername = Cypress.env('SRUser'); let policyId; - before('Get policy id', () => { + + before('Import policy and dry-run it', () => { Authorization.getAccessToken(SRUsername).then((authorization) => { cy.request({ - method: METHOD.GET, - url: API.ApiServer + API.Policies, + method: METHOD.POST, + url: API.ApiServer + API.PolicisImportMsg, + body: { messageId: "1707125414.999819805" }, //iRec2 headers: { authorization, }, - timeout: 180000 + timeout: 600000, }).then((response) => { - expect(response.status).to.eq(STATUS_CODE.OK); - response.body.forEach(element => { - if (element.name == "iRec_2") { - policyId = element.id - } - }) - }) + expect(response.status).to.eq(STATUS_CODE.SUCCESS); + policyId = response.body.at(0).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); + }); + }); }) - }) + }); it('Import a new policy test', () => { Authorization.getAccessToken(SRUsername).then((authorization) => { diff --git a/e2e-tests/cypress/e2e/api-tests/016_policy_test/003_deletePolicyTest.cy.js b/e2e-tests/cypress/e2e/api-tests/016_policy_test/003_deletePolicyTest.cy.js index 0d4e7df330..2bd1f1a3e6 100644 --- a/e2e-tests/cypress/e2e/api-tests/016_policy_test/003_deletePolicyTest.cy.js +++ b/e2e-tests/cypress/e2e/api-tests/016_policy_test/003_deletePolicyTest.cy.js @@ -38,7 +38,7 @@ context("Delete policy test", { tags: ['policies', 'secondPool', 'all'] }, () => }) }); - it("Deletes the policy with the provided ID by user - Negative", () => { + it("Deletes the policy test by User - Negative", () => { Authorization.getAccessToken(UserUsername).then((authorization) => { cy.request({ method: METHOD.DELETE, @@ -53,7 +53,7 @@ context("Delete policy test", { tags: ['policies', 'secondPool', 'all'] }, () => }); }); - it("Deletes the policy with the provided ID without auth token - Negative", () => { + it("Deletes the policy test without auth token - Negative", () => { cy.request({ method: METHOD.DELETE, url: API.ApiServer + API.Policies + policyId + "/" + API.Test + testId, @@ -63,7 +63,7 @@ context("Delete policy test", { tags: ['policies', 'secondPool', 'all'] }, () => }); }); - it("Deletes the policy with the provided ID with invalid auth token - Negative", () => { + it("Deletes the policy test with invalid auth token - Negative", () => { cy.request({ method: METHOD.DELETE, url: API.ApiServer + API.Policies + policyId + "/" + API.Test + testId, @@ -76,7 +76,7 @@ context("Delete policy test", { tags: ['policies', 'secondPool', 'all'] }, () => }); }); - it("Deletes the policy with the provided ID with empty auth token - Negative", () => { + it("Deletes the policy test with empty auth token - Negative", () => { cy.request({ method: METHOD.DELETE, url: API.ApiServer + API.Policies + policyId + "/" + API.Test + testId,