proxy conf
This commit is contained in:
50
api/mocks/repositories/user.repository.mock.ts
Normal file
50
api/mocks/repositories/user.repository.mock.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import { CreateUserDto } from "src/model/dto/create-user.dto";
|
||||||
|
import { User } from "src/model/entitites";
|
||||||
|
import { IUser } from "src/model/interface";
|
||||||
|
|
||||||
|
export class MockUserRepository {
|
||||||
|
|
||||||
|
user: User = {
|
||||||
|
firstName: null,
|
||||||
|
lastName: null,
|
||||||
|
id: 'mockId',
|
||||||
|
username: 'mockuser@test.de',
|
||||||
|
createdAt: undefined,
|
||||||
|
lastLogin: undefined,
|
||||||
|
external: {
|
||||||
|
externalId: 'externalid',
|
||||||
|
user: null,
|
||||||
|
accessToken: "",
|
||||||
|
refreshToken: ""
|
||||||
|
},
|
||||||
|
isActive: false,
|
||||||
|
role: null,
|
||||||
|
systems: []
|
||||||
|
}
|
||||||
|
|
||||||
|
findByUsername = jest.fn().mockImplementation((username: string) => {
|
||||||
|
return this.user;
|
||||||
|
})
|
||||||
|
|
||||||
|
createUser = jest.fn().mockImplementation((register: CreateUserDto) => {
|
||||||
|
const user: User = {
|
||||||
|
firstName: null,
|
||||||
|
lastName: null,
|
||||||
|
id: 'mockId',
|
||||||
|
username: register.username,
|
||||||
|
createdAt: undefined,
|
||||||
|
lastLogin: undefined,
|
||||||
|
external: {
|
||||||
|
externalId: register.externalId,
|
||||||
|
user: null,
|
||||||
|
accessToken: "",
|
||||||
|
refreshToken: ""
|
||||||
|
},
|
||||||
|
isActive: false,
|
||||||
|
role: null,
|
||||||
|
systems: []
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,8 +4,9 @@ import { HttpService } from '@nestjs/axios';
|
|||||||
import { UserRepository } from 'src/model/repositories';
|
import { UserRepository } from 'src/model/repositories';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { JwtService } from '@nestjs/jwt';
|
import { JwtService } from '@nestjs/jwt';
|
||||||
|
import { MockUserRepository } from '../../../mocks/repositories/user.repository.mock';
|
||||||
|
|
||||||
describe('AppService', () => {
|
describe('AuthService', () => {
|
||||||
let service: AuthService;
|
let service: AuthService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@@ -24,10 +25,15 @@ describe('AppService', () => {
|
|||||||
it('should be defined', () => {
|
it('should be defined', () => {
|
||||||
expect(service).toBeDefined();
|
expect(service).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should store a user on creation', async () => {
|
||||||
|
const user = await service.register({externalId: '123', username: 'sc'});
|
||||||
|
expect(service['userRepo'].createUser).toHaveBeenCalled();
|
||||||
|
expect(user.external.externalId).toEqual('123');
|
||||||
|
expect(user.username).toEqual('sc');
|
||||||
|
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
class MockUserRepository {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class MockHttpService {}
|
class MockHttpService {}
|
||||||
@@ -80,6 +80,10 @@
|
|||||||
},
|
},
|
||||||
"development": {
|
"development": {
|
||||||
"buildTarget": "client:build:development"
|
"buildTarget": "client:build:development"
|
||||||
|
},
|
||||||
|
"remote": {
|
||||||
|
"proxyConfig": "proxy.remote.conf.json",
|
||||||
|
"buildTarget": "client:build:development"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"defaultConfiguration": "development"
|
"defaultConfiguration": "development"
|
||||||
|
|||||||
11
client/proxy.remote.conf.json
Normal file
11
client/proxy.remote.conf.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"/api": {
|
||||||
|
"target": "http://keyvaultpro.de:3701",
|
||||||
|
"secure": false,
|
||||||
|
"logLevel": "debug",
|
||||||
|
"changeOrigin": true,
|
||||||
|
"pathRewrite": {
|
||||||
|
"^/api": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user