mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
caching_middleware: add test for unsupported methods
This commit is contained in:
parent
e35a2b4cb5
commit
04bb2a9f8f
1 changed files with 23 additions and 4 deletions
|
@ -51,6 +51,7 @@ describe(__filename, function () {
|
|||
'/javascripts/lib/ep_etherpad-lite/static/js/pad.js?callback=require.define',
|
||||
'/javascripts/lib/ep_etherpad-lite/static/js/timeslider.js?callback=require.define',
|
||||
];
|
||||
const unsupportedMethods = ['post', 'put', 'delete', 'options', 'trace', 'patch'];
|
||||
|
||||
before(async function () {
|
||||
agent = await common.init();
|
||||
|
@ -68,7 +69,7 @@ describe(__filename, function () {
|
|||
settings.minify = false;
|
||||
});
|
||||
it('gets packages uncompressed without Accept-Encoding gzip', async function () {
|
||||
await Promise.all(packages.map(async (resource) => agent.get(resource)
|
||||
await Promise.all(packages.map(async (resource) => await agent.get(resource)
|
||||
.set('Accept-Encoding', fantasyEncoding)
|
||||
.use(disableAutoDeflate)
|
||||
.then((res) => {
|
||||
|
@ -80,7 +81,7 @@ describe(__filename, function () {
|
|||
});
|
||||
|
||||
it('gets packages compressed with Accept-Encoding gzip', async function () {
|
||||
await Promise.all(packages.map(async (resource) => agent.get(resource)
|
||||
await Promise.all(packages.map(async (resource) => await agent.get(resource)
|
||||
.set('Accept-Encoding', 'gzip')
|
||||
.use(disableAutoDeflate)
|
||||
.then((res) => {
|
||||
|
@ -102,6 +103,15 @@ describe(__filename, function () {
|
|||
.set('Accept-Encoding', fantasyEncoding)
|
||||
.then((res) => assert.equal(res.header['content-encoding'], undefined));
|
||||
});
|
||||
|
||||
it('only HEAD and GET are supported', async function() {
|
||||
await Promise.all(unsupportedMethods.map(async (method) => {
|
||||
await agent[method](packages[0])
|
||||
.then((res) => {
|
||||
assert.equal(res.statusCode, 405)
|
||||
})
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
context('when minify is true', function () {
|
||||
|
@ -109,7 +119,7 @@ describe(__filename, function () {
|
|||
settings.minify = true;
|
||||
});
|
||||
it('gets packages uncompressed without Accept-Encoding gzip', async function () {
|
||||
await Promise.all(packages.map(async (resource) => agent.get(resource)
|
||||
await Promise.all(packages.map(async (resource) => await agent.get(resource)
|
||||
.set('Accept-Encoding', fantasyEncoding)
|
||||
.use(disableAutoDeflate)
|
||||
.then((res) => {
|
||||
|
@ -121,7 +131,7 @@ describe(__filename, function () {
|
|||
});
|
||||
|
||||
it('gets packages compressed with Accept-Encoding gzip', async function () {
|
||||
await Promise.all(packages.map(async (resource) => agent.get(resource)
|
||||
await Promise.all(packages.map(async (resource) => await agent.get(resource)
|
||||
.set('Accept-Encoding', 'gzip')
|
||||
.use(disableAutoDeflate)
|
||||
.then((res) => {
|
||||
|
@ -143,5 +153,14 @@ describe(__filename, function () {
|
|||
.set('Accept-Encoding', fantasyEncoding)
|
||||
.then((res) => assert.equal(res.header['content-encoding'], undefined));
|
||||
});
|
||||
|
||||
it('only HEAD and GET are supported', async function() {
|
||||
await Promise.all(unsupportedMethods.map(async (method) => {
|
||||
await agent[method](packages[0])
|
||||
.then((res) => {
|
||||
assert.equal(res.statusCode, 405)
|
||||
})
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue