mock password worker in test, build worker for seeding in e2e-tests

This commit is contained in:
einhornimmond 2024-12-20 14:40:05 +01:00
parent 2a93cfa095
commit 6f59b3a854
16 changed files with 26 additions and 4 deletions

View File

@ -35,7 +35,7 @@ jobs:
cd database
yarn && yarn dev_reset
cd ../backend
yarn && yarn seed
yarn && yarn build && yarn seed
- name: Boot up test system | docker-compose mailserver
run: docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps mailserver

View File

@ -28,6 +28,8 @@ import { peterLustig } from '@/seeds/users/peter-lustig'
import { getCommunityByUuid } from './util/communities'
jest.mock('@/password/EncryptorUtils')
// to do: We need a setup for the tests that closes the connection
let mutate: ApolloServerTestClient['mutate'],
query: ApolloServerTestClient['query'],

View File

@ -22,6 +22,8 @@ import { listContributionLinks } from '@/seeds/graphql/queries'
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
import { peterLustig } from '@/seeds/users/peter-lustig'
jest.mock('@/password/EncryptorUtils')
let mutate: ApolloServerTestClient['mutate'],
query: ApolloServerTestClient['query'],
con: Connection

View File

@ -27,6 +27,7 @@ import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
import { bobBaumeister } from '@/seeds/users/bob-baumeister'
import { peterLustig } from '@/seeds/users/peter-lustig'
jest.mock('@/password/EncryptorUtils')
jest.mock('@/emails/sendEmailVariants', () => {
const originalModule = jest.requireActual('@/emails/sendEmailVariants')
return {

View File

@ -59,6 +59,7 @@ import { stephenHawking } from '@/seeds/users/stephen-hawking'
import { getFirstDayOfPreviousNMonth } from '@/util/utilities'
jest.mock('@/emails/sendEmailVariants')
jest.mock('@/password/EncryptorUtils')
let mutate: ApolloServerTestClient['mutate'],
query: ApolloServerTestClient['query'],

View File

@ -15,6 +15,8 @@ import { userFactory } from '@/seeds/factory/user'
import { login, subscribeNewsletter, unsubscribeNewsletter } from '@/seeds/graphql/mutations'
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
jest.mock('@/password/EncryptorUtils')
let testEnv: any, mutate: any, con: any
beforeAll(async () => {

View File

@ -38,6 +38,8 @@ import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
import { transactionLinkCode } from './TransactionLinkResolver'
jest.mock('@/password/EncryptorUtils')
// mock semaphore to allow use fake timers
jest.mock('@/util/TRANSACTIONS_LOCK')
TRANSACTIONS_LOCK.acquire = jest.fn().mockResolvedValue(jest.fn())

View File

@ -37,6 +37,8 @@ import { garrickOllivander } from '@/seeds/users/garrick-ollivander'
import { peterLustig } from '@/seeds/users/peter-lustig'
import { stephenHawking } from '@/seeds/users/stephen-hawking'
jest.mock('@/password/EncryptorUtils')
let mutate: ApolloServerTestClient['mutate'], con: Connection
let query: ApolloServerTestClient['query']

View File

@ -74,6 +74,7 @@ import { objectValuesToArray } from '@/util/utilities'
import { Location2Point } from './util/Location2Point'
jest.mock('@/apis/humhub/HumHubClient')
jest.mock('@/password/EncryptorUtils')
jest.mock('@/emails/sendEmailVariants', () => {
const originalModule = jest.requireActual('@/emails/sendEmailVariants')

View File

@ -25,6 +25,8 @@ import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
import { bobBaumeister } from '@/seeds/users/bob-baumeister'
import { peterLustig } from '@/seeds/users/peter-lustig'
jest.mock('@/password/EncryptorUtils')
let mutate: ApolloServerTestClient['mutate'], con: Connection
let testEnv: {
mutate: ApolloServerTestClient['mutate']

View File

@ -12,6 +12,8 @@ import { peterLustig } from '@/seeds/users/peter-lustig'
import { getOpenCreations, getUserCreation } from './creations'
jest.mock('@/password/EncryptorUtils')
let mutate: ApolloServerTestClient['mutate'], con: Connection
let testEnv: {
mutate: ApolloServerTestClient['mutate']

View File

@ -16,6 +16,8 @@ import { peterLustig } from '@/seeds/users/peter-lustig'
import { findUserByIdentifier } from './findUserByIdentifier'
jest.mock('@/password/EncryptorUtils')
let con: Connection
let testEnv: {
mutate: ApolloServerTestClient['mutate']

View File

@ -32,6 +32,8 @@ import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz'
import { sendTransactionsToDltConnector } from './sendTransactionsToDltConnector'
jest.mock('@/password/EncryptorUtils')
/*
// Mock the GraphQLClient
jest.mock('graphql-request', () => {

View File

@ -18,7 +18,7 @@ export const SecretKeyCryptographyCreateKey = (
password: string,
configLoginAppSecret: Buffer,
configLoginServerKey: Buffer,
): Buffer[] => {
): Uint8Array[] => {
const state = Buffer.alloc(crypto_hash_sha512_STATEBYTES)
crypto_hash_sha512_init(state)
crypto_hash_sha512_update(state, Buffer.from(salt))
@ -42,7 +42,7 @@ export const SecretKeyCryptographyCreateKey = (
const encryptionKeyHash = Buffer.alloc(crypto_shorthash_BYTES)
crypto_shorthash(encryptionKeyHash, encryptionKey, configLoginServerKey)
return [encryptionKeyHash, encryptionKey]
return [new Uint8Array(encryptionKeyHash), new Uint8Array(encryptionKey)]
}
worker({

View File

@ -21,7 +21,7 @@ const configLoginServerKey = Buffer.from(CONFIG.LOGIN_SERVER_KEY, 'hex')
// TODO: put maxQueueSize into config
const encryptionWorkerPool = pool(
path.join(__dirname, '..', '..', 'build', 'src', 'password', '/EncryptionWorker.js'),
path.join(__dirname, '..', '..', 'build', 'src', 'password', '/EncryptionWorker.ts'),
{
maxQueueSize: 30 * cpus().length,
},

View File

@ -19,6 +19,7 @@ import { peterLustig } from '@/seeds/users/peter-lustig'
import { exportEventDataToKlickTipp } from './klicktipp'
jest.mock('@/apis/KlicktippController')
jest.mock('@/password/EncryptorUtils')
let mutate: ApolloServerTestClient['mutate'], con: Connection
let testEnv: {