Skip to content

Commit

Permalink
Adding Chaoscenter e2e tests (#405)
Browse files Browse the repository at this point in the history
* Chaoscenter e2e tests

Signed-off-by: Dhanush0369 <dhanush789245@gmail.com>

* Updated chaosinfra tests

Signed-off-by: Dhanush0369 <dhanush789245@gmail.com>

* Completed chaosInfra tests

Signed-off-by: Dhanush0369 <dhanush789245@gmail.com>

* Updated chaosInfra tests

Signed-off-by: Dhanush0369 <dhanush789245@gmail.com>

* Added chaosprobes test

Signed-off-by: Dhanush0369 <dhanush789245@gmail.com>

* Updated chaosprobes tests

Signed-off-by: Dhanush0369 <dhanush789245@gmail.com>

* Added User Managment and Negative tests

Signed-off-by: Dhanush0369 <dhanush789245@gmail.com>

* Restructuring files into two groups REST APIs and UI

Signed-off-by: Dhanush0369 <dhanush789245@gmail.com>

* Delete Previous Files

Signed-off-by: Dhanush0369 <dhanush789245@gmail.com>

* Addition of chaoshub,chaosInfra and Negative test cases

Signed-off-by: Dhanush0369 <dhanush789245@gmail.com>

---------

Signed-off-by: Dhanush0369 <dhanush789245@gmail.com>
  • Loading branch information
Dhanush0369 committed May 15, 2024
1 parent 1e83cb7 commit e813226
Show file tree
Hide file tree
Showing 20 changed files with 4,069 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
**/videos
**/screenshots
**/cypress/downloads
agent-manifest.yaml
agent-manifest.yaml
**/chaoscenter/node_modules
**/chaoscenter/cypress/downloads
13 changes: 13 additions & 0 deletions chaoscenter/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
e2e: {
baseUrl: 'http://192.168.49.2:30829',
requestTimeout: 60000,
responseTimeout: 60000
},
env: {
username: 'admin',
password: 'litmus'
},
});
124 changes: 124 additions & 0 deletions chaoscenter/cypress/e2e/REST APIs/UserManagment.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
describe('Test Cases for User-Management', () => {
let user;
beforeEach(() => {
cy.requestLogin(Cypress.env('username'),Cypress.env('password'));
cy.fixture("Users").then((User) => {
user = User.user1;
});
});

it('Create New User', () => {
const accessToken = localStorage.getItem('accessToken');

//add user
const add_payload = {
name: user.name,
email: user.email,
username: user.username,
password: user.password,
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(add_payload.username);
expect(response.body.email).to.eq(add_payload.email);
expect(response.body.name).to.eq(add_payload.name);
});
});

it('Negative test case for User management [Get error when creating User with same name]', () => {
const accessToken = localStorage.getItem('accessToken');

//add user
const add_payload = {
name: user.name,
email: user.email,
username: user.username,
password: user.password,
role: 'user'
};

cy.request({
method: 'POST',
url: '/auth/create_user',
headers: {
Authorization: `Bearer ${accessToken}`
},
body: add_payload,
failOnStatusCode: false,
}).then((response) => {
expect(response.body.error).to.equal('user_exists');
});
})

it('Edit user password', () => {
const accessToken = localStorage.getItem('accessToken');

const edit_payload = {
username: user.username,
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');
});
});

it('Disable user', () => {
const accessToken = localStorage.getItem('accessToken');

//negative test case for disable user
const disable_payload1 = {
username: '123',
isDeactivate: true
};

cy.request({
method: 'POST',
url: '/auth/update/state',
failOnStatusCode: false,
headers: {
Authorization: `Bearer ${accessToken}`
},
body: disable_payload1,
}).then((response) => {
expect(response.body.error).to.equal('user does not exist');
});


//disable user
const disable_payload = {
username: user.username,
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");
});
});
});
Loading

0 comments on commit e813226

Please sign in to comment.