Skip to content

Commit 1c542fc

Browse files
committed
Test fixes
Signed-off-by: Derek Ho <dxho@amazon.com>
1 parent 4c1e448 commit 1c542fc

File tree

5 files changed

+12
-68
lines changed

5 files changed

+12
-68
lines changed

server/auth/types/basic/basic_auth.test.ts

+2-11
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,11 @@ describe('Basic auth tests', () => {
3333
let sessionStorageFactory: SessionStorageFactory<SecuritySessionCookie>;
3434
let logger: Logger;
3535

36-
// Consistent with auth_handler_factory.test.ts
37-
beforeEach(() => {});
38-
39-
const config = ({
40-
saml: {
41-
extra_storage: {
42-
cookie_prefix: 'testcookie',
43-
additional_cookies: 5,
44-
},
45-
},
36+
const config = {
4637
session: {
4738
ttl: 1000,
4839
},
49-
} as unknown) as SecurityPluginConfigType;
40+
} as SecurityPluginConfigType;
5041

5142
test('getKeepAliveExpiry', () => {
5243
const realDateNow = Date.now.bind(global.Date);

server/auth/types/jwt/jwt_helper.test.ts

+6-24
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,7 @@ describe('JWT Expiry Tests', () => {
244244
});
245245

246246
test('JWT auth type sets expiryTime of cookie JWT exp less than ttl', async () => {
247-
const keepAliveConfig = {
248-
multitenancy: {
249-
enabled: false,
250-
},
251-
auth: {
252-
unauthenticated_routes: [] as string[],
253-
},
247+
const infiniteTTLConfig = {
254248
session: {
255249
keepalive: true,
256250
ttl: Infinity,
@@ -266,7 +260,7 @@ describe('JWT Expiry Tests', () => {
266260
} as SecurityPluginConfigType;
267261

268262
const jwtAuth = new JwtAuthentication(
269-
keepAliveConfig,
263+
infiniteTTLConfig,
270264
sessionStorageFactory,
271265
router,
272266
esClient,
@@ -294,13 +288,7 @@ describe('JWT Expiry Tests', () => {
294288
});
295289

296290
test('JWT auth type sets expiryTime of cookie ttl less than JWT exp', async () => {
297-
const keepAliveConfig = {
298-
multitenancy: {
299-
enabled: false,
300-
},
301-
auth: {
302-
unauthenticated_routes: [] as string[],
303-
},
291+
const lowTTLConfig = {
304292
session: {
305293
keepalive: true,
306294
ttl: 1000,
@@ -316,7 +304,7 @@ describe('JWT Expiry Tests', () => {
316304
} as SecurityPluginConfigType;
317305

318306
const jwtAuth = new JwtAuthentication(
319-
keepAliveConfig,
307+
lowTTLConfig,
320308
sessionStorageFactory,
321309
router,
322310
esClient,
@@ -344,13 +332,7 @@ describe('JWT Expiry Tests', () => {
344332
});
345333

346334
test('getKeepAliveExpiry', () => {
347-
const keepAliveConfig = {
348-
multitenancy: {
349-
enabled: false,
350-
},
351-
auth: {
352-
unauthenticated_routes: [] as string[],
353-
},
335+
const jwtConfig = {
354336
session: {
355337
keepalive: true,
356338
ttl: 100000,
@@ -366,7 +348,7 @@ describe('JWT Expiry Tests', () => {
366348
} as SecurityPluginConfigType;
367349

368350
const jwtAuth = new JwtAuthentication(
369-
keepAliveConfig,
351+
jwtConfig,
370352
sessionStorageFactory,
371353
router,
372354
esClient,

server/auth/types/multiple/multi_auth.test.ts

-6
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@
1515

1616
import { httpServerMock } from '../../../../../../src/core/server/http/http_server.mocks';
1717

18-
import { OpenSearchDashboardsRequest } from '../../../../../../src/core/server/http/router';
19-
2018
import { SecurityPluginConfigType } from '../../../index';
2119
import { SecuritySessionCookie } from '../../../session/security_cookie';
22-
import { deflateValue } from '../../../utils/compression';
2320
import {
2421
IRouter,
2522
CoreSetup,
@@ -36,9 +33,6 @@ describe('Multi auth tests', () => {
3633
let sessionStorageFactory: SessionStorageFactory<SecuritySessionCookie>;
3734
let logger: Logger;
3835

39-
// Consistent with auth_handler_factory.test.ts
40-
beforeEach(() => {});
41-
4236
const config = ({
4337
session: {
4438
ttl: 1000,

server/auth/types/openid/openid_auth.test.ts

+4-18
Original file line numberDiff line numberDiff line change
@@ -212,21 +212,14 @@ describe('test OpenId authHeaderValue', () => {
212212
const realDateNow = Date.now.bind(global.Date);
213213
const dateNowStub = jest.fn(() => 0);
214214
global.Date.now = dateNowStub;
215-
const customConfig = {
215+
const oidcConfig: unknown = {
216216
openid: {
217-
pfx: 'test/certs/keyStore.p12',
218-
certificate: 'test/certs/cert.pem',
219-
private_key: 'test/certs/private-key.pem',
220-
passphrase: '',
221-
header: 'authorization',
222217
scope: [],
223218
},
224219
};
225220

226-
const openidConfig = (customConfig as unknown) as SecurityPluginConfigType;
227-
228221
const openIdAuthentication = new OpenIdAuthentication(
229-
openidConfig,
222+
oidcConfig as SecurityPluginConfigType,
230223
sessionStorageFactory,
231224
router,
232225
esClient,
@@ -248,21 +241,14 @@ describe('test OpenId authHeaderValue', () => {
248241
});
249242

250243
test('getKeepAliveExpiry', () => {
251-
const customConfig = {
244+
const oidcConfig: unknown = {
252245
openid: {
253-
pfx: 'test/certs/keyStore.p12',
254-
certificate: 'test/certs/cert.pem',
255-
private_key: 'test/certs/private-key.pem',
256-
passphrase: '',
257-
header: 'authorization',
258246
scope: [],
259247
},
260248
};
261249

262-
const openidConfig = (customConfig as unknown) as SecurityPluginConfigType;
263-
264250
const openIdAuthentication = new OpenIdAuthentication(
265-
openidConfig,
251+
oidcConfig as SecurityPluginConfigType,
266252
sessionStorageFactory,
267253
router,
268254
esClient,

server/auth/types/proxy/proxy_auth.test.ts

-9
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,7 @@ describe('Proxy auth tests', () => {
3333
let sessionStorageFactory: SessionStorageFactory<SecuritySessionCookie>;
3434
let logger: Logger;
3535

36-
// Consistent with auth_handler_factory.test.ts
37-
beforeEach(() => {});
38-
3936
const config = ({
40-
saml: {
41-
extra_storage: {
42-
cookie_prefix: 'testcookie',
43-
additional_cookies: 5,
44-
},
45-
},
4637
session: {
4738
ttl: 1000,
4839
},

0 commit comments

Comments
 (0)