diff --git a/.github/workflows/test_e2e.yml b/.github/workflows/test_e2e.yml index bdf979bf9..120fd0db3 100644 --- a/.github/workflows/test_e2e.yml +++ b/.github/workflows/test_e2e.yml @@ -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 diff --git a/backend/src/graphql/resolver/CommunityResolver.test.ts b/backend/src/graphql/resolver/CommunityResolver.test.ts index 8b5c05d5b..f9e6aa9ac 100644 --- a/backend/src/graphql/resolver/CommunityResolver.test.ts +++ b/backend/src/graphql/resolver/CommunityResolver.test.ts @@ -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'], diff --git a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts index 23be529d3..3a3196c85 100644 --- a/backend/src/graphql/resolver/ContributionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionLinkResolver.test.ts @@ -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 diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts index 88d79d5c6..a82f623cc 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts @@ -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 { diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 9317b76e7..5c7a3e77d 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -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'], diff --git a/backend/src/graphql/resolver/KlicktippResolver.test.ts b/backend/src/graphql/resolver/KlicktippResolver.test.ts index 2c819f070..06430c620 100644 --- a/backend/src/graphql/resolver/KlicktippResolver.test.ts +++ b/backend/src/graphql/resolver/KlicktippResolver.test.ts @@ -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 () => { diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index fe047b35a..bcea43416 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -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()) diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index 4bf5ab493..7cc6143e6 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -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'] diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index b8e4a5750..6cbcf9830 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -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') diff --git a/backend/src/graphql/resolver/semaphore.test.ts b/backend/src/graphql/resolver/semaphore.test.ts index ed58d55ec..f3dcce6f6 100644 --- a/backend/src/graphql/resolver/semaphore.test.ts +++ b/backend/src/graphql/resolver/semaphore.test.ts @@ -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'] diff --git a/backend/src/graphql/resolver/util/creations.test.ts b/backend/src/graphql/resolver/util/creations.test.ts index 83d787dd9..8b59d0b14 100644 --- a/backend/src/graphql/resolver/util/creations.test.ts +++ b/backend/src/graphql/resolver/util/creations.test.ts @@ -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'] diff --git a/backend/src/graphql/resolver/util/findUserByIdentifiers.test.ts b/backend/src/graphql/resolver/util/findUserByIdentifiers.test.ts index cfdbce8f2..1cdca8429 100644 --- a/backend/src/graphql/resolver/util/findUserByIdentifiers.test.ts +++ b/backend/src/graphql/resolver/util/findUserByIdentifiers.test.ts @@ -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'] diff --git a/backend/src/graphql/resolver/util/sendTransactionsToDltConnector.test.ts b/backend/src/graphql/resolver/util/sendTransactionsToDltConnector.test.ts index 0d85a35af..064184a9d 100644 --- a/backend/src/graphql/resolver/util/sendTransactionsToDltConnector.test.ts +++ b/backend/src/graphql/resolver/util/sendTransactionsToDltConnector.test.ts @@ -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', () => { diff --git a/backend/src/password/EncryptionWorker.ts b/backend/src/password/EncryptionWorker.ts index 2299a1a9b..00129dc69 100644 --- a/backend/src/password/EncryptionWorker.ts +++ b/backend/src/password/EncryptionWorker.ts @@ -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({ diff --git a/backend/src/password/EncryptorUtils.ts b/backend/src/password/EncryptorUtils.ts index 74b9f91d0..7086547a2 100644 --- a/backend/src/password/EncryptorUtils.ts +++ b/backend/src/password/EncryptorUtils.ts @@ -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, }, diff --git a/backend/src/util/klicktipp.test.ts b/backend/src/util/klicktipp.test.ts index 6639a0aa4..a88e8f21a 100644 --- a/backend/src/util/klicktipp.test.ts +++ b/backend/src/util/klicktipp.test.ts @@ -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: {