Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel committed Apr 3, 2024
1 parent 9f7e661 commit 5e9b043
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions apps/policy-engine/src/engine/__test__/e2e/engine.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ import { InMemoryKeyValueRepository } from '../../../shared/module/key-value/per
import { TestPrismaService } from '../../../shared/module/persistence/service/test-prisma.service'
import { getEntityStore, getPolicyStore } from '../../../shared/testing/data-store.testing'
import { getTestRawAesKeyring } from '../../../shared/testing/encryption.testing'
import { Tenant } from '../../../shared/type/domain.type'
import { Client } from '../../../shared/type/domain.type'
import { ClientService } from '../../core/service/client.service'
import { EngineSignerConfigService } from '../../core/service/engine-signer-config.service'
import { TenantService } from '../../core/service/tenant.service'
import { EngineModule } from '../../engine.module'

describe('Engine', () => {
let app: INestApplication
let privateKey: PrivateKey
let module: TestingModule
let tenant: Tenant
let client: Client
let enginePublicJwk: PublicKey
let tenantService: TenantService
let clientService: ClientService
let testPrismaService: TestPrismaService
let configService: ConfigService<Config>

Expand Down Expand Up @@ -60,7 +60,7 @@ describe('Engine', () => {
const engineService = module.get<EngineService>(EngineService)
const engineSignerConfigService = module.get<EngineSignerConfigService>(EngineSignerConfigService)
configService = module.get<ConfigService<Config>>(ConfigService)
tenantService = module.get<TenantService>(TenantService)
clientService = module.get<ClientService>(ClientService)
testPrismaService = module.get<TestPrismaService>(TestPrismaService)

await testPrismaService.truncateAll()
Expand All @@ -84,7 +84,7 @@ describe('Engine', () => {
key: privateKey
})

tenant = await tenantService.onboard(
client = await clientService.onboard(
{
clientId,
clientSecret: randomBytes(42).toString('hex'),
Expand All @@ -100,8 +100,8 @@ describe('Engine', () => {

enginePublicJwk = await engineSignerConfigService.getPublicJwkOrThrow()

await tenantService.savePolicyStore(tenant.clientId, await getPolicyStore([], privateKey))
await tenantService.saveEntityStore(tenant.clientId, await getEntityStore(FIXTURE.ENTITIES, privateKey))
await clientService.savePolicyStore(client.clientId, await getPolicyStore([], privateKey))
await clientService.saveEntityStore(client.clientId, await getEntityStore(FIXTURE.ENTITIES, privateKey))

await app.init()
})
Expand All @@ -116,8 +116,8 @@ describe('Engine', () => {
it('returns engine id + public jwk', async () => {
const { status, body } = await request(app.getHttpServer())
.get('/engine')
.set(REQUEST_HEADER_CLIENT_ID, tenant.clientId)
.set(REQUEST_HEADER_CLIENT_SECRET, tenant.clientSecret)
.set(REQUEST_HEADER_CLIENT_ID, client.clientId)
.set(REQUEST_HEADER_CLIENT_SECRET, client.clientSecret)

expect(body).toEqual(enginePublicJwk)
expect(status).toEqual(HttpStatus.OK)
Expand Down

0 comments on commit 5e9b043

Please sign in to comment.