From d5c986a20e86c54fc153839e6d2dd57b16047d95 Mon Sep 17 00:00:00 2001 From: veerendra thakur Date: Wed, 27 Sep 2023 15:24:47 +0530 Subject: [PATCH 1/2] Added cypress test case for cypress-health API Signed-off-by: veerendra thakur --- tests/functional/cypress/e2e/health.cy.ts | 32 +++++++++ .../cypress/fixtures/health/healthCheck.json | 65 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 tests/functional/cypress/e2e/health.cy.ts create mode 100644 tests/functional/cypress/fixtures/health/healthCheck.json diff --git a/tests/functional/cypress/e2e/health.cy.ts b/tests/functional/cypress/e2e/health.cy.ts new file mode 100644 index 000000000..fcf7bd4ce --- /dev/null +++ b/tests/functional/cypress/e2e/health.cy.ts @@ -0,0 +1,32 @@ +import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands' + +describe("To Validate & get health status via API call", function () { + + //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/health/operation/healthCheck + const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4`; + + let bearerToken: string = null; + before(() => { + if(bearerToken==null){ + getTokenKey(bearerToken); + cy.window().then((win) => { + bearerToken = win.localStorage.getItem('bearerToken'); + }); + } + }); + +it("Returns the Health of the application- Record should Returns 200 Response", function () { + cy.request({ + method: 'GET', + url: `${claEndpoint}/ops/health`, + auth: { + 'bearer': bearerToken, + } + }).then((response) => { + validate_200_Status(response); + //To validate schema of response + validateApiResponse("health/healthCheck.json",response) + }); + }); + +}) \ No newline at end of file diff --git a/tests/functional/cypress/fixtures/health/healthCheck.json b/tests/functional/cypress/fixtures/health/healthCheck.json new file mode 100644 index 000000000..a2162ba8b --- /dev/null +++ b/tests/functional/cypress/fixtures/health/healthCheck.json @@ -0,0 +1,65 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "Branch": { + "type": "string" + }, + "BuildTimeStamp": { + "type": "string" + }, + "Githash": { + "type": "string" + }, + "Healths": { + "type": "array", + "items": [ + { + "type": "object", + "properties": { + "Duration": { + "type": "string" + }, + "Error": { + "type": "string" + }, + "Healthy": { + "type": "boolean" + }, + "Name": { + "type": "string" + }, + "TimeStamp": { + "type": "string" + } + }, + "required": [ + "Duration", + + "Healthy", + "Name", + "TimeStamp" + ] + } + ] + }, + "Status": { + "type": "string" + }, + "TimeStamp": { + "type": "string" + }, + "Version": { + "type": "string" + } + }, + "required": [ + "Branch", + "BuildTimeStamp", + "Githash", + "Healths", + "Status", + "TimeStamp", + "Version" + ] + } \ No newline at end of file From e24721a5a426860aa2b8a40597e2bd6e61ce7b6a Mon Sep 17 00:00:00 2001 From: veerendra thakur Date: Wed, 27 Sep 2023 17:55:46 +0530 Subject: [PATCH 2/2] Added cypress test case for cypress-version API Signed-off-by: veerendra thakur --- tests/functional/cypress/e2e/version.cy.ts | 32 +++++++++++++++++++ .../cypress/fixtures/version/getVersion.json | 24 ++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/functional/cypress/e2e/version.cy.ts create mode 100644 tests/functional/cypress/fixtures/version/getVersion.json diff --git a/tests/functional/cypress/e2e/version.cy.ts b/tests/functional/cypress/e2e/version.cy.ts new file mode 100644 index 000000000..0a4776a78 --- /dev/null +++ b/tests/functional/cypress/e2e/version.cy.ts @@ -0,0 +1,32 @@ +import {validateApiResponse,validate_200_Status,getTokenKey} from '../support/commands' + +describe("To Validate & check cla version via API call", function () { + + //Reference api doc: https://api-gw.dev.platform.linuxfoundation.org/cla-service/v4/api-docs#tag/version + const claEndpoint = `${Cypress.env("APP_URL")}cla-service/v4`; + + let bearerToken: string = null; + before(() => { + if(bearerToken==null){ + getTokenKey(bearerToken); + cy.window().then((win) => { + bearerToken = win.localStorage.getItem('bearerToken'); + }); + } + }); + +it("Returns the application version information- Record should Returns 200 Response", function () { + cy.request({ + method: 'GET', + url: `${claEndpoint}/ops/version`, + auth: { + 'bearer': bearerToken, + } + }).then((response) => { + validate_200_Status(response); + //To validate schema of response + validateApiResponse("version/getVersion.json",response) + }); + }); + +}) \ No newline at end of file diff --git a/tests/functional/cypress/fixtures/version/getVersion.json b/tests/functional/cypress/fixtures/version/getVersion.json new file mode 100644 index 000000000..f2762f3db --- /dev/null +++ b/tests/functional/cypress/fixtures/version/getVersion.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "branch": { + "type": "string" + }, + "buildDate": { + "type": "string" + }, + "commit": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "required": [ + "branch", + "buildDate", + "commit", + "version" + ] + } \ No newline at end of file