mirror of
https://github.com/thelounge/thelounge
synced 2024-11-25 21:40:22 +00:00
dd05ee3a65
Co-authored-by: Eric Nemchik <eric@nemchik.com> Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import {expect} from "chai";
|
|
import Helper from "../../server/helper";
|
|
|
|
describe("Client passwords", function () {
|
|
this.slow(1500);
|
|
|
|
const inputPassword = "my$Super@Cool Password";
|
|
|
|
it("hashed password should match", function () {
|
|
// Generated with third party tool to test implementation
|
|
const comparedPassword = Helper.password.compare(
|
|
inputPassword,
|
|
"$2a$11$zrPPcfZ091WNfs6QrRHtQeUitlgrJcecfZhxOFiQs0FWw7TN3Q1oS"
|
|
);
|
|
|
|
return comparedPassword.then((result) => {
|
|
expect(result).to.be.true;
|
|
});
|
|
});
|
|
|
|
it("wrong hashed password should not match", function () {
|
|
// Compare against a fake hash
|
|
const comparedPassword = Helper.password.compare(
|
|
inputPassword,
|
|
"$2a$11$zrPPcfZ091WRONGPASSWORDitlgrJcecfZhxOFiQs0FWw7TN3Q1oS"
|
|
);
|
|
|
|
return comparedPassword.then((result) => {
|
|
expect(result).to.be.false;
|
|
});
|
|
});
|
|
|
|
it("freshly hashed password should match", function () {
|
|
const hashedPassword = Helper.password.hash(inputPassword);
|
|
const comparedPassword = Helper.password.compare(inputPassword, hashedPassword);
|
|
|
|
return comparedPassword.then((result) => {
|
|
expect(result).to.be.true;
|
|
});
|
|
});
|
|
|
|
it("shout passwords should be marked as old", function () {
|
|
expect(
|
|
Helper.password.requiresUpdate(
|
|
"$2a$08$K4l.hteJcCP9D1G5PANzYuBGvdqhUSUDOLQLU.xeRxTbvtp01KINm"
|
|
)
|
|
).to.be.true;
|
|
expect(
|
|
Helper.password.requiresUpdate(
|
|
"$2a$11$zrPPcfZ091WNfs6QrRHtQeUitlgrJcecfZhxOFiQs0FWw7TN3Q1oS"
|
|
)
|
|
).to.be.false;
|
|
});
|
|
});
|