diff --git a/chaoscenter/cypress/e2e/UserManagment.cy.js b/chaoscenter/cypress/e2e/UserManagment.cy.js deleted file mode 100644 index fa46f41ee..000000000 --- a/chaoscenter/cypress/e2e/UserManagment.cy.js +++ /dev/null @@ -1,105 +0,0 @@ -describe('testing UserManagement', () => { - before(() => { - cy.requestLogin(Cypress.env('username'),Cypress.env('password')); - }); - - it('tesing through REST APIs', () => { - const accessToken = localStorage.getItem('accessToken'); - - //add user - const add_payload = { - name: 'user10', - email: 'user10@gmail.com', - username: 'user10', - password: 'user10', - role: 'user' - }; - - cy.request({ - method: 'POST', - url: '/auth/create_user', - headers: { - Authorization: `Bearer ${accessToken}` - }, - body: add_payload, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.username).to.eq(payload.username); - expect(response.body.email).to.eq(payload.email); - expect(response.body.name).to.eq(payload.name); - }); - - //edit password - const edit_payload = { - username: 'user10', - oldPassword: '', - newPassword: '1' - }; - - cy.request({ - method: 'POST', - url: '/auth/reset/password', - headers: { - Authorization: `Bearer ${accessToken}` - }, - body: edit_payload, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.message).to.eq('password has been reset successfully'); - }); - - //disable user - const disable_payload = { - username: 'user10', - isDeactivate: true - }; - - cy.request({ - method: 'POST', - url: '/auth/update/state', - headers: { - Authorization: `Bearer ${accessToken}` - }, - body: disable_payload, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.message).to.eq("user's state updated successfully"); - }); - }) - - it('testing through UI', () => { - cy.login(Cypress.env('username'),Cypress.env('password')); - - cy.get('.chaos_MainNav-module_navItem_MxEeXl').eq(1).click(); - cy.contains('User Management').click(); - - //create user - cy.contains('New User').click(); - cy.get('input[name="name"]').type('User22222'); - cy.get('input[name="email"]').type('User22222@gmail.com'); - cy.get('input[name="username"]').type('User22222'); - cy.get('input[name="password"]').type('User22222'); - cy.get('input[name="reEnterPassword"]').type('User22222'); - cy.intercept('POST','/auth/create_user').as('user'); - cy.get('button[aria-label="Confirm"]').click(); - cy.wait('@user'); - - //edit user - cy.get('.bp3-popover-wrapper .bp3-button').then((buttons) => { - cy.wrap(buttons[buttons.length - 1]).click(); - }); - cy.contains('Reset Password').click(); - cy.get('input[name="password"]').type('22222'); - cy.get('input[name="reEnterPassword"]').type('22222'); - cy.intercept('POST','/auth/reset/password').as('reset'); - cy.contains('Confirm').click(); - cy.wait('@reset'); - - //disable User - cy.get('.bp3-popover-target').then((buttons) => { - cy.wrap(buttons[buttons.length - 1]).click(); - }); - cy.contains('Disable User').click(); - cy.contains('Confirm').click(); - }) -}); \ No newline at end of file diff --git a/chaoscenter/cypress/e2e/chaosProbes.cy.js b/chaoscenter/cypress/e2e/chaosProbes.cy.js deleted file mode 100644 index 8e1a630c5..000000000 --- a/chaoscenter/cypress/e2e/chaosProbes.cy.js +++ /dev/null @@ -1,668 +0,0 @@ -import { add_httpProbe, add_CMDProbe, delete_httpprobe, update_httpProbe, update_CMDProbe, delete_CMDprobe, add_PROMProbe, update_PROMProbe, delete_PROMProbe, add_k8sProbe, update_k8sProbe, delete_k8sProbe } from "../fixtures/chaosprobes"; - -describe('Testing http chaos Probes', () => { - before(() => { - cy.requestLogin(Cypress.env('username'),Cypress.env('password')); - }); - - it('testing through REST APIs', () => { - const accessToken = localStorage.getItem('accessToken'); - const projectID = localStorage.getItem('projectID'); - - //add Probe - const add_httpProbe_payload = { - operationName: "addKubernetesHTTPProbe", - variables: { - projectID: projectID, - request: { - name: "exp1", - description: '', - tags: [], - type: 'httpProbe', - infrastructureType: 'Kubernetes', - kubernetesHTTPProperties: { - probeTimeout: '1s', - interval: '1s', - probePollingInterval: '1s', - evaluationTimeout: '1s', - retry: 5, - url: 'http://localhost:3000', - method: { - get: { criteria: '==', responseCode: '200' } - } - } - } - }, - query: add_httpProbe - }; - - cy.request({ - method: 'POST', - url: '/api/query', - body: add_httpProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.addProbe.name).to.equal("exp1"); - }); - - //update probe - const update_httpProbe_payload = { - operationName: "updateProbe", - variables: { - projectID: projectID, - request: { - name: "exp1", - description: '', - tags: [], - type: 'httpProbe', - infrastructureType: 'Kubernetes', - kubernetesHTTPProperties: { - probeTimeout: '3s', - interval: '1s', - probePollingInterval: '1s', - evaluationTimeout: '1s', - retry: 5, - url: 'http://localhost:3000', - method: { - get: { criteria: '==', responseCode: '200' } - } - } - } - }, - query: update_httpProbe - }; - - cy.request({ - method: 'POST', - url: '/api/query', - body: update_httpProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.updateProbe).to.equal("Updated successfully"); - }); - - //delete probe - const deleteProbe_payload = { - operationName: 'deleteProbe', - variables: { - projectID: projectID, - probeName: "exp1" - }, - query: delete_httpprobe - } - - cy.request({ - method: 'POST', - url: '/api/query', - body: deleteProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.deleteProbe).to.equal(true); - }); - }); - - - it('Testing through UI', () =>{ - cy.login(Cypress.env('username'),Cypress.env('password')); - cy.contains('Resilience Probes').click(); - - //create Probe - cy.contains('New Probe').click(); - cy.contains('HTTP').click(); - cy.get('input[name="name"]').type('exp2'); - cy.contains('Configure Properties').click(); - cy.get('input[name="kubernetesHTTPProperties.probeTimeout"]').type('1s'); - cy.get('input[name="kubernetesHTTPProperties.interval"]').type('1s'); - cy.get('input[name="kubernetesHTTPProperties.retry"]').type('5'); - cy.get('input[name="kubernetesHTTPProperties.attempt"]').type('5'); - cy.get('input[name="kubernetesHTTPProperties.probePollingInterval"]').type('1s'); - cy.get('input[name="kubernetesHTTPProperties.evaluationTimeout"]').type('1s'); - cy.contains('Configure Details').click(); - cy.get('input[name="kubernetesHTTPProperties.url"]').type('http://localhost:3000'); - cy.get('input[name="kubernetesHTTPProperties.methodDropdown"]').type('GET'); - cy.contains('GET').click(); - cy.get('input[name="kubernetesHTTPProperties.method.get.criteria"]').type('=='); - cy.contains('==').click(); - cy.get('input[name="kubernetesHTTPProperties.method.get.responseCode"]').type('200'); - cy.contains('Setup Probe').click(); - - //update Probe - cy.get('.TableV2--cell .bp3-button').then(buttons => { - cy.wrap(buttons[buttons.length - 1]).click(); - }); - cy.contains('Edit Probe').click(); - cy.contains('Configure Properties').click(); - cy.get('input[name="kubernetesHTTPProperties.probeTimeout"]').clear().type('3s'); - cy.contains('Configure Details').click(); - cy.contains('Setup Probe').click(); - cy.on('window alert', () => { - expect(message).to.equal('Updated successfully'); - }); - - //delete probe - cy.get('.TableV2--cell .bp3-button').then(buttons => { - cy.wrap(buttons[buttons.length - 1]).click(); - }); - cy.contains('Delete Probe').click(); - cy.intercept('POST','/api/query').as('Query'); - cy.contains('Confirm').click(); - cy.wait('@Query'); - }); -}); - -describe('testing CMD chaos probes', () => { - before(() => { - cy.requestLogin(Cypress.env('username'),Cypress.env('password')); - }); - - it('testing through REST APIs', () => { - const accessToken = localStorage.getItem('accessToken'); - const projectID = localStorage.getItem('projectID'); - - //add Probe - const addCMDProbe_payload = { - operationName: "addKubernetesCMDProbe", - variables: { - projectID: projectID, - request: { - name: "exp3", - description: "", - tags: [], - type: "cmdProbe", - infrastructureType: "Kubernetes", - kubernetesCMDProperties: { - probeTimeout: "1s", - interval: "1s", - retry: 1, - attempt: 1, - probePollingInterval: "1s", - evaluationTimeout: "1s", - command: "run", - comparator: { - type: "int", - criteria: "==", - value: "1", - }, - }, - }, - }, - query: add_CMDProbe, - }; - - cy.request({ - method: "POST", - url: "/api/query", - body: addCMDProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.addProbe.name).to.equal("exp3"); - }); - - //update probe - const updateCMDProbe_payload = { - operationName: "updateProbe", - variables: { - projectID: projectID, - request: { - name: "exp3", - description: "", - tags: [], - type: "cmdProbe", - infrastructureType: "Kubernetes", - kubernetesCMDProperties: { - probeTimeout: "3s", - interval: "1s", - retry: 1, - attempt: 1, - evaluationTimeout: "1s", - probePollingInterval: "1s", - initialDelay: null, - stopOnFailure: null, - command: "run", - comparator: { - type: "int", - value: "1", - criteria: "==", - }, - source: null, - }, - }, - }, - query: update_CMDProbe, - }; - - cy.request({ - method: "POST", - url: "/api/query", - body: updateCMDProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.updateProbe).to.equal("Updated successfully"); - }); - - //delete probe - const deleteCMDProbe_payload = { - operationName: "deleteProbe", - variables: { - projectID: projectID, - probeName: "exp3", - }, - query: delete_CMDprobe, - }; - - cy.request({ - method: "POST", - url: "/api/query", - body: deleteCMDProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.deleteProbe).to.equal(true); - }); - - }); - - it('testing through UI', () => { - cy.login(Cypress.env('username'),Cypress.env('password')); - cy.contains('Resilience Probes').click(); - - //create Probe - cy.contains('New Probe').click(); - cy.contains('Command').click(); - cy.get('input[name="name"]').type('exp4'); - cy.contains('Configure Properties').click(); - cy.get('input[name="kubernetesCMDProperties.probeTimeout"]').type('1s'); - cy.get('input[name="kubernetesCMDProperties.interval"]').type('1s'); - cy.get('input[name="kubernetesCMDProperties.retry"]').type('5'); - cy.get('input[name="kubernetesCMDProperties.attempt"]').type('5'); - cy.get('input[name="kubernetesCMDProperties.probePollingInterval"]').type('1s'); - cy.get('input[name="kubernetesCMDProperties.evaluationTimeout"]').type('1s'); - cy.contains('Configure Details').click(); - cy.get('textarea[name="kubernetesCMDProperties.command"]').type('run'); - cy.get('input[name="kubernetesCMDProperties.comparator.type"]').type('int'); - cy.contains('Int').click(); - cy.get('input[name="kubernetesCMDProperties.comparator.criteria"]').type('=='); - cy.contains('==').click(); - cy.get('input[name="kubernetesCMDProperties.comparator.value"]').type('1'); - cy.contains('Setup Probe').click(); - - //update Probe - cy.get('.TableV2--cell .bp3-button').then(buttons => { - cy.wrap(buttons[buttons.length - 1]).click(); - }); - cy.contains('Edit Probe').click(); - cy.contains('Configure Properties').click(); - cy.get('input[name="kubernetesCMDProperties.probeTimeout"]').clear().type('3s'); - cy.contains('Configure Details').click(); - cy.contains('Setup Probe').click(); - cy.on('window alert', () => { - expect(message).to.equal('Updated successfully'); - }); - - //delete probe - cy.get('.TableV2--cell .bp3-button').then(buttons => { - cy.wrap(buttons[buttons.length - 1]).click(); - }); - cy.contains('Delete Probe').click(); - cy.intercept('POST','/api/query').as('Query'); - cy.contains('Confirm').click(); - cy.wait('@Query'); - }); -}); - -describe('testing prometheus chaos probes', () => { - before(() => { - cy.requestLogin(Cypress.env('username'),Cypress.env('password')); - }); - - it('testing through REST APIs', () => { - const accessToken = localStorage.getItem('accessToken'); - const projectID = localStorage.getItem('projectID'); - - //add Probe - const addPROMProbe_payload = { - operationName: "addPROMProbe", - variables: { - projectID: projectID, - request: { - name: "exp5", - description: "", - tags: [], - type: "promProbe", - infrastructureType: "Kubernetes", - promProperties: { - probeTimeout: "1s", - interval: "1s", - retry: 1, - attempt: 1, - probePollingInterval: "1s", - evaluationTimeout: "1s", - endpoint: "http://localhost:3000", - query: "run", - comparator: { - type: "int", - criteria: "==", - value: "1", - }, - }, - }, - }, - query: add_PROMProbe, - }; - - cy.request({ - method: "POST", - url: "/api/query", - body: addPROMProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.addProbe.name).to.equal("exp5"); - }); - - //update probe - const updatePROMProbe_payload = { - operationName: "updateProbe", - variables: { - projectID: projectID, - request: { - name: "exp5", - description: "", - tags: [], - type: "promProbe", - infrastructureType: "Kubernetes", - promProperties: { - probeTimeout: "3s", - interval: "1s", - retry: 1, - attempt: 1, - evaluationTimeout: "1s", - probePollingInterval: "1s", - initialDelay: null, - stopOnFailure: null, - endpoint: "http://localhost:3000", - query: "run", - queryPath: null, - comparator: { - type: "int", - value: "1", - criteria: "==", - }, - }, - }, - }, - query: update_PROMProbe, - }; - - cy.request({ - method: "POST", - url: "/api/query", - body: updatePROMProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.updateProbe).to.equal("Updated successfully"); - }); - - //delete probe - const deletePROMProbe_payload = { - operationName: "deleteProbe", - variables: { - projectID: projectID, - probeName: "exp5", - }, - query: delete_PROMProbe, - }; - - cy.request({ - method: "POST", - url: "/api/query", - body: deletePROMProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.deleteProbe).to.equal(true); - }); - - - }); - - it('testing through UI', () => { - cy.login(Cypress.env('username'),Cypress.env('password')); - cy.contains('Resilience Probes').click(); - - //create Probe - cy.contains('New Probe').click(); - cy.contains('Prometheus').click(); - cy.get('input[name="name"]').type('exp6'); - cy.contains('Configure Properties').click(); - cy.get('input[name="promProperties.probeTimeout"]').type('1s'); - cy.get('input[name="promProperties.interval"]').type('1s'); - cy.get('input[name="promProperties.retry"]').type('5'); - cy.get('input[name="promProperties.attempt"]').type('5'); - cy.get('input[name="promProperties.probePollingInterval"]').type('1s'); - cy.get('input[name="promProperties.evaluationTimeout"]').type('1s'); - cy.contains('Configure Details').click(); - cy.get('input[name="promProperties.endpoint"]').type('http://localhost:3000'); - cy.get('textarea[name="promProperties.query"]').type('run'); - cy.get('input[name="promProperties.comparator.type"]').type('int'); - cy.contains('Int').click(); - cy.get('input[name="promProperties.comparator.criteria"]').type('=='); - cy.contains('==').click(); - cy.get('input[name="promProperties.comparator.value"]').type('1'); - cy.contains('Setup Probe').click(); - - //update Probe - cy.get('.TableV2--cell .bp3-button').then(buttons => { - cy.wrap(buttons[buttons.length - 1]).click(); - }); - cy.contains('Edit Probe').click(); - cy.contains('Configure Properties').click(); - cy.get('input[name="promProperties.probeTimeout"]').clear().type('3s'); - cy.contains('Configure Details').click(); - cy.contains('Setup Probe').click(); - cy.on('window alert', () => { - expect(message).to.equal('Updated successfully'); - }); - - //delete probe - cy.get('.TableV2--cell .bp3-button').then(buttons => { - cy.wrap(buttons[buttons.length - 1]).click(); - }); - cy.contains('Delete Probe').click(); - cy.intercept('POST','/api/query').as('Query'); - cy.contains('Confirm').click(); - cy.wait('@Query'); - }); -}); - -describe('testing kubernetes chaos probes', () => { - before(() => { - cy.requestLogin(Cypress.env('username'),Cypress.env('password')); - }); - - it('testing through REST APIs', () => { - const accessToken = localStorage.getItem('accessToken'); - const projectID = localStorage.getItem('projectID'); - - //add Probe - const add_K8SProbe_payload = { - operationName: "addK8SProbe", - variables: { - projectID: projectID, - request: { - name: "exp7", - description: "", - tags: [], - type: "k8sProbe", - infrastructureType: "Kubernetes", - k8sProperties: { - probeTimeout: "1s", - interval: "1s", - retry: 1, - attempt: 1, - probePollingInterval: "1s", - evaluationTimeout: "1s", - group: "book", - version: "v1", - resource: "store", - namespace: "alpha", - operation: "delete", - }, - }, - }, - query: add_k8sProbe, - }; - - cy.request({ - method: "POST", - url: "/api/query", - body: add_K8SProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.addProbe.name).to.equal("exp7"); - }); - - //update probe - const update_K8SProbe_payload = { - operationName: "updateProbe", - variables: { - projectID: projectID, - request: { - name: "exp7", - description: "", - tags: [], - type: "k8sProbe", - infrastructureType: "Kubernetes", - k8sProperties: { - probeTimeout: "3s", - interval: "1s", - retry: 1, - attempt: 1, - evaluationTimeout: "1s", - probePollingInterval: "1s", - initialDelay: null, - stopOnFailure: null, - group: "book", - version: "v1", - resource: "store", - resourceNames: null, - namespace: "alpha", - fieldSelector: null, - labelSelector: null, - operation: "delete", - }, - }, - }, - query: update_k8sProbe, - }; - - cy.request({ - method: "POST", - url: "/api/query", - body: update_K8SProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.updateProbe).to.equal("Updated successfully"); - }); - - //delete probe - const delete_K8SProbe_payload = { - operationName: "deleteProbe", - variables: { - projectID: projectID, - probeName: "exp7", - }, - query: delete_k8sProbe, - }; - - cy.request({ - method: "POST", - url: "/api/query", - body: delete_K8SProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.deleteProbe).to.equal(true); - }); - - }); - - it('testing through UI', () => { - cy.login(Cypress.env('username'),Cypress.env('password')); - cy.contains('Resilience Probes').click(); - - //create Probe - cy.contains('New Probe').click(); - cy.contains('Kubernetes').click(); - cy.get('input[name="name"]').type('exp8'); - cy.contains('Configure Properties').click(); - cy.get('input[name="k8sProperties.probeTimeout"]').type('1s'); - cy.get('input[name="k8sProperties.interval"]').type('1s'); - cy.get('input[name="k8sProperties.retry"]').type('5'); - cy.get('input[name="k8sProperties.attempt"]').type('5'); - cy.get('input[name="k8sProperties.probePollingInterval"]').type('1s'); - cy.get('input[name="k8sProperties.evaluationTimeout"]').type('1s'); - cy.contains('Configure Details').click(); - cy.get('input[name="k8sProperties.group"]').type('book'); - cy.get('input[name="k8sProperties.version"]').type('v1'); - cy.get('input[name="k8sProperties.resource"]').type('store'); - cy.get('input[name="k8sProperties.namespace"]').type('alpha'); - cy.get('input[name="k8sProperties.operation"]').type('delete'); - cy.contains('Delete').click(); - cy.contains('Setup Probe').click(); - - //update Probe - cy.get('.TableV2--cell .bp3-button').then(buttons => { - cy.wrap(buttons[buttons.length - 1]).click(); - }); - cy.contains('Edit Probe').click(); - cy.contains('Configure Properties').click(); - cy.get('input[name="k8sProperties.probeTimeout"]').clear().type('3s'); - cy.contains('Configure Details').click(); - cy.contains('Setup Probe').click(); - cy.on('window alert', () => { - expect(message).to.equal('Updated successfully'); - }); - - //delete probe - cy.get('.TableV2--cell .bp3-button').then(buttons => { - cy.wrap(buttons[buttons.length - 1]).click(); - }); - cy.contains('Delete Probe').click(); - cy.intercept('POST','/api/query').as('Query'); - cy.contains('Confirm').click(); - cy.wait('@Query'); - }); -}); \ No newline at end of file diff --git a/chaoscenter/cypress/e2e/chaoshub.cy.js b/chaoscenter/cypress/e2e/chaoshub.cy.js deleted file mode 100644 index 91df6a7a4..000000000 --- a/chaoscenter/cypress/e2e/chaoshub.cy.js +++ /dev/null @@ -1,177 +0,0 @@ -import { add_hub,update_hub,delete_hub, list_hub } from "../fixtures/chaoshub"; - -describe('testing chaoshub', () => { - - before(() => { - cy.requestLogin(Cypress.env('username'),Cypress.env('password')); - }) - - it('testing ChaosHub functionality through REST APIs', () => { - const accessToken = localStorage.getItem('accessToken'); - const projectID = localStorage.getItem('projectID'); - - //Add new chaoshub with public repo - const addPayload = { - operationName: 'addChaosHub', - variables: { - projectID: projectID, - request: { - name: 'testing', - repoBranch: 'master', - description: '', - tags: [], - authType: 'NONE', - isPrivate: false, - repoURL: 'https://github.com/litmuschaos/chaos-charts', - }, - }, - query: add_hub, - }; - - cy.request({ - method: 'POST', - url: '/api/query', - body: addPayload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.addChaosHub.name).to.equal("testing"); - }); - - - //get hub id - const listPayload = { - operationName: 'listChaosHub', - variables: { - projectID: projectID, - request: { filter: { chaosHubName: "" } } - }, - query: list_hub, - }; - - cy.request({ - method: 'POST', - url: '/api/query', - body: listPayload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.status).to.equal(200); - localStorage.setItem('hubID',response.body.data.listChaosHub[1].id); - }); - - cy.wrap(null).then(() => { - const hubID = localStorage.getItem('hubID'); - - - //update chaoshub - const updatePayload = { - operationName: 'updateChaosHub', - variables: { - projectID: projectID, - request: { - id: hubID, - name: 'sample', - repoBranch: 'master', - description: '', - authType: 'NONE', - isPrivate: false, - repoURL: 'https://github.com/litmuschaos/chaos-charts', - sshPrivateKey: '', - sshPublicKey: '', - tags: [], - token: '' - } - }, - query: update_hub - }; - cy.request({ - method: 'POST', - url: '/api/query', - body: updatePayload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.updateChaosHub.name).to.equal("sample") - }); - - - //delete chaoshub - const deletePayload = { - operationName: 'deleteChaosHub', - variables: { - hubID: hubID, - projectID: projectID - }, - query: delete_hub - }; - cy.request({ - method: 'POST', - url: '/api/query', - body: deletePayload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.deleteChaosHub).to.equal(true); - }); - }); - }); - - it('testing ChaosHub functionality through UI', () => { - - cy.login(Cypress.env('username'),Cypress.env('password')); - cy.visit('/dashboard'); - cy.contains('ChaosHubs').click(); - cy.contains('Litmus ChaosHub').should('exist'); - cy.contains('Connected').should('exist'); - - - //Add new chaoshub with public repo - cy.contains('New ChaosHub').click(); - cy.get('input[name="name"]').type('testing1'); - cy.contains('Continue').click(); - cy.get('input[name="repoURL"]').type('https://github.com/litmuschaos/chaos-charts.git'); - cy.get('input[name="repoBranch"]').type('master'); - cy.intercept('POST','/api/query').as('Query'); - cy.get('button[aria-label = "Connect Hub"]').click(); - cy.wait('@Query'); - cy.on('window:alert', () => { - expect(message).to.equal('Chaoshub added successfully'); - }); - - - //Checks if chaoshub is connected - cy.get('[class="chaos_ChaosHubs-module_connectionStatus_PWHgAA"]').eq(1).contains('Connected').should('exist'); - cy.get('.bp3-card').eq(1).click(); - cy.contains('Chaos Faults (50)').should('exist'); - cy.contains('ChaosHubs').click(); - - - //Updating chaoshub name - cy.get('.Card--cardMenu .bp3-button').eq(1).click(); - cy.contains('Edit Hub').click(); - cy.get('input[name="name"]').clear().type('sample1'); - cy.contains('Continue').click(); - cy.get('button[aria-label = "Edit ChaosHub"]').click(); - cy.wait('@Query'); - cy.reload(); - cy.on('window:alert', () => { - expect(message).to.equal('Chaoshub updated successfully'); - }); - - - //delete chaoshub - cy.get('.Card--cardMenu .bp3-button').eq(1).click(); - cy.contains('Delete Hub').click(); - cy.on('window:alert', () => { - expect(message).to.equal('Hub Deleted Successfully'); - }); - }); -}); diff --git a/chaoscenter/cypress/e2e/chaosinfra.cy.js b/chaoscenter/cypress/e2e/chaosinfra.cy.js deleted file mode 100644 index a45ecf599..000000000 --- a/chaoscenter/cypress/e2e/chaosinfra.cy.js +++ /dev/null @@ -1,184 +0,0 @@ -import { create_env, list_infra, register_infra, update_infra, delete_infra } from "../fixtures/chaosinfra"; - -describe('testing chaosinfra', () => { - - before(() => { - cy.requestLogin(Cypress.env('username'),Cypress.env('password')); - }) - - it('testing chaosinfra through REST APIs', () => { - const accessToken = localStorage.getItem('accessToken'); - const projectID = localStorage.getItem('projectID'); - - //create Environment - const createEnv_payload = { - operatioName: 'createEnvironment', - variables: { - projectID: projectID, - request: { - description: "", - environmentID: "exp5", - name: "exp5", - tags: [], - type: "NON_PROD" - } - }, - query: create_env - }; - - cy.request({ - method: 'POST', - url: '/api/query', - body: createEnv_payload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.createEnvironment.name).to.equal("exp5"); - }); - - - //create Infra - const registerInfra_payload = { - operationName: 'registerInfra', - variables: { - projectID: projectID, - request: { - infraScope: 'cluster', - name: "exp5", - environmentID: "exp5", - description: '', - platformName: 'Kubernetes', - infraNamespace: 'litmus', - infraNsExists: false, - infraSaExists: false, - infrastructureType: 'Kubernetes', - serviceAccount: 'litmus', - skipSsl: false, - } - }, - query: register_infra - }; - - cy.request({ - method: 'POST', - url: '/api/query', - body: registerInfra_payload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data).to.have.property('registerInfra'); - }) - - - //get InfraID - const listInfra_payload = { - operationName: 'listInfras', - variables: { - projectID: projectID, - request: { environmentIDs: ["exp5"] }, - }, - query: list_infra - }; - - cy.request({ - method: 'POST', - url: '/api/query', - headers: { - Authorization: `Bearer ${accessToken}` - }, - body: listInfra_payload, - }).then((response) => { - expect(response.status).to.equal(200); - localStorage.setItem('infraID', response.body.data.listInfras.infras[0].infraID); - }); - - cy.wrap(null).then(() => { - const infraID = localStorage.getItem('infraID'); - - //update Infra - const updateInfra_payload = { - operationName: 'getInfraManifest', - variables: { - projectID: projectID, - infraID: infraID, - upgrade: true, - }, - query: update_infra, - }; - - cy.request({ - method: 'POST', - url: '/api/query', - headers: { - Authorization: `Bearer ${accessToken}` - }, - body: updateInfra_payload, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data).to.have.property('getInfraManifest'); - }); - - //disable Infra - const deleteInfra_payload = { - operationName: 'deleteInfra', - variables: { - projectID: projectID, - infraID: infraID, - }, - query: delete_infra, - }; - - cy.request({ - method: 'POST', - url: '/api/query', - headers: { - Authorization: `Bearer ${accessToken}` - }, - body: deleteInfra_payload, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.deleteInfra).to.equal("infra deleted successfully"); - }); - }); - }); - - it('testing chaosinfra through UI', () => { - cy.login(Cypress.env('username'),Cypress.env('password')); - cy.contains('Environments').click(); - - //adding chaosinfra - cy.get('.TableV2--row').eq(0).click(); - cy.contains('Enable Chaos').click(); - cy.get('.bp3-form-content').type('exp97'); - cy.contains('Next').click(); - cy.contains('Next').click(); - cy.contains('Download').click(); - cy.on('window alert', () => { - expect(message).to.equal('Chaos infrastructure successfully created'); - }); - cy.contains('Done').click(); - - //updating chaosinfra - cy.contains('Update').eq(0).click(); - cy.get('button[aria-label= "Download"]').click(); - cy.on('window alert', () => { - expect(message).to.equal('Download request successfully sent'); - }); - cy.contains('Done').click(); - cy.on('window alert', () => { - expect(message).to.equal('Upgrade manifest downloaded successfully'); - }); - - //disable chaosinfra - cy.get('.Card--dots').eq(0).click(); - cy.contains('Disable').click(); - cy.contains('Confirm').click(); - cy.on('window alert', () => { - expect(message).to.equal('Chaos Infrastructure Successfully Disabled'); - }); - }); -}); \ No newline at end of file diff --git a/chaoscenter/cypress/e2e/login.cy.js b/chaoscenter/cypress/e2e/login.cy.js deleted file mode 100644 index 41d5c3d63..000000000 --- a/chaoscenter/cypress/e2e/login.cy.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('Testing login page of chaoscenter', () => { - it('testing login with valid data', () => { - cy.login(Cypress.env('username'),Cypress.env('password')); - }); - - it('testing login thorugh REST API', () => { - cy.requestLogin(Cypress.env('username'),Cypress.env('password')); - }); -}); \ No newline at end of file diff --git a/chaoscenter/cypress/e2e/negative_tests.cy.js b/chaoscenter/cypress/e2e/negative_tests.cy.js deleted file mode 100644 index 174a0bce9..000000000 --- a/chaoscenter/cypress/e2e/negative_tests.cy.js +++ /dev/null @@ -1,469 +0,0 @@ -import { add_hub } from "../fixtures/chaoshub"; -import { create_env } from "../fixtures/chaosinfra"; -import { add_CMDProbe, add_PROMProbe, add_httpProbe, add_k8sProbe } from "../fixtures/chaosprobes"; - -describe('negative test cases for login', () => { - it('testing with invalid login data through REST APIs', () => { - cy.request({ - method: "POST", - url: "auth/login", - failOnStatusCode: false, - body: { - username: 'invalid_user', - password: 'invalid_password', - }, - }).then((response) => { - expect(response.status).to.equal(400); - expect(response.body.error).to.equal('user does not exist'); - }); - }); - - it('testing with invalid login data through UI', () => { - cy.visit('/login'); - cy.get('input[name="username"]').type('invalid_user'); - cy.get('input[name="password"]').type('invalid_password'); - cy.get('.bp3-button').click(); - cy.on('window:alert', (message) => { - expect(message).to.equal('user does not exist'); - }); - }); -}) - -describe('negative tests for chaoshub', () => { - before(() => { - cy.requestLogin(Cypress.env('username'),Cypress.env('password')); - }); - - it('testing with exisitng chaoshub name through REST APIs', () => { - const accessToken = localStorage.getItem('accessToken'); - const projectID = localStorage.getItem('projectID'); - - //Add new chaoshub - const addPayload = { - operationName: 'addChaosHub', - variables: { - projectID: projectID, - request: { - name: 'testing1', - repoBranch: '1', - description: '', - tags: [], - authType: 'NONE', - isPrivate: false, - repoURL: '1', - }, - }, - query: add_hub, - }; - - cy.request({ - method: 'POST', - url: '/api/query', - body: addPayload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.status).to.equal(200); - }); - - //create chaoshub with same name - cy.request({ - method: 'POST', - url: '/api/query', - body: addPayload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.body.errors[0].message).to.equal('Name Already exists'); - }); -}); - - it('testing with exisitng chaoshub name through UI', () => { - cy.login(Cypress.env('username'),Cypress.env('password')); - cy.contains('ChaosHubs').click(); - cy.contains('Disconnected').should('exist'); - cy.contains('New ChaosHub').click(); - cy.get('input[name="name"]').type('testing1'); - cy.contains('Continue').click(); - cy.get('input[name="repoURL"]').type('1'); - cy.get('input[name="repoBranch"]').type('1'); - cy.get('button[aria-label = "Connect Hub"]').click(); - cy.on('window:alert', () => { - expect(message).to.equal('Name Already exists'); - }); - }); -}) - -describe('negative tests for environment', () => { - before(() => { - cy.requestLogin(Cypress.env('username'),Cypress.env('password')); - }); - - it('testing with existing environment name through REST APIs', () => { - const accessToken = localStorage.getItem('accessToken'); - const projectID = localStorage.getItem('projectID'); - - //create Environment - const createEnv_payload = { - operatioName: 'createEnvironment', - variables: { - projectID: projectID, - request: { - description: "", - environmentID: "exp1", - name: "exp1", - tags: [], - type: "NON_PROD" - } - }, - query: create_env - }; - - cy.request({ - method: 'POST', - url: '/api/query', - body: createEnv_payload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.status).to.equal(200); - }); - - //create environment with same name - cy.request({ - method: 'POST', - url: '/api/query', - body: createEnv_payload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.errors[0].message).to.equal('write exception: write errors: [E11000 duplicate key error collection: litmus.environment index: environment_id_1 dup key: { environment_id: "exp1" }]'); - }); - }) - - it('testing with existing environment name through UI', () => { - cy.login(Cypress.env('username'),Cypress.env('password')); - cy.contains('Environments').click(); - cy.contains('New Environment').click(); - cy.get('input[name="name"]').type('exp1'); - cy.contains('Save').click(); - cy.on('alert message', () => { - expect(message).to.equal('write exception: write errors: [E11000 duplicate key error collection: litmus.environment index: environment_id_1 dup key: { environment_id: "exp1" }]'); - }); - }); -}); - -describe('negative tests for HTTP chaos probe', () => { - before(() => { - cy.requestLogin(Cypress.env('username'),Cypress.env('password')); - }); - - it('testing with exisiting chaos probe through REST APIs', () => { - const accessToken = localStorage.getItem('accessToken'); - const projectID = localStorage.getItem('projectID'); - - //add Probe - const add_httpProbe_payload = { - operationName: "addKubernetesHTTPProbe", - variables: { - projectID: projectID, - request: { - name: "exp1", - description: '', - tags: [], - type: 'httpProbe', - infrastructureType: 'Kubernetes', - kubernetesHTTPProperties: { - probeTimeout: '1s', - interval: '1s', - probePollingInterval: '1s', - evaluationTimeout: '1s', - retry: 5, - url: 'http://localhost:3000', - method: { - get: { criteria: '==', responseCode: '200' } - } - } - } - }, - query: add_httpProbe - }; - - cy.request({ - method: 'POST', - url: '/api/query', - body: add_httpProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.addProbe.name).to.equal("exp1"); - }); - - //add probe with same name - cy.request({ - method: 'POST', - url: '/api/query', - body: add_httpProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}` - } - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.errors[0].message).to.equal('write exception: write errors: [E11000 duplicate key error collection: litmus.chaosProbes index: name_1 dup key: { name: "exp1" }]'); - }); - }) - - it('testing with existing chaos probe name through UI', () => { - cy.login(Cypress.env('username'),Cypress.env('password')); - cy.contains('Resilience Probes').click(); - - //try creating probe with same name - cy.contains('New Probe').click(); - cy.contains('HTTP').click(); - cy.get('input[name="name"]').type('exp1'); - cy.contains('Configure Properties').click(); - cy.contains('The name exp1 is not unique and was already used before, please provide a unique name').should('exist'); - }); -}); - -describe('negative tests for CMD chaos probe', () => { - before(() => { - cy.requestLogin(Cypress.env('username'),Cypress.env('password')); - }); - - it('testing with existing chaos probe name through REST APIs', () => { - const accessToken = localStorage.getItem('accessToken'); - const projectID = localStorage.getItem('projectID'); - - //add Probe - const addCMDProbe_payload = { - operationName: "addKubernetesCMDProbe", - variables: { - projectID: projectID, - request: { - name: "exp2", - description: "", - tags: [], - type: "cmdProbe", - infrastructureType: "Kubernetes", - kubernetesCMDProperties: { - probeTimeout: "1s", - interval: "1s", - retry: 1, - attempt: 1, - probePollingInterval: "1s", - evaluationTimeout: "1s", - command: "run", - comparator: { - type: "int", - criteria: "==", - value: "1", - }, - }, - }, - }, - query: add_CMDProbe, - }; - - cy.request({ - method: "POST", - url: "/api/query", - body: addCMDProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.addProbe.name).to.equal("exp2"); - }); - - //add probe with same name - cy.request({ - method: "POST", - url: "/api/query", - body: addCMDProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.errors[0].message).to.equal('write exception: write errors: [E11000 duplicate key error collection: litmus.chaosProbes index: name_1 dup key: { name: "exp2" }]'); - }); - }); - - it('testing with exisisting chaos probe name through UI', () => { - cy.login(Cypress.env('username'),Cypress.env('password')); - cy.contains('Resilience Probes').click(); - - //try creating probe with same name - cy.contains('New Probe').click(); - cy.contains('Command').click(); - cy.get('input[name="name"]').type('exp2'); - cy.contains('Configure Properties').click(); - cy.contains('The name exp2 is not unique and was already used before, please provide a unique name').should('exist'); - }); -}); - -describe('negative tests for prometheus chaos probe', () => { - before(() => { - cy.requestLogin(Cypress.env('username'),Cypress.env('password')); - }); - - it('testing with existing chaos probe name through REST APIs', () => { - const accessToken = localStorage.getItem('accessToken'); - const projectID = localStorage.getItem('projectID'); - - //add Probe - const addPROMProbe_payload = { - operationName: "addPROMProbe", - variables: { - projectID: projectID, - request: { - name: "exp3", - description: "", - tags: [], - type: "promProbe", - infrastructureType: "Kubernetes", - promProperties: { - probeTimeout: "1s", - interval: "1s", - retry: 1, - attempt: 1, - probePollingInterval: "1s", - evaluationTimeout: "1s", - endpoint: "http://localhost:3000", - query: "run", - comparator: { - type: "int", - criteria: "==", - value: "1", - }, - }, - }, - }, - query: add_PROMProbe, - }; - - cy.request({ - method: "POST", - url: "/api/query", - body: addPROMProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.addProbe.name).to.equal("exp3"); - }); - - //add Probe with same name - cy.request({ - method: "POST", - url: "/api/query", - body: addPROMProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.errors[0].message).to.equal('write exception: write errors: [E11000 duplicate key error collection: litmus.chaosProbes index: name_1 dup key: { name: "exp3" }]'); - }); - }); - - it('testing with exisisting chaos probe name through UI', () => { - cy.login(Cypress.env('username'),Cypress.env('password')); - cy.contains('Resilience Probes').click(); - - //try creating probe with same name - cy.contains('New Probe').click(); - cy.contains('Prometheus').click(); - cy.get('input[name="name"]').type('exp3'); - cy.contains('Configure Properties').click(); - cy.contains('The name exp3 is not unique and was already used before, please provide a unique name').should('exist'); - }); -}); - -describe('negative tests for Kubernetes chaos probe', () => { - before(() => { - cy.requestLogin(Cypress.env('username'),Cypress.env('password')); - }); - - it('testing with existing chaos probe name through REST APIs', () => { - const accessToken = localStorage.getItem('accessToken'); - const projectID = localStorage.getItem('projectID'); - - //add Probe - const add_K8SProbe_payload = { - operationName: "addK8SProbe", - variables: { - projectID: projectID, - request: { - name: "exp4", - description: "", - tags: [], - type: "k8sProbe", - infrastructureType: "Kubernetes", - k8sProperties: { - probeTimeout: "1s", - interval: "1s", - retry: 1, - attempt: 1, - probePollingInterval: "1s", - evaluationTimeout: "1s", - group: "book", - version: "v1", - resource: "store", - namespace: "alpha", - operation: "delete", - }, - }, - }, - query: add_k8sProbe, - }; - - cy.request({ - method: "POST", - url: "/api/query", - body: add_K8SProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.data.addProbe.name).to.equal("exp4"); - }); - - //add Porbe with same name - cy.request({ - method: "POST", - url: "/api/query", - body: add_K8SProbe_payload, - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }).then((response) => { - expect(response.status).to.equal(200); - expect(response.body.errors[0].message).to.equal('write exception: write errors: [E11000 duplicate key error collection: litmus.chaosProbes index: name_1 dup key: { name: "exp4" }]'); - }); - }); - - it('testing with exisisting chaos probe name through UI', () => { - cy.login(Cypress.env('username'),Cypress.env('password')); - cy.contains('Resilience Probes').click(); - - //try creating probe with same name - cy.contains('New Probe').click(); - cy.contains('Kubernetes').click(); - cy.get('input[name="name"]').type('exp4'); - cy.contains('Configure Properties').click(); - cy.contains('The name exp4 is not unique and was already used before, please provide a unique name').should('exist'); - }); -}); -