Skip to content

Commit

Permalink
Merge branch 'master' into chore/siem-eslint-react-no-children-prop
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Jan 6, 2020
2 parents 6a0f0a3 + 1e5135e commit 9104431
Show file tree
Hide file tree
Showing 239 changed files with 4,961 additions and 3,023 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"**/isomorphic-git/**/base64-js": "^1.2.1",
"**/image-diff/gm/debug": "^2.6.9",
"**/react-dom": "^16.12.0",
"**/react": "^16.12.0",
"**/react-test-renderer": "^16.12.0",
"**/deepmerge": "^4.2.2",
"**/serialize-javascript": "^2.1.1"
Expand All @@ -113,7 +114,7 @@
"@babel/core": "^7.5.5",
"@babel/register": "^7.7.0",
"@elastic/apm-rum": "^4.6.0",
"@elastic/charts": "^14.0.0",
"@elastic/charts": "^16.0.2",
"@elastic/datemath": "5.0.2",
"@elastic/ems-client": "1.0.5",
"@elastic/eui": "17.3.1",
Expand Down Expand Up @@ -173,6 +174,7 @@
"fast-deep-equal": "^3.1.1",
"file-loader": "4.2.0",
"font-awesome": "4.7.0",
"fp-ts": "^2.3.1",
"getos": "^3.1.0",
"glob": "^7.1.2",
"glob-all": "^3.1.0",
Expand All @@ -187,6 +189,7 @@
"hoek": "^5.0.4",
"http-proxy-agent": "^2.1.0",
"https-proxy-agent": "^2.2.2",
"immer": "^1.5.0",
"inert": "^5.1.0",
"inline-style": "^2.0.0",
"joi": "^13.5.2",
Expand Down
12 changes: 1 addition & 11 deletions src/cli/serve/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,23 +140,12 @@ function applyConfigOverrides(rawConfig, opts, extraCliOptions) {
}

set('plugins.scanDirs', _.compact([].concat(get('plugins.scanDirs'), opts.pluginDir)));

