Skip to content

Commit fac981e

Browse files
committed
clean code
1 parent 740ab77 commit fac981e

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

packages/kbn-test/src/auth/helper.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,9 @@
77
*/
88

99
import * as fs from 'fs';
10-
import { User } from './session_manager';
10+
import { Role, User } from './types';
1111

12-
export const getProjectType = (serverArgs: string[]) => {
13-
const svlArg = serverArgs.filter((arg) => arg.startsWith('--serverless'));
14-
if (svlArg.length === 0) {
15-
throw new Error('--serverless argument is missing in kbnTestServer.serverArgs');
16-
}
17-
return svlArg[0].split('=')[1];
18-
};
19-
20-
export const readCloudUsersFromFile = (filePath: string): Array<[string, User]> => {
12+
export const readCloudUsersFromFile = (filePath: string): Array<[Role, User]> => {
2113
if (!fs.existsSync(filePath)) {
2214
throw new Error(`Please define user roles with email/password in ${filePath}`);
2315
}
@@ -26,5 +18,5 @@ export const readCloudUsersFromFile = (filePath: string): Array<[string, User]>
2618
throw new Error(`'${filePath}' is empty: no roles are defined`);
2719
}
2820

29-
return Object.entries(JSON.parse(data)) as Array<[string, User]>;
21+
return Object.entries(JSON.parse(data)) as Array<[Role, User]>;
3022
};

packages/kbn-test/src/auth/session_manager.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ import Url from 'url';
1313
import { KbnClient } from '../kbn_client';
1414
import { readCloudUsersFromFile } from './helper';
1515
import { createCloudSAMLSession, createLocalSAMLSession, Session } from './saml_auth';
16-
17-
export interface User {
18-
readonly email: string;
19-
readonly password: string;
20-
}
21-
22-
export type Role = string;
16+
import { Role, User } from './types';
2317

2418
export interface HostOptions {
2519
protocol: 'http' | 'https';

packages/kbn-test/src/auth/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ export interface CreateSamlSessionParams {
3131
password: string;
3232
log: ToolingLog;
3333
}
34+
35+
export interface User {
36+
readonly email: string;
37+
readonly password: string;
38+
}
39+
40+
export type Role = string;

x-pack/test_serverless/functional/page_objects/svl_common_page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function SvlCommonPageProvider({ getService, getPageObjects }: FtrProvide
5454
const { body } = await supertestWithoutAuth
5555
.get('/internal/security/me')
5656
.set(svlCommonApi.getInternalRequestHeader())
57-
.set('Cookie', `sid=${browserCookies[0].value}`);
57+
.set({Cookie: `sid=${browserCookies[0].value}`});
5858

5959
const userData = await svlUserManager.getUserData(role);
6060
// email returned from API call must match the email for the specified role

0 commit comments

Comments
 (0)