Skip to content

Commit c619a6d

Browse files
committed
test: parse admin password correctly for test
1 parent 1334dd9 commit c619a6d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tests/app.test.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import buildApp from "../app.js";
33
import { unlink } from "node:fs/promises";
44
import { parse } from "cookie";
55
import { readFile } from "node:fs/promises";
6-
import { makeAccesstoken, makeRefreshtoken, makeAdminToken } from "../utils/jwt.js";
6+
import {
7+
makeAccesstoken,
8+
makeRefreshtoken,
9+
makeAdminToken,
10+
} from "../utils/jwt.js";
711
import * as jose from "jose";
812

913
// Setup Test
@@ -13,7 +17,7 @@ test.before(async (t) => {
1317

1418
//set up admin password
1519
const adminKey = await readFile("./adminkey_test", "utf8");
16-
const adminPassword = adminKey.split(":")[1].trim();
20+
const adminPassword = adminKey.split("admin password:")[1].trim();
1721
t.context.adminPass = adminPassword;
1822

1923
//create a user to test auth api endpoints with
@@ -340,7 +344,9 @@ test("JWT Test: makeRefreshtoken generates a valid recovery JWT token", async (t
340344
const secretKey = t.context.app.key;
341345

342346
// Generate a recovery token using the function
343-
const { token, expiration } = await makeRefreshtoken(userObj, secretKey, { recoveryToken: true });
347+
const { token, expiration } = await makeRefreshtoken(userObj, secretKey, {
348+
recoveryToken: true,
349+
});
344350

345351
// Fetch the payload
346352
const { payload } = await jose.jwtVerify(token, secretKey);
@@ -366,7 +372,10 @@ test("JWT Test: makeAdminToken generates a valid admin JWT token", async (t) =>
366372
const secretKey = t.context.app.key;
367373

368374
// Generate an admin token using the function
369-
const { token, expiration, userFingerprint } = await makeAdminToken(userObj, secretKey);
375+
const { token, expiration, userFingerprint } = await makeAdminToken(
376+
userObj,
377+
secretKey
378+
);
370379

371380
// Fetch the payload
372381
const { payload } = await jose.jwtVerify(token, secretKey);

0 commit comments

Comments
 (0)