Skip to content

Commit 4cb05a0

Browse files
committed
updating test utils
1 parent c8b8dfe commit 4cb05a0

File tree

1 file changed

+33
-22
lines changed

1 file changed

+33
-22
lines changed

src/core/server/http/test_utils.ts

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,39 @@ const env = Env.createDefault(REPO_ROOT, getEnvOptions());
3232
const logger = loggingSystemMock.create();
3333

3434
const configService = configServiceMock.create();
35-
configService.atPath.mockReturnValue(
36-
new BehaviorSubject({
37-
hosts: ['localhost'],
38-
maxPayload: new ByteSizeValue(1024),
39-
autoListen: true,
40-
ssl: {
41-
enabled: false,
42-
},
43-
compression: { enabled: true },
44-
xsrf: {
45-
disableProtection: true,
46-
allowlist: [],
47-
},
48-
customResponseHeaders: {},
49-
requestId: {
50-
allowFromAnyIp: true,
51-
ipAllowlist: [],
52-
},
53-
keepaliveTimeout: 120_000,
54-
socketTimeout: 120_000,
55-
} as any)
56-
);
35+
configService.atPath.mockImplementation((path) => {
36+
if (path === 'server') {
37+
return new BehaviorSubject({
38+
hosts: ['localhost'],
39+
maxPayload: new ByteSizeValue(1024),
40+
autoListen: true,
41+
ssl: {
42+
enabled: false,
43+
},
44+
compression: { enabled: true },
45+
xsrf: {
46+
disableProtection: true,
47+
allowlist: [],
48+
},
49+
customResponseHeaders: {},
50+
requestId: {
51+
allowFromAnyIp: true,
52+
ipAllowlist: [],
53+
},
54+
keepaliveTimeout: 120_000,
55+
socketTimeout: 120_000,
56+
} as any);
57+
}
58+
if (path === 'externalUrl') {
59+
return new BehaviorSubject({
60+
policy: [],
61+
} as any);
62+
}
63+
if (path === 'csp') {
64+
return new BehaviorSubject({} as any);
65+
}
66+
throw new Error(`Unexpected config path: ${path}`);
67+
});
5768

5869
const defaultContext: CoreContext = {
5970
coreId,

0 commit comments

Comments
 (0)