Skip to content

Commit

Permalink
Test fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho committed Feb 22, 2024
1 parent 4c1e448 commit 1c542fc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 68 deletions.
13 changes: 2 additions & 11 deletions server/auth/types/basic/basic_auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,11 @@ describe('Basic auth tests', () => {
let sessionStorageFactory: SessionStorageFactory<SecuritySessionCookie>;
let logger: Logger;

// Consistent with auth_handler_factory.test.ts
beforeEach(() => {});

const config = ({
saml: {
extra_storage: {
cookie_prefix: 'testcookie',
additional_cookies: 5,
},
},
const config = {
session: {
ttl: 1000,
},
} as unknown) as SecurityPluginConfigType;
} as SecurityPluginConfigType;

test('getKeepAliveExpiry', () => {
const realDateNow = Date.now.bind(global.Date);
Expand Down
30 changes: 6 additions & 24 deletions server/auth/types/jwt/jwt_helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,7 @@ describe('JWT Expiry Tests', () => {
});

test('JWT auth type sets expiryTime of cookie JWT exp less than ttl', async () => {
const keepAliveConfig = {
multitenancy: {
enabled: false,
},
auth: {
unauthenticated_routes: [] as string[],
},
const infiniteTTLConfig = {
session: {
keepalive: true,
ttl: Infinity,
Expand All @@ -266,7 +260,7 @@ describe('JWT Expiry Tests', () => {
} as SecurityPluginConfigType;

const jwtAuth = new JwtAuthentication(
keepAliveConfig,
infiniteTTLConfig,
sessionStorageFactory,
router,
esClient,
Expand Down Expand Up @@ -294,13 +288,7 @@ describe('JWT Expiry Tests', () => {
});

test('JWT auth type sets expiryTime of cookie ttl less than JWT exp', async () => {
const keepAliveConfig = {
multitenancy: {
enabled: false,
},
auth: {
unauthenticated_routes: [] as string[],
},
const lowTTLConfig = {
session: {
keepalive: true,
ttl: 1000,
Expand All @@ -316,7 +304,7 @@ describe('JWT Expiry Tests', () => {
} as SecurityPluginConfigType;

const jwtAuth = new JwtAuthentication(
keepAliveConfig,
lowTTLConfig,
sessionStorageFactory,
router,
esClient,
Expand Down Expand Up @@ -344,13 +332,7 @@ describe('JWT Expiry Tests', () => {
});

test('getKeepAliveExpiry', () => {
const keepAliveConfig = {
multitenancy: {
enabled: false,
},
auth: {
unauthenticated_routes: [] as string[],
},
const jwtConfig = {
session: {
keepalive: true,
ttl: 100000,
Expand All @@ -366,7 +348,7 @@ describe('JWT Expiry Tests', () => {
} as SecurityPluginConfigType;

const jwtAuth = new JwtAuthentication(
keepAliveConfig,
jwtConfig,
sessionStorageFactory,
router,
esClient,
Expand Down
6 changes: 0 additions & 6 deletions server/auth/types/multiple/multi_auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@

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

import { OpenSearchDashboardsRequest } from '../../../../../../src/core/server/http/router';

import { SecurityPluginConfigType } from '../../../index';
import { SecuritySessionCookie } from '../../../session/security_cookie';
import { deflateValue } from '../../../utils/compression';
import {
IRouter,
CoreSetup,
Expand All @@ -36,9 +33,6 @@ describe('Multi auth tests', () => {
let sessionStorageFactory: SessionStorageFactory<SecuritySessionCookie>;
let logger: Logger;

// Consistent with auth_handler_factory.test.ts
beforeEach(() => {});

const config = ({
session: {
ttl: 1000,
Expand Down
22 changes: 4 additions & 18 deletions server/auth/types/openid/openid_auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,21 +212,14 @@ describe('test OpenId authHeaderValue', () => {
const realDateNow = Date.now.bind(global.Date);
const dateNowStub = jest.fn(() => 0);
global.Date.now = dateNowStub;
const customConfig = {
const oidcConfig: unknown = {
openid: {
pfx: 'test/certs/keyStore.p12',
certificate: 'test/certs/cert.pem',
private_key: 'test/certs/private-key.pem',
passphrase: '',
header: 'authorization',
scope: [],
},
};

const openidConfig = (customConfig as unknown) as SecurityPluginConfigType;

const openIdAuthentication = new OpenIdAuthentication(
openidConfig,
oidcConfig as SecurityPluginConfigType,
sessionStorageFactory,
router,
esClient,
Expand All @@ -248,21 +241,14 @@ describe('test OpenId authHeaderValue', () => {
});

test('getKeepAliveExpiry', () => {
const customConfig = {
const oidcConfig: unknown = {
openid: {
pfx: 'test/certs/keyStore.p12',
certificate: 'test/certs/cert.pem',
private_key: 'test/certs/private-key.pem',
passphrase: '',
header: 'authorization',
scope: [],
},
};

const openidConfig = (customConfig as unknown) as SecurityPluginConfigType;

const openIdAuthentication = new OpenIdAuthentication(
openidConfig,
oidcConfig as SecurityPluginConfigType,
sessionStorageFactory,
router,
esClient,
Expand Down
9 changes: 0 additions & 9 deletions server/auth/types/proxy/proxy_auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,7 @@ describe('Proxy auth tests', () => {
let sessionStorageFactory: SessionStorageFactory<SecuritySessionCookie>;
let logger: Logger;

// Consistent with auth_handler_factory.test.ts
beforeEach(() => {});

const config = ({
saml: {
extra_storage: {
cookie_prefix: 'testcookie',
additional_cookies: 5,
},
},
session: {
ttl: 1000,
},
Expand Down

0 comments on commit 1c542fc

Please sign in to comment.