-
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.
Adding SQLite db to authz, updating persitence directory structure, s… (
#73) * Adding SQLite db to authz, updating persitence directory structure, starting to wire up crud for entities
- Loading branch information
1 parent
c16acdc
commit e93bc30
Showing
24 changed files
with
494 additions
and
84 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 |
---|---|---|
|
@@ -54,4 +54,7 @@ Thumbs.db | |
.env.production | ||
.env.test | ||
|
||
/rego-build | ||
/rego-build | ||
|
||
*.sqlite | ||
*.sqlite-journal |
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 +1,5 @@ | ||
NODE_ENV=development | ||
|
||
PORT=3010 | ||
|
||
ENGINE_DATABASE_URL="file:./engine-core.sqlite" |
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,2 +1,5 @@ | ||
# IMPORTANT: The variables defined here will override other variables. | ||
# See `./apps/authz/jest.setup.ts`. | ||
NODE_ENV=test | ||
|
||
ENGINE_DATABASE_URL="file:./engine-core-test.sqlite" |
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
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
56 changes: 56 additions & 0 deletions
56
...authz/src/app/persistence/repository/__test__/integration/organization.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,56 @@ | ||
import { load } from '@app/authz/app/app.config' | ||
import { OrganizationRepository } from '@app/authz/app/persistence/repository/organization.repository' | ||
import { PersistenceModule } from '@app/authz/shared/module/persistence/persistence.module' | ||
import { TestPrismaService } from '@app/authz/shared/module/persistence/service/test-prisma.service' | ||
import { Alg } from '@narval/authz-shared' | ||
import { ConfigModule, ConfigService } from '@nestjs/config' | ||
import { Test, TestingModule } from '@nestjs/testing' | ||
|
||
describe(OrganizationRepository.name, () => { | ||
let module: TestingModule | ||
let repository: OrganizationRepository | ||
let testPrismaService: TestPrismaService | ||
|
||
beforeEach(async () => { | ||
module = await Test.createTestingModule({ | ||
imports: [ | ||
ConfigModule.forRoot({ | ||
load: [load], | ||
isGlobal: true | ||
}), | ||
PersistenceModule | ||
], | ||
providers: [OrganizationRepository] | ||
}).compile() | ||
|
||
testPrismaService = module.get<TestPrismaService>(TestPrismaService) | ||
repository = module.get<OrganizationRepository>(OrganizationRepository) | ||
}) | ||
|
||
afterEach(async () => { | ||
await testPrismaService.truncateAll() | ||
await module.close() | ||
}) | ||
|
||
describe('create', () => { | ||
it('should have test db url', () => { | ||
// Just leaving this to ensure the jest.setup.ts file is configured correctly to set the env variable. | ||
const configService = module.get<ConfigService>(ConfigService) | ||
expect(configService.get('database.url', { infer: true })).toBe('file:./engine-core-test.sqlite') | ||
}) | ||
|
||
it('creates a new organization', async () => { | ||
await repository.createOrganization('test-org-uid', 'test-user-uid', { | ||
alg: Alg.ES256K, | ||
pubKey: 'test-public-key' | ||
}) | ||
|
||
const org = await testPrismaService.getClient().organization.findFirst({ | ||
where: { | ||
uid: 'test-org-uid' | ||
} | ||
}) | ||
expect(org).toEqual({ uid: 'test-org-uid' }) | ||
}) | ||
}) | ||
}) |
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
Oops, something went wrong.