Skip to content

Commit

Permalink
updating test utils
Browse files Browse the repository at this point in the history
  • Loading branch information
legrego committed Dec 8, 2020
1 parent c8b8dfe commit 4cb05a0
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions src/core/server/http/test_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,39 @@ const env = Env.createDefault(REPO_ROOT, getEnvOptions());
const logger = loggingSystemMock.create();

const configService = configServiceMock.create();
configService.atPath.mockReturnValue(
new BehaviorSubject({
hosts: ['localhost'],
maxPayload: new ByteSizeValue(1024),
autoListen: true,
ssl: {
enabled: false,
},
compression: { enabled: true },
xsrf: {
disableProtection: true,
allowlist: [],
},
customResponseHeaders: {},
requestId: {
allowFromAnyIp: true,
ipAllowlist: [],
},
keepaliveTimeout: 120_000,
socketTimeout: 120_000,
} as any)
);
configService.atPath.mockImplementation((path) => {
if (path === 'server') {
return new BehaviorSubject({
hosts: ['localhost'],
maxPayload: new ByteSizeValue(1024),
autoListen: true,
ssl: {
enabled: false,
},
compression: { enabled: true },
xsrf: {
disableProtection: true,
allowlist: [],
},
customResponseHeaders: {},
requestId: {
allowFromAnyIp: true,
ipAllowlist: [],
},
keepaliveTimeout: 120_000,
socketTimeout: 120_000,
} as any);
}
if (path === 'externalUrl') {
return new BehaviorSubject({
policy: [],
} as any);
}
if (path === 'csp') {
return new BehaviorSubject({} as any);
}
throw new Error(`Unexpected config path: ${path}`);
});

const defaultContext: CoreContext = {
coreId,
Expand Down

0 comments on commit 4cb05a0

Please sign in to comment.