-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
129 changes: 129 additions & 0 deletions
129
e2e-tests/cypress/e2e/api-tests/000_accounts/postUpdatePassword.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import { METHOD, STATUS_CODE } from "../../../support/api/api-const"; | ||
import API from "../../../support/ApiUrls"; | ||
|
||
context("Update password", { tags: ['accounts', 'firstPool', 'all'] }, () => { | ||
const name = "TestUserRegistration"; | ||
|
||
it("Change password", () => { | ||
cy.request({ | ||
method: METHOD.POST, | ||
url: API.ApiServer + API.ChangePassword, | ||
body: { | ||
username: name, | ||
oldPassword: "test", | ||
newPassword: "test1" | ||
} | ||
}).then((response) => { | ||
expect(response.status).to.eq(STATUS_CODE.OK); | ||
expect(response.body).to.have.property("username", name); | ||
expect(response.body).to.have.property("role", "USER"); | ||
}).then(() => { | ||
cy.request({ | ||
method: METHOD.POST, | ||
url: API.ApiServer + API.AccountsLogin, | ||
body: { | ||
username: name, | ||
password: "test1" | ||
} | ||
}).then((response) => { | ||
expect(response.status).to.eq(STATUS_CODE.OK); | ||
expect(response.body).to.have.property("username", name); | ||
expect(response.body).to.have.property("role", "USER"); | ||
}); | ||
cy.request({ | ||
method: METHOD.POST, | ||
url: API.ApiServer + API.AccountsLogin, | ||
body: { | ||
username: name, | ||
password: "test" | ||
}, | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(STATUS_CODE.UNAUTHORIZED); | ||
}); | ||
}); | ||
}); | ||
|
||
it("Change password without body - Negative", () => { | ||
cy.request({ | ||
method: METHOD.POST, | ||
url: API.ApiServer + API.ChangePassword, | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(STATUS_CODE.UNPROCESSABLE); | ||
}) | ||
}); | ||
|
||
it("Change password with wrong password body - Negative", () => { | ||
cy.request({ | ||
method: METHOD.POST, | ||
url: API.ApiServer + API.ChangePassword, | ||
body: { | ||
username: name, | ||
oldPassword: "test", | ||
newPassword: "test2" | ||
}, | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(STATUS_CODE.UNAUTHORIZED); | ||
}) | ||
}); | ||
|
||
it('Change password without username - Negative', () => { | ||
cy.request({ | ||
method: METHOD.POST, | ||
url: API.ApiServer + API.ChangePassword, | ||
body: { | ||
oldPassword: "test", | ||
newPassword: "test1" | ||
}, | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(STATUS_CODE.UNPROCESSABLE); | ||
}) | ||
}); | ||
|
||
it('Change password without old password - Negative', () => { | ||
cy.request({ | ||
method: METHOD.POST, | ||
url: API.ApiServer + API.ChangePassword, | ||
body: { | ||
username: name, | ||
newPassword: "test1" | ||
}, | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(STATUS_CODE.UNPROCESSABLE); | ||
}) | ||
}); | ||
|
||
it('Change password with wrong username - Negative', () => { | ||
cy.request({ | ||
method: METHOD.POST, | ||
url: API.ApiServer + API.ChangePassword, | ||
body: { | ||
username: name + "fdsafds", | ||
oldPassword: "test", | ||
newPassword: "test1" | ||
}, | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(STATUS_CODE.UNAUTHORIZED); | ||
}) | ||
}); | ||
|
||
it('Change password with sql infection - Negative', () => { | ||
cy.request({ | ||
method: METHOD.POST, | ||
url: API.ApiServer + API.ChangePassword, | ||
body: { | ||
username: 'select * from users where id = 1 or 1=1', | ||
oldPassword: "test", | ||
newPassword: "test1" | ||
}, | ||
failOnStatusCode: false | ||
}).then((response) => { | ||
expect(response.status).to.eq(STATUS_CODE.UNAUTHORIZED); | ||
}) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters