-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into policy-devtool
- Loading branch information
Showing
39 changed files
with
2,374 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
# IMPORTANT: The variables defined here will override other variables. | ||
# See `./apps/armory/jest.setup.ts`. | ||
|
||
NODE_ENV=test | ||
|
||
PORT=3005 | ||
|
||
ARMORY_DATABASE_URL="postgresql://postgres:postgres@localhost:5432/armory_test?schema=public" | ||
|
||
REDIS_HOST=localhost | ||
REDIS_PORT=6379 | ||
|
||
PRICE_FEED_PRIVATE_KEY="0xc7a1b8ba040a238e36058fc5693f801d129aca9f10ed30d0133878f1b9147c01" | ||
HISTORICAL_TRANSFER_FEED_PRIVATE_KEY="0xf5c8f17cc09215c5038f6b8d5e557c0d98d341236307fe831efdcdd7faeef134" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
# IMPORTANT: The variables defined here will override other variables. | ||
# See `./apps/policy-engine/jest.setup.ts`. | ||
NODE_ENV=test | ||
|
||
PORT=3010 | ||
|
||
POLICY_ENGINE_DATABASE_URL="postgresql://postgres:postgres@localhost:5432/engine-test?schema=public" | ||
|
||
ENGINE_UID="local-dev-engine-instance-1" | ||
|
||
MASTER_PASSWORD="unsafe-local-test-master-password" | ||
|
||
KEYRING_TYPE="raw" | ||
|
||
# MASTER_AWS_KMS_ARN="arn:aws:kms:us-east-2:728783560968:key/f6aa3ddb-47c3-4f31-977d-b93205bb23d1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
apps/policy-engine/src/app/persistence/repository/__test__/unit/tenant.repository.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { DataStoreConfiguration } from '@narval/policy-engine-shared' | ||
import { Test } from '@nestjs/testing' | ||
import { KeyValueRepository } from '../../../../../shared/module/key-value/core/repository/key-value.repository' | ||
import { KeyValueService } from '../../../../../shared/module/key-value/core/service/key-value.service' | ||
import { InMemoryKeyValueRepository } from '../../../../../shared/module/key-value/persistence/repository/in-memory-key-value.repository' | ||
import { Tenant } from '../../../../../shared/types/domain.type' | ||
import { TenantRepository } from '../../../repository/tenant.repository' | ||
|
||
describe(TenantRepository.name, () => { | ||
let repository: TenantRepository | ||
let inMemoryKeyValueRepository: InMemoryKeyValueRepository | ||
|
||
beforeEach(async () => { | ||
inMemoryKeyValueRepository = new InMemoryKeyValueRepository() | ||
|
||
const module = await Test.createTestingModule({ | ||
providers: [ | ||
KeyValueService, | ||
TenantRepository, | ||
{ | ||
provide: KeyValueRepository, | ||
useValue: inMemoryKeyValueRepository | ||
} | ||
] | ||
}).compile() | ||
|
||
repository = module.get<TenantRepository>(TenantRepository) | ||
}) | ||
|
||
describe('create', () => { | ||
const now = new Date() | ||
|
||
const dataStoreConfiguration: DataStoreConfiguration = { | ||
dataUrl: 'a-url-that-doesnt-need-to-exist-for-the-purpose-of-this-test', | ||
signatureUrl: 'a-url-that-doesnt-need-to-exist-for-the-purpose-of-this-test', | ||
keys: [] | ||
} | ||
|
||
const tenant: Tenant = { | ||
clientId: 'test-client-id', | ||
clientSecret: 'test-client-secret', | ||
dataStore: { | ||
entity: dataStoreConfiguration, | ||
policy: dataStoreConfiguration | ||
}, | ||
createdAt: now, | ||
updatedAt: now | ||
} | ||
|
||
it('creates a new tenant', async () => { | ||
await repository.create(tenant) | ||
|
||
const value = await inMemoryKeyValueRepository.get(repository.getKey(tenant.clientId)) | ||
const actualTenant = await repository.findByClientId(tenant.clientId) | ||
|
||
expect(value).not.toEqual(null) | ||
expect(tenant).toEqual(actualTenant) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.