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:
parent
6e9fc7328b
commit
6b9f911e0d
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
24
test/api_integration/apis/general/cookies.js
Normal file
24
test/api_integration/apis/general/cookies.js
Normal 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');
|
||||
})
|
||||
));
|
||||
});
|
||||
}
|
5
test/api_integration/apis/general/index.js
Normal file
5
test/api_integration/apis/general/index.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
export default function ({ loadTestFile }) {
|
||||
describe('general', () => {
|
||||
loadTestFile(require.resolve('./cookies'));
|
||||
});
|
||||
}
|
|
@ -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'));
|
||||
|
|
Loading…
Reference in a new issue