Changeset View
Changeset View
Standalone View
Standalone View
lib/app/base-chips/collections/users.subtest.js
Show All 34 Lines | it("should properly handle route to account cration", async () => | ||||
assert(response.includes("Uzupełnij dane o Twoim koncie")); | assert(response.includes("Uzupełnij dane o Twoim koncie")); | ||||
})); | })); | ||||
}); | }); | ||||
describe("users routes", () => { | describe("users routes", () => { | ||||
it("should correctly handle me when not logged in", async () => | it("should correctly handle me when not logged in", async () => | ||||
with_running_app(async ({ app, rest_api }) => { | with_running_app(async ({ app, rest_api }) => { | ||||
await assert_throws_async( | await assert_throws_async( | ||||
async () => | () => | ||||
await rest_api.get( | rest_api.get( | ||||
"/api/v1/users/me?format%5Broles%5D=expand" | "/api/v1/users/me?format%5Broles%5D=expand" | ||||
), | ), | ||||
e => { | e => { | ||||
assert.equal(e.response.status, 401); | assert.equal(e.response.status, 401); | ||||
assert.equal( | assert.equal( | ||||
e.response.data.message, | e.response.data.message, | ||||
"You're not logged in!" | "You're not logged in!" | ||||
); | ); | ||||
Show All 10 Lines | it("correctly rejects when provided incorrect password", async () => | ||||
{ password: "", message: "Missing password!" }, | { password: "", message: "Missing password!" }, | ||||
{ | { | ||||
password: "incorrect_password", | password: "incorrect_password", | ||||
message: "Incorrect password!", | message: "Incorrect password!", | ||||
}, | }, | ||||
]; | ]; | ||||
for (let variant of incorrect_password_variants) { | for (let variant of incorrect_password_variants) { | ||||
await assert_throws_async( | await assert_throws_async( | ||||
async () => | () => | ||||
await rest_api.login({ | rest_api.login({ | ||||
username: "seal", | username: "seal", | ||||
password: variant.password, | password: variant.password, | ||||
}), | }), | ||||
e => { | e => { | ||||
assert.equal(e.response.status, 401); | assert.equal(e.response.status, 401); | ||||
assert.equal( | assert.equal( | ||||
e.response.data.message, | e.response.data.message, | ||||
variant.message | variant.message | ||||
Show All 23 Lines | it("correctly rejects when provided incorrect username", async () => | ||||
{ username: "", message: "Missing username!" }, | { username: "", message: "Missing username!" }, | ||||
{ | { | ||||
username: "incorrect_username", | username: "incorrect_username", | ||||
message: "Incorrect username!", | message: "Incorrect username!", | ||||
}, | }, | ||||
]; | ]; | ||||
for (let variant of incorrect_username_variants) { | for (let variant of incorrect_username_variants) { | ||||
await assert_throws_async( | await assert_throws_async( | ||||
async () => | () => | ||||
await rest_api.login({ | rest_api.login({ | ||||
username: variant.username, | username: variant.username, | ||||
password: "seal", | password: "seal", | ||||
}), | }), | ||||
e => { | e => { | ||||
assert.equal(e.response.status, 401); | assert.equal(e.response.status, 401); | ||||
assert.equal( | assert.equal( | ||||
e.response.data.message, | e.response.data.message, | ||||
variant.message | variant.message | ||||
); | ); | ||||
} | } | ||||
); | ); | ||||
} | } | ||||
})); | })); | ||||
}); | }); | ||||
}); | }); |