test: move cookie tests to api_integration tests (#14435)

This long running test does not belong in the unit tests.
This commit is contained in:
Court Ewing 2018-01-27 15:31:32 -08:00 committed by GitHub
parent 6e9fc7328b
commit 6b9f911e0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 53 deletions

View file

@ -1,53 +0,0 @@
import expect from 'expect.js';
import * as kbnTestServer from '../../../test_utils/kbn_server';
import { createEsTestCluster } from '../../../test_utils/es';
describe('routes', () => {
let kbnServer;
const es = createEsTestCluster({
name: 'server/http',
});
before(async function () {
this.timeout(es.getStartTimeout());
await es.start();
kbnServer = kbnTestServer.createServerWithCorePlugins();
await kbnServer.ready();
await kbnServer.server.plugins.elasticsearch.waitUntilReady();
});
after(async () => {
await kbnServer.close();
await es.stop();
});
describe('cookie validation', function () {
it('allows non-strict cookies', function (done) {
const options = {
method: 'GET',
url: '/',
headers: {
cookie: 'test:80=value;test_80=value'
}
};
kbnTestServer.makeRequest(kbnServer, options, (res) => {
expect(res.payload).not.to.contain('Invalid cookie header');
done();
});
});
it('returns an error if the cookie can\'t be parsed', function (done) {
const options = {
method: 'GET',
url: '/',
headers: {
cookie: 'a'
}
};
kbnTestServer.makeRequest(kbnServer, options, (res) => {
expect(res.payload).to.contain('Invalid cookie header');
done();
});
});
});
});

View file

@ -0,0 +1,24 @@
import expect from 'expect.js';
export default function ({ getService }) {
const supertest = getService('supertest');
describe('cookie handling', () => {
it('allows non-strict cookies', () => (
supertest.get('/')
.set('cookie', 'test:80=value;test_80=value')
.then((response) => {
expect(response.text).not.to.contain('Invalid cookie header');
})
));
it(`returns an error if the cookie can't be parsed`, () => (
supertest.get('/')
.set('cookie', 'a')
.expect(400)
.then((response) => {
expect(response.text).to.contain('Invalid cookie header');
})
));
});
}

View file

@ -0,0 +1,5 @@
export default function ({ loadTestFile }) {
describe('general', () => {
loadTestFile(require.resolve('./cookies'));
});
}

View file

@ -1,6 +1,7 @@
export default function ({ loadTestFile }) {
describe('apis', () => {
loadTestFile(require.resolve('./elasticsearch'));
loadTestFile(require.resolve('./general'));
loadTestFile(require.resolve('./index_patterns'));
loadTestFile(require.resolve('./saved_objects'));
loadTestFile(require.resolve('./scripts'));