Skip to content

Commit

Permalink
Merge pull request #20 from joonashak/trunk
Browse files Browse the repository at this point in the history
User mocking for testing and development
  • Loading branch information
joonashak authored Nov 6, 2024
2 parents ff1370e + 1e52816 commit 9a2fe8f
Show file tree
Hide file tree
Showing 40 changed files with 366 additions and 77 deletions.
2 changes: 2 additions & 0 deletions dev/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ApolloServerPluginLandingPageLocalDefault } from "@apollo/server/plugin/landingPage/default";
import {
CloneBayMockingModule,
CloneBayModule,
CloneBayResolversModule,
CloneBaySsoModule,
Expand Down Expand Up @@ -40,6 +41,7 @@ import { SomeModule } from "./some/some.module";
CloneBaySsoModule,
CloneBayResolversModule,
SomeModule,
CloneBayMockingModule,
],
controllers: [AppController],
providers: [AppService],
Expand Down
2 changes: 2 additions & 0 deletions dev/src/some/some.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
CloneBayEsiApiService,
CloneBayMockingModule,
CloneBayUserService,
} from "@joonashak/nestjs-clone-bay";
import { Module } from "@nestjs/common";
Expand All @@ -13,6 +14,7 @@ import { SomeService } from "./some.service";
@Module({
imports: [
MongooseModule.forFeature([{ name: Some.name, schema: SomeSchema }]),
CloneBayMockingModule,
],
providers: [
SomeService,
Expand Down
6 changes: 5 additions & 1 deletion dev/src/some/some.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { CloneBayEsiApiService } from "@joonashak/nestjs-clone-bay";
import {
CloneBayEsiApiService,
CloneBayMockingService,
} from "@joonashak/nestjs-clone-bay";
import { Injectable } from "@nestjs/common";
import { InjectModel } from "@nestjs/mongoose";
import { Model } from "mongoose";
Expand All @@ -9,6 +12,7 @@ export class SomeService {
constructor(
@InjectModel(Some.name) private someModel: Model<SomeDocument>,
private apiService: CloneBayEsiApiService,
private mockingService: CloneBayMockingService,
) {}

async findAll() {
Expand Down
6 changes: 5 additions & 1 deletion docs/src/.vuepress/sidebar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { SidebarConfigArray } from "vuepress";

const sidebar: SidebarConfigArray = ["/index.md", "/api/index.md"];
const sidebar: SidebarConfigArray = [
"/index.md",
"/testing.md",
"/api/index.md",
];

export default sidebar;
4 changes: 2 additions & 2 deletions docs/src/api/classes/AuthenticationGuard.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#### Defined in

[lib/src/authentication/authentication.guard.ts:9](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/authentication/authentication.guard.ts#L9)
[lib/src/authentication/authentication.guard.ts:9](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/authentication/authentication.guard.ts#L9)

## Methods

Expand All @@ -47,4 +47,4 @@ CanActivate.canActivate

#### Defined in

[lib/src/authentication/authentication.guard.ts:14](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/authentication/authentication.guard.ts#L14)
[lib/src/authentication/authentication.guard.ts:14](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/authentication/authentication.guard.ts#L14)
8 changes: 4 additions & 4 deletions docs/src/api/classes/CloneBayConfigService.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Get current dynamic configuration.

#### Defined in

[lib/src/api/clone-bay-config.service.ts:25](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/api/clone-bay-config.service.ts#L25)
[lib/src/api/clone-bay-config.service.ts:25](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/api/clone-bay-config.service.ts#L25)

___

Expand All @@ -48,7 +48,7 @@ alliance included in this allowlist.

#### Defined in

[lib/src/api/clone-bay-config.service.ts:61](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/api/clone-bay-config.service.ts#L61)
[lib/src/api/clone-bay-config.service.ts:61](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/api/clone-bay-config.service.ts#L61)

___

Expand All @@ -73,7 +73,7 @@ allowlist.

#### Defined in

[lib/src/api/clone-bay-config.service.ts:37](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/api/clone-bay-config.service.ts#L37)
[lib/src/api/clone-bay-config.service.ts:37](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/api/clone-bay-config.service.ts#L37)

___

Expand All @@ -98,4 +98,4 @@ corporation included in this allowlist.

#### Defined in

[lib/src/api/clone-bay-config.service.ts:49](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/api/clone-bay-config.service.ts#L49)
[lib/src/api/clone-bay-config.service.ts:49](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/api/clone-bay-config.service.ts#L49)
8 changes: 4 additions & 4 deletions docs/src/api/classes/CloneBayEsiApiService.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ See [EsiApiRequestOptions](../interfaces/EsiApiRequestOptions.md) for method par

#### Defined in

[lib/src/api/clone-bay-esi-api.service.ts:37](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/api/clone-bay-esi-api.service.ts#L37)
[lib/src/api/clone-bay-esi-api.service.ts:37](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/api/clone-bay-esi-api.service.ts#L37)

___

Expand All @@ -62,7 +62,7 @@ ___

#### Defined in

[lib/src/api/clone-bay-esi-api.service.ts:25](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/api/clone-bay-esi-api.service.ts#L25)
[lib/src/api/clone-bay-esi-api.service.ts:25](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/api/clone-bay-esi-api.service.ts#L25)

___

Expand All @@ -88,7 +88,7 @@ ___

#### Defined in

[lib/src/api/clone-bay-esi-api.service.ts:29](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/api/clone-bay-esi-api.service.ts#L29)
[lib/src/api/clone-bay-esi-api.service.ts:29](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/api/clone-bay-esi-api.service.ts#L29)

___

Expand All @@ -114,4 +114,4 @@ ___

#### Defined in

[lib/src/api/clone-bay-esi-api.service.ts:33](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/api/clone-bay-esi-api.service.ts#L33)
[lib/src/api/clone-bay-esi-api.service.ts:33](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/api/clone-bay-esi-api.service.ts#L33)
11 changes: 11 additions & 0 deletions docs/src/api/classes/CloneBayMockingModule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Class: CloneBayMockingModule

Mocking utilities for testing and development.

_**CAUTION!** Importing this module into your application will make it
completely vulnerable. Use only in controlled environments such as testing
and development envs._

This module provides [CloneBayMockingService](CloneBayMockingService.md) and also mounts a
controller that exposes the endpoints `/clone-bay-mocking/create-user` and
`/clone-bay-mocking/login`.
62 changes: 62 additions & 0 deletions docs/src/api/classes/CloneBayMockingService.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Class: CloneBayMockingService

## Constructors

### constructor

**new CloneBayMockingService**(`mockingService`): [`CloneBayMockingService`](CloneBayMockingService.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `mockingService` | `MockingService` |

#### Returns

[`CloneBayMockingService`](CloneBayMockingService.md)

#### Defined in

[lib/src/api/clone-bay-mocking.service.ts:8](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/api/clone-bay-mocking.service.ts#L8)

## Methods

### createUser

**createUser**(`user`): `Promise`\<`Document`\<`unknown`, {}, `UserDocument`\> & [`User`](User.md) & `Document`\<`any`, `any`, `any`\> & `SchemaTimestampsConfig` & \{ `_id`: `ObjectId` }\>

#### Parameters

| Name | Type |
| :------ | :------ |
| `user` | `Omit`\<[`User`](User.md), ``"id"``\> |

#### Returns

`Promise`\<`Document`\<`unknown`, {}, `UserDocument`\> & [`User`](User.md) & `Document`\<`any`, `any`, `any`\> & `SchemaTimestampsConfig` & \{ `_id`: `ObjectId` }\>

#### Defined in

[lib/src/api/clone-bay-mocking.service.ts:10](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/api/clone-bay-mocking.service.ts#L10)

___

### loginWithEveId

**loginWithEveId**(`session`, `eveId`): `Promise`\<`UserDocument`\>

#### Parameters

| Name | Type |
| :------ | :------ |
| `session` | `unknown` |
| `eveId` | `number` |

#### Returns

`Promise`\<`UserDocument`\>

#### Defined in

[lib/src/api/clone-bay-mocking.service.ts:14](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/api/clone-bay-mocking.service.ts#L14)
4 changes: 2 additions & 2 deletions docs/src/api/classes/CloneBayModule.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CloneBayModuleDefinition.forRoot

#### Defined in

[lib/src/clone-bay.module.ts:42](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/clone-bay.module.ts#L42)
[lib/src/clone-bay.module.ts:42](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/clone-bay.module.ts#L42)

___

Expand All @@ -70,4 +70,4 @@ CloneBayModuleDefinition.forRootAsync

#### Defined in

[lib/src/clone-bay.module.ts:47](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/clone-bay.module.ts#L47)
[lib/src/clone-bay.module.ts:47](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/clone-bay.module.ts#L47)
6 changes: 3 additions & 3 deletions docs/src/api/classes/CloneBayUserService.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#### Defined in

[lib/src/api/clone-bay-user.service.ts:8](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/api/clone-bay-user.service.ts#L8)
[lib/src/api/clone-bay-user.service.ts:8](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/api/clone-bay-user.service.ts#L8)

## Methods

Expand All @@ -39,7 +39,7 @@

#### Defined in

[lib/src/api/clone-bay-user.service.ts:13](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/api/clone-bay-user.service.ts#L13)
[lib/src/api/clone-bay-user.service.ts:13](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/api/clone-bay-user.service.ts#L13)

___

Expand All @@ -59,4 +59,4 @@ ___

#### Defined in

[lib/src/api/clone-bay-user.service.ts:18](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/api/clone-bay-user.service.ts#L18)
[lib/src/api/clone-bay-user.service.ts:18](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/api/clone-bay-user.service.ts#L18)
10 changes: 5 additions & 5 deletions docs/src/api/classes/DynamicConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _Default: `true`_

#### Defined in

[lib/src/config/dynamic-config.model.ts:29](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/config/dynamic-config.model.ts#L29)
[lib/src/config/dynamic-config.model.ts:29](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/config/dynamic-config.model.ts#L29)

___

Expand All @@ -39,7 +39,7 @@ ___

#### Defined in

[lib/src/config/dynamic-config.model.ts:14](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/config/dynamic-config.model.ts#L14)
[lib/src/config/dynamic-config.model.ts:14](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/config/dynamic-config.model.ts#L14)

___

Expand All @@ -49,7 +49,7 @@ ___

#### Defined in

[lib/src/config/dynamic-config.model.ts:8](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/config/dynamic-config.model.ts#L8)
[lib/src/config/dynamic-config.model.ts:8](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/config/dynamic-config.model.ts#L8)

___

Expand All @@ -59,7 +59,7 @@ ___

#### Defined in

[lib/src/config/dynamic-config.model.ts:11](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/config/dynamic-config.model.ts#L11)
[lib/src/config/dynamic-config.model.ts:11](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/config/dynamic-config.model.ts#L11)

___

Expand All @@ -80,4 +80,4 @@ _Default: `false`_

#### Defined in

[lib/src/config/dynamic-config.model.ts:44](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/config/dynamic-config.model.ts#L44)
[lib/src/config/dynamic-config.model.ts:44](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/config/dynamic-config.model.ts#L44)
4 changes: 2 additions & 2 deletions docs/src/api/classes/EveAccessToken.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#### Defined in

[lib/src/types/eve-access-token.dto.ts:9](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/types/eve-access-token.dto.ts#L9)
[lib/src/types/eve-access-token.dto.ts:9](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/types/eve-access-token.dto.ts#L9)

___

Expand All @@ -28,4 +28,4 @@ ___

#### Defined in

[lib/src/types/eve-access-token.dto.ts:6](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/types/eve-access-token.dto.ts#L6)
[lib/src/types/eve-access-token.dto.ts:6](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/types/eve-access-token.dto.ts#L6)
2 changes: 1 addition & 1 deletion docs/src/api/classes/InvalidConfigurationException.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#### Defined in

[lib/src/exceptions/invalid-configuration.exception.ts:6](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/exceptions/invalid-configuration.exception.ts#L6)
[lib/src/exceptions/invalid-configuration.exception.ts:6](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/exceptions/invalid-configuration.exception.ts#L6)

## Methods

Expand Down
8 changes: 4 additions & 4 deletions docs/src/api/classes/User.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#### Defined in

[lib/src/entities/user/user.model.ts:25](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/entities/user/user.model.ts#L25)
[lib/src/entities/user/user.model.ts:25](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/entities/user/user.model.ts#L25)

___

Expand All @@ -28,7 +28,7 @@ ___

#### Defined in

[lib/src/entities/user/user.model.ts:21](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/entities/user/user.model.ts#L21)
[lib/src/entities/user/user.model.ts:21](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/entities/user/user.model.ts#L21)

___

Expand All @@ -38,7 +38,7 @@ ___

#### Defined in

[lib/src/entities/user/user.model.ts:12](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/entities/user/user.model.ts#L12)
[lib/src/entities/user/user.model.ts:12](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/entities/user/user.model.ts#L12)

___

Expand All @@ -48,4 +48,4 @@ ___

#### Defined in

[lib/src/entities/user/user.model.ts:16](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/entities/user/user.model.ts#L16)
[lib/src/entities/user/user.model.ts:16](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/entities/user/user.model.ts#L16)
10 changes: 5 additions & 5 deletions docs/src/api/enums/UserAction.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#### Defined in

[lib/src/authorization/user-action.enum.ts:3](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/authorization/user-action.enum.ts#L3)
[lib/src/authorization/user-action.enum.ts:3](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/authorization/user-action.enum.ts#L3)

___

Expand All @@ -18,7 +18,7 @@ ___

#### Defined in

[lib/src/authorization/user-action.enum.ts:6](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/authorization/user-action.enum.ts#L6)
[lib/src/authorization/user-action.enum.ts:6](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/authorization/user-action.enum.ts#L6)

___

Expand All @@ -28,7 +28,7 @@ ___

#### Defined in

[lib/src/authorization/user-action.enum.ts:2](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/authorization/user-action.enum.ts#L2)
[lib/src/authorization/user-action.enum.ts:2](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/authorization/user-action.enum.ts#L2)

___

Expand All @@ -38,7 +38,7 @@ ___

#### Defined in

[lib/src/authorization/user-action.enum.ts:4](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/authorization/user-action.enum.ts#L4)
[lib/src/authorization/user-action.enum.ts:4](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/authorization/user-action.enum.ts#L4)

___

Expand All @@ -48,4 +48,4 @@ ___

#### Defined in

[lib/src/authorization/user-action.enum.ts:5](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/authorization/user-action.enum.ts#L5)
[lib/src/authorization/user-action.enum.ts:5](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/authorization/user-action.enum.ts#L5)
2 changes: 1 addition & 1 deletion docs/src/api/functions/RequireAuthentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ Useful to build new decorators (or a decorator factory) encapsulating multiple d

#### Defined in

[lib/src/decorators/require-authentication.decorator.ts:4](https://github.com/joonashak/nestjs-clone-bay/blob/3e50c73/lib/src/decorators/require-authentication.decorator.ts#L4)
[lib/src/decorators/require-authentication.decorator.ts:4](https://github.com/joonashak/nestjs-clone-bay/blob/37c762a/lib/src/decorators/require-authentication.decorator.ts#L4)
Loading

0 comments on commit 9a2fe8f

Please sign in to comment.