Rework authentication
This commit is contained in:
parent
a85330e8cf
commit
c07d33bcc9
17 changed files with 317 additions and 128 deletions
|
|
@ -1,7 +1,14 @@
|
|||
import assert from "node:assert";
|
||||
import { test } from "node:test";
|
||||
import { validate } from "uuid";
|
||||
import { apiGet, apiPost, apiPatch, apiDelete } from "./api.js";
|
||||
import {
|
||||
apiCookie,
|
||||
apiToken,
|
||||
apiGet,
|
||||
apiPost,
|
||||
apiPatch,
|
||||
apiDelete,
|
||||
} from "./api.js";
|
||||
|
||||
const state = {};
|
||||
|
||||
|
|
@ -30,19 +37,27 @@ test("can create community", async () => {
|
|||
});
|
||||
state.userId2 = responseRegister2.id;
|
||||
|
||||
const responseLogin1 = await apiPost(`auth/login`, {
|
||||
const responseLogin1Array = await apiCookie(`auth/login`, {
|
||||
username: state.username1,
|
||||
password: state.password1,
|
||||
});
|
||||
const responseLogin1 = responseLogin1Array[0];
|
||||
state.cookie1 = responseLogin1Array[1];
|
||||
state.sessionId1 = responseLogin1.id;
|
||||
state.token1 = responseLogin1.token;
|
||||
|
||||
const responseLogin2 = await apiPost(`auth/login`, {
|
||||
const responseLogin2Array = await apiCookie(`auth/login`, {
|
||||
username: state.username2,
|
||||
password: state.password2,
|
||||
});
|
||||
const responseLogin2 = responseLogin2Array[0];
|
||||
state.cookie2 = responseLogin2Array[1];
|
||||
state.sessionId2 = responseLogin2.id;
|
||||
state.token2 = responseLogin2.token;
|
||||
|
||||
const responseRefresh1 = await apiToken(`auth/refresh`, state.cookie1);
|
||||
state.token1 = responseRefresh1.token;
|
||||
|
||||
const responseRefresh2 = await apiToken(`auth/refresh`, state.cookie2);
|
||||
state.token2 = responseRefresh2.token;
|
||||
|
||||
const responseCreate = await apiPost(
|
||||
`community`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue