tests: readonly pastes must be readable+exportable with authentication

readonly paste links should be readable even if authentication is turned
on, as long as the user provides valid login data.
This test currently fails.

Also test that readonly paste IDs can be exported under the same
condition, which currently succeeds.
This commit is contained in:
pcworld 2021-04-11 04:00:14 +02:00 committed by Richard Hansen
parent 7d5cad6932
commit 0d33793908
2 changed files with 46 additions and 16 deletions

View file

@ -109,22 +109,24 @@ describe(__filename, function () {
.expect((res) => assert.equal(res.body.data.text, padText.toString()));
});
it('gets read only pad Id and exports the html and text for this pad', async function () {
this.timeout(250);
const ro = await agent.get(`${endPoint('getReadOnlyID')}&padID=${testPadId}`)
.expect(200)
.expect((res) => assert.ok(JSON.parse(res.text).data.readOnlyID));
const readOnlyId = JSON.parse(ro.text).data.readOnlyID;
await agent.get(`/p/${readOnlyId}/export/html`)
.expect(200)
.expect((res) => assert(res.text.indexOf('This is the') !== -1));
await agent.get(`/p/${readOnlyId}/export/txt`)
.expect(200)
.expect((res) => assert(res.text.indexOf('This is the') !== -1));
});
for (const authn of [false, true]) {
it(`can export from read-only pad ID, authn ${authn}`, async function () {
this.timeout(250);
settings.requireAuthentication = authn;
const get = (ep) => {
let req = agent.get(ep);
if (authn) req = req.auth('user', 'user-password');
return req.expect(200);
};
const ro = await get(`${endPoint('getReadOnlyID')}&padID=${testPadId}`)
.expect((res) => assert.ok(JSON.parse(res.text).data.readOnlyID));
const readOnlyId = JSON.parse(ro.text).data.readOnlyID;
await get(`/p/${readOnlyId}/export/html`)
.expect((res) => assert(res.text.indexOf('This is the') !== -1));
await get(`/p/${readOnlyId}/export/txt`)
.expect((res) => assert(res.text.indexOf('This is the') !== -1));
});
}
describe('Import/Export tests requiring AbiWord/LibreOffice', function () {
this.timeout(10000);