From c62169f9c3eb5cd8ef0b13e56ed7d0e7ff1313a4 Mon Sep 17 00:00:00 2001
From: clauspeterhuebner
Date: Wed, 25 Jun 2025 16:26:38 +0200
Subject: [PATCH] remove console.logs and organize imports
---
backend/src/auth/jwt/JWT.test.ts | 47 ++++++++++----------------------
1 file changed, 14 insertions(+), 33 deletions(-)
diff --git a/backend/src/auth/jwt/JWT.test.ts b/backend/src/auth/jwt/JWT.test.ts
index 45d812ee0..4ab61e18f 100644
--- a/backend/src/auth/jwt/JWT.test.ts
+++ b/backend/src/auth/jwt/JWT.test.ts
@@ -1,29 +1,24 @@
-import { ApolloServerTestClient } from 'apollo-server-testing'
-import { FederatedCommunity as DbFederatedCommunity } from 'database'
-import { GraphQLClient } from 'graphql-request'
-import { Response } from 'graphql-request/dist/types'
-import { DataSource } from 'typeorm'
-import { cleanDB, testEnvironment } from '@test/helpers'
-import { logger } from '@test/testSetup'
+// import { testEnvironment } from '@test/helpers'
+// import { logger } from '@test/testSetup'
-import { encode, decode, verify, encrypt, decrypt, createKeyPair } from './JWT'
-import { OpenConnectionJwtPayloadType } from './payloadtypes/OpenConnectionJwtPayloadType'
+import { createKeyPair, decode, decrypt, encode, encrypt, verify } from './JWT'
import { EncryptedJWEJwtPayloadType } from './payloadtypes/EncryptedJWEJwtPayloadType'
+import { OpenConnectionJwtPayloadType } from './payloadtypes/OpenConnectionJwtPayloadType'
-let con: DataSource
-let testEnv: {
- mutate: ApolloServerTestClient['mutate']
- query: ApolloServerTestClient['query']
- con: DataSource
-}
+// let con: DataSource
+// let testEnv: {
+// mutate: ApolloServerTestClient['mutate']
+// query: ApolloServerTestClient['query']
+// con: DataSource
+// }
let keypairComA: { publicKey: string; privateKey: string }
let keypairComB: { publicKey: string; privateKey: string }
beforeAll(async () => {
- testEnv = await testEnvironment(logger)
- con = testEnv.con
- await cleanDB()
+// testEnv = await testEnvironment(logger)
+// con = testEnv.con
+// await cleanDB()
keypairComA = await createKeyPair()
keypairComB = await createKeyPair()
@@ -31,7 +26,7 @@ beforeAll(async () => {
afterAll(async () => {
// await cleanDB()
- await con.destroy()
+ // await con.destroy()
})
describe('test JWS creation and verification', () => {
@@ -40,13 +35,10 @@ describe('test JWS creation and verification', () => {
beforeEach(async () => {
jest.clearAllMocks()
jwsComA = await encode(new OpenConnectionJwtPayloadType('http://localhost:5001/api/'), keypairComA.privateKey)
- console.log('jwsComA=', jwsComA)
jwsComB = await encode(new OpenConnectionJwtPayloadType('http://localhost:5002/api/'), keypairComB.privateKey)
- console.log('jwsComB=', jwsComB)
})
it('decode jwsComA', async () => {
const decodedJwsComA = await decode(jwsComA)
- console.log('decodedJwsComA=', decodedJwsComA)
expect(decodedJwsComA).toEqual({
expiration: '10m',
tokentype: OpenConnectionJwtPayloadType.OPEN_CONNECTION_TYPE,
@@ -55,7 +47,6 @@ describe('test JWS creation and verification', () => {
})
it('decode jwsComB', async () => {
const decodedJwsComB = await decode(jwsComB)
- console.log('decodedJwsComB=', decodedJwsComB)
expect(decodedJwsComB).toEqual({
expiration: '10m',
tokentype: OpenConnectionJwtPayloadType.OPEN_CONNECTION_TYPE,
@@ -64,7 +55,6 @@ describe('test JWS creation and verification', () => {
})
it('verify jwsComA', async () => {
const verifiedJwsComA = await verify(jwsComA, keypairComA.publicKey)
- console.log('verify jwsComA=', verifiedJwsComA)
expect(verifiedJwsComA).toEqual(expect.objectContaining({
payload: expect.objectContaining({
tokentype: OpenConnectionJwtPayloadType.OPEN_CONNECTION_TYPE,
@@ -74,7 +64,6 @@ describe('test JWS creation and verification', () => {
})
it('verify jwsComB', async () => {
const verifiedJwsComB = await verify(jwsComB, keypairComB.publicKey)
- console.log('verify jwsComB=', verifiedJwsComB)
expect(verifiedJwsComB).toEqual(expect.objectContaining({
payload: expect.objectContaining({
tokentype: OpenConnectionJwtPayloadType.OPEN_CONNECTION_TYPE,
@@ -90,13 +79,10 @@ describe('test JWE encryption and decryption', () => {
beforeEach(async () => {
jest.clearAllMocks()
jweComA = await encrypt(new OpenConnectionJwtPayloadType('http://localhost:5001/api/'), keypairComB.publicKey)
- console.log('jweComA=', jweComA)
jweComB = await encrypt(new OpenConnectionJwtPayloadType('http://localhost:5002/api/'), keypairComA.publicKey)
- console.log('jweComB=', jweComB)
})
it('decrypt jweComA', async () => {
const decryptedAJwT = await decrypt(jweComA, keypairComB.privateKey)
- console.log('decryptedAJwT=', decryptedAJwT)
expect(JSON.parse(decryptedAJwT)).toEqual(expect.objectContaining({
tokentype: OpenConnectionJwtPayloadType.OPEN_CONNECTION_TYPE,
url: 'http://localhost:5001/api/',
@@ -104,7 +90,6 @@ describe('test JWE encryption and decryption', () => {
})
it('decrypt jweComB', async () => {
const decryptedBJwT = await decrypt(jweComB, keypairComA.privateKey)
- console.log('decryptedBJwT=', decryptedBJwT)
expect(JSON.parse(decryptedBJwT)).toEqual(expect.objectContaining({
tokentype: OpenConnectionJwtPayloadType.OPEN_CONNECTION_TYPE,
url: 'http://localhost:5002/api/',
@@ -122,13 +107,9 @@ describe('test encrypted and signed JWT', () => {
beforeEach(async () => {
jest.clearAllMocks()
jweComA = await encrypt(new OpenConnectionJwtPayloadType('http://localhost:5001/api/'), keypairComB.publicKey)
- console.log('jweComA=', jweComA)
jwsComA = await encode(new EncryptedJWEJwtPayloadType(jweComA), keypairComA.privateKey)
- console.log('jwsComA=', jwsComA)
jweComB = await encrypt(new OpenConnectionJwtPayloadType('http://localhost:5002/api/'), keypairComA.publicKey)
- console.log('jweComB=', jweComB)
jwsComB = await encode(new EncryptedJWEJwtPayloadType(jweComB), keypairComB.privateKey)
- console.log('jwsComB=', jwsComB)
})
it('verify jwsComA', async () => {
expect(await verify(jwsComA, keypairComA.publicKey)).toEqual(expect.objectContaining({