From 760952bcf26bf64bf10c2bb67b3e7b1b1e132e79 Mon Sep 17 00:00:00 2001 From: zkldi Date: Tue, 20 Apr 2021 16:30:00 +0100 Subject: [PATCH] debugging donotrun --- .../framework/importing/score-importing.ts | 3 ++- server/src/test-utils/api-common.ts | 12 +++++++++--- server/src/test-utils/fake-session.ts | 11 +++++++---- server/src/test-utils/reset-db-state.ts | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/server/src/score-import/framework/importing/score-importing.ts b/server/src/score-import/framework/importing/score-importing.ts index 71af161c8..4d3a0f909 100644 --- a/server/src/score-import/framework/importing/score-importing.ts +++ b/server/src/score-import/framework/importing/score-importing.ts @@ -100,6 +100,8 @@ export async function ImportIterableDatapoint( ) { const converterReturns = await ConverterFunction(data, context, logger); + logger.debug("Converter Function Finished"); + if (Array.isArray(converterReturns)) { return Promise.all( converterReturns.map((e) => ImportFromConverterReturn(userID, e, logger)) @@ -115,7 +117,6 @@ export async function ImportIterableDatapoint( * @param dryScore - The score that is to be hydrated and inserted. * @param chart - The chart this score is on. * @param song - The song this score is on. - * @returns no idea yet */ async function HydrateAndInsertScore( userID: integer, diff --git a/server/src/test-utils/api-common.ts b/server/src/test-utils/api-common.ts index a975dc94b..0793ec3cc 100644 --- a/server/src/test-utils/api-common.ts +++ b/server/src/test-utils/api-common.ts @@ -1,11 +1,13 @@ -import tap from "tap"; +import t from "tap"; +import { rootLogger } from "../logger"; +import { CloseAllConnections } from "./close-connections"; import mockApi from "./mock-api"; -type TestCB = Exclude[1], undefined>; +type TestCB = Exclude[1], undefined>; type Test = Parameters[0]; -export function RequireNeutralAuthentication(t: Test, url: string, method: "GET" | "POST" = "GET") { +export function RequireNeutralAuthentication(url: string, method: "GET" | "POST" = "GET") { t.test(`Testing authentication for ${method} ${url}.`, async (t) => { let res; @@ -21,5 +23,9 @@ export function RequireNeutralAuthentication(t: Test, url: string, method: "GET" "You are not authorised to perform this action.", "Should return an appropriate error message." ); + + // CloseAllConnections(); + + t.end(); }); } diff --git a/server/src/test-utils/fake-session.ts b/server/src/test-utils/fake-session.ts index d4c586d76..d533e8558 100644 --- a/server/src/test-utils/fake-session.ts +++ b/server/src/test-utils/fake-session.ts @@ -1,13 +1,13 @@ -import mockApi from "./mock-api"; -import assert from "assert"; -import db from "../db/db"; import ResetDBState from "./reset-db-state"; import CreateLogCtx from "../logger"; +import supertest from "supertest"; const logger = CreateLogCtx("fake-session.ts"); -export async function CreateFakeAuthCookie() { +export async function CreateFakeAuthCookie(mockApi: supertest.SuperTest) { + logger.info("1"); await ResetDBState(); + logger.info("2"); // possible security issue, ask hazel let res = await mockApi.post("/internal-api/auth/login").send({ username: "test_zkldi", @@ -15,10 +15,13 @@ export async function CreateFakeAuthCookie() { captcha: "asdf", }); + logger.info("3"); + if (res.status !== 200) { logger.crit("Failed to login. Cannot generate auth cookie."); throw res.body; } + logger.info("4"); return res.headers["set-cookie"] as string[]; } diff --git a/server/src/test-utils/reset-db-state.ts b/server/src/test-utils/reset-db-state.ts index 7582b4c68..149d3d722 100644 --- a/server/src/test-utils/reset-db-state.ts +++ b/server/src/test-utils/reset-db-state.ts @@ -1,7 +1,7 @@ /** * Resets the state of the database. */ -import db from "../db/db"; +import db, { CloseMongoConnection, ReopenMongoConnection } from "../db/db"; import fs from "fs"; import path from "path"; import CreateLogCtx from "../logger";