set(
'plugins.paths',
_.compact(
[].concat(
get('plugins.paths'),
opts.pluginPath,
opts.runExamples
? [
// Ideally this would automatically include all plugins in the examples dir
fromRoot('examples/demo_search'),
fromRoot('examples/search_explorer'),
fromRoot('examples/embeddable_examples'),
fromRoot('examples/embeddable_explorer'),
]
: [],

XPACK_INSTALLED && !opts.oss ? [XPACK_DIR] : []
)
)
Expand Down Expand Up @@ -253,6 +242,7 @@ export default function(program) {
silent: !!opts.silent,
watch: !!opts.watch,
repl: !!opts.repl,
runExamples: !!opts.runExamples,
// We want to run without base path when the `--run-examples` flag is given so that we can use local
// links in other documentation sources, like "View this tutorial [here](http://localhost:5601/app/tutorial/xyz)".
// We can tell users they only have to run with `yarn start --run-examples` to get those
Expand Down
1 change: 1 addition & 0 deletions src/core/server/config/__mocks__/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function getEnvOptions(options: DeepPartial<EnvOptions> = {}): EnvOptions
basePath: false,
optimize: false,
oss: false,
runExamples: false,
...(options.cliArgs || {}),
},
isDevClusterMaster:
Expand Down
12 changes: 6 additions & 6 deletions src/core/server/config/__snapshots__/env.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/core/server/config/deprecation/core_deprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({
}) => [
unusedFromRoot('savedObjects.indexCheckTimeout'),
unusedFromRoot('server.xsrf.token'),
unusedFromRoot('uiSettings.enabled'),
renameFromRoot('optimize.lazy', 'optimize.watch'),
renameFromRoot('optimize.lazyPort', 'optimize.watchPort'),
renameFromRoot('optimize.lazyHost', 'optimize.watchHost'),
Expand Down
22 changes: 22 additions & 0 deletions src/core/server/config/env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,25 @@ test('pluginSearchPaths does not contains x-pack plugins path if --oss flag is t

expect(env.pluginSearchPaths).not.toContain('/some/home/dir/x-pack/plugins');
});

test('pluginSearchPaths contains examples plugins path if --run-examples flag is true', () => {
const env = new Env(
'/some/home/dir',
getEnvOptions({
cliArgs: { runExamples: true },
})
);

expect(env.pluginSearchPaths).toContain('/some/home/dir/examples');
});

test('pluginSearchPaths does not contains examples plugins path if --run-examples flag is false', () => {
const env = new Env(
'/some/home/dir',
getEnvOptions({
cliArgs: { runExamples: false },
})
);

expect(env.pluginSearchPaths).not.toContain('/some/home/dir/examples');
});
9 changes: 4 additions & 5 deletions src/core/server/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface CliArgs {
optimize: boolean;
open: boolean;
oss: boolean;
runExamples: boolean;
}

export class Env {
Expand All @@ -61,8 +62,6 @@ export class Env {
/** @internal */
public readonly logDir: string;
/** @internal */
public readonly staticFilesDir: string;
/** @internal */
public readonly pluginSearchPaths: readonly string[];

/**
Expand Down Expand Up @@ -100,14 +99,14 @@ export class Env {
this.configDir = resolve(this.homeDir, 'config');
this.binDir = resolve(this.homeDir, 'bin');
this.logDir = resolve(this.homeDir, 'log');
this.staticFilesDir = resolve(this.homeDir, 'ui');

this.pluginSearchPaths = [
resolve(this.homeDir, 'src', 'plugins'),
options.cliArgs.oss ? '' : resolve(this.homeDir, 'x-pack', 'plugins'),
...(options.cliArgs.oss ? [] : [resolve(this.homeDir, 'x-pack', 'plugins')]),
resolve(this.homeDir, 'plugins'),
...(options.cliArgs.runExamples ? [resolve(this.homeDir, 'examples')] : []),
resolve(this.homeDir, '..', 'kibana-extra'),
].filter(Boolean);
];

this.cliArgs = Object.freeze(options.cliArgs);
this.configs = Object.freeze(options.configs);
Expand Down
6 changes: 6 additions & 0 deletions src/core/server/http/__snapshots__/http_config.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/core/server/http/cookie_session_storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ configService.atPath.mockReturnValue(
verificationMode: 'none',
},
compression: { enabled: true },
xsrf: {
disableProtection: true,
whitelist: [],
},
} as any)
);

Expand Down
34 changes: 26 additions & 8 deletions src/core/server/http/http_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@

import uuid from 'uuid';
import { config, HttpConfig } from '.';
import { Env } from '../config';
import { getEnvOptions } from '../config/__mocks__/env';

const validHostnames = ['www.example.com', '8.8.8.8', '::1', 'localhost'];
const invalidHostname = 'asdf$%^';

jest.mock('os', () => ({
...jest.requireActual('os'),
hostname: () => 'kibana-hostname',
}));

test('has defaults for config', () => {
const httpSchema = config.schema;
const obj = {};
Expand Down Expand Up @@ -86,6 +89,24 @@ test('accepts only valid uuids for server.uuid', () => {
);
});

test('uses os.hostname() as default for server.name', () => {
const httpSchema = config.schema;
const validated = httpSchema.validate({});
expect(validated.name).toEqual('kibana-hostname');
});

test('throws if xsrf.whitelist element does not start with a slash', () => {
const httpSchema = config.schema;
const obj = {
xsrf: {
whitelist: ['/valid-path', 'invalid-path'],
},
};
expect(() => httpSchema.validate(obj)).toThrowErrorMatchingInlineSnapshot(
`"[xsrf.whitelist.1]: must start with a slash"`
);
});

describe('with TLS', () => {
test('throws if TLS is enabled but `key` is not specified', () => {
const httpSchema = config.schema;
Expand Down Expand Up @@ -265,8 +286,7 @@ describe('with TLS', () => {
clientAuthentication: 'none',
},
}),
{} as any,
Env.createDefault(getEnvOptions())
{} as any
);

expect(httpConfig.ssl.requestCert).toBe(false);
Expand All @@ -283,8 +303,7 @@ describe('with TLS', () => {
clientAuthentication: 'optional',
},
}),
{} as any,
Env.createDefault(getEnvOptions())
{} as any
);

expect(httpConfig.ssl.requestCert).toBe(true);
Expand All @@ -301,8 +320,7 @@ describe('with TLS', () => {
clientAuthentication: 'required',
},
}),
{} as any,
Env.createDefault(getEnvOptions())
{} as any
);

expect(httpConfig.ssl.requestCert).toBe(true);
Expand Down
Loading

0 comments on commit 9104431

Please sign in to comment.