Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr/47074 #29

Merged
merged 2 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions src/core/server/http/integration_tests/core_services.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,39 +126,6 @@ describe('http service', () => {
.expect(200, { authorization: token, custom: 'custom-header' });
});

it('passes associated auth state to Legacy platform', async () => {
const user = { id: '42' };

const { http } = await root.setup();
const sessionStorageFactory = await http.createCookieSessionStorageFactory<StorageData>(
cookieOptions
);
http.registerAuth((req, res, toolkit) => {
if (req.headers.authorization) {
const sessionStorage = sessionStorageFactory.asScoped(req);
sessionStorage.set({ value: user, expires: Date.now() + sessionDurationMs });
return toolkit.authenticated({ state: user });
} else {
return res.unauthorized();
}
});
await root.start();

const legacyUrl = '/legacy';
const kbnServer = kbnTestServer.getKbnServer(root);
kbnServer.server.route({
method: 'GET',
path: legacyUrl,
handler: kbnServer.newPlatform.setup.core.http.auth.get,
});

const response = await kbnTestServer.request.get(root, legacyUrl).expect(200);
expect(response.body.state).toEqual(user);
expect(response.body.status).toEqual('authenticated');

expect(response.header['set-cookie']).toHaveLength(1);
});

it('attach security header to a successful response handled by Legacy platform', async () => {
const authResponseHeader = {
'www-authenticate': 'Negotiate ade0234568a4209af8bc0280289eca',
Expand Down
3 changes: 2 additions & 1 deletion src/test_utils/kbn_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import supertest from 'supertest';
import { CliArgs, Env } from '../core/server/config';
import { LegacyObjectToConfigAdapter } from '../core/server/legacy';
import { Root } from '../core/server/root';
import KbnServer from '../legacy/server/kbn_server';

type HttpMethod = 'delete' | 'get' | 'head' | 'post' | 'put';

Expand Down Expand Up @@ -131,7 +132,7 @@ export function createRootWithCorePlugins(settings = {}, cliArgs: Partial<CliArg
* Returns `kbnServer` instance used in the "legacy" Kibana.
* @param root
*/
export function getKbnServer(root: Root) {
export function getKbnServer(root: Root): KbnServer {
return (root as any).server.legacy.kbnServer;
}

Expand Down