Skip to content

Commit

Permalink
Restructuring files into two groups REST APIs and UI
Browse files Browse the repository at this point in the history
Signed-off-by: Dhanush0369 <[email protected]>
  • Loading branch information
Dhanush0369 committed May 6, 2024
1 parent bed2e60 commit 00d3f89
Show file tree
Hide file tree
Showing 10 changed files with 1,273 additions and 4 deletions.
104 changes: 104 additions & 0 deletions chaoscenter/cypress/e2e/REST APIs/UserManagment.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
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');

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 00d3f89

Please sign in to comment.