Skip to content

Commit 96f9333

Browse files
committed
support couchapp attachments while testing locally
1 parent 9e5d2ca commit 96f9333

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

etc/local.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ enable_cors = true
55
origins = *
66
credentials = true
77

8+
[csp]
9+
attachments_enable = true
10+
; https://docs.couchdb.org/en/stable/cve/2021-38295.html
11+
; use nginx instead to allow only signed couchapps when on deployed server
12+
attachments_header_value = "child-src 'self' data: blob:; default-src 'self'; img-src 'self' data: https://secure.gravatar.com; font-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline';"
13+
814
[couchdb]
915
single_node=true
1016

test/integration/install.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ debug('replay localhosts', replay._localhosts);
1818
\"TLS server: In state wait_finished received CLIENT ALERT: Fatal - Certificate Unknown\\n\"}}}"
1919
*/
2020
let destination = 'http://admin:none@localhost:5984';
21+
const couchUrl = destination.replace('admin:none@', '');
22+
2123
if (!destination) {
2224
destination = url.parse(config.usersDbConnection.url);
2325
destination.auth = `${config.couchKeys.username}:${config.couchKeys.password}`;
@@ -525,19 +527,38 @@ describe('install', () => {
525527
expect(res.body.ok).to.equal(true);
526528

527529
return supertest(destination)
530+
.put(`/${dbnameToReplicate}/_security`)
531+
.set('cookie', adminSessionCookie)
532+
.set('Accept', 'application/json')
533+
.send({
534+
"members":{"roles":[]},
535+
"admins":{"roles":["_admin"]}
536+
})
537+
})
538+
.then((res) => {
539+
expect(res.body.ok).to.equal(true);
540+
541+
return supertest(couchUrl)
528542
.get(`/${dbnameToReplicate}/_design/prototype`)
529543
.set('Accept', 'application/json');
530544
})
531545
.then((res) => {
532546
debug('res.body prototype after ', res.body);
533547
expect(res.body.couchapp && res.body.couchapp.name).to.contain('Prototype (has the most features of the apps)', JSON.stringify(res.body));
534548

535-
return supertest(destination)
549+
return supertest(couchUrl)
536550
.get(`/${dbnameToReplicate}/_design/prototype/user.html`);
537551
})
538552
.then((res) => {
539553
debug('res.body prototype after ', res.body);
540554
expect(res.status).to.equal(200);
555+
556+
return supertest(couchUrl)
557+
.get(`/${dbnameToReplicate}/_design/prototype/app/app.css`);
558+
})
559+
.then((res) => {
560+
debug('attachments prototype after ', res.body);
561+
expect(res.status).to.equal(200);
541562
});
542563
});
543564
});

0 commit comments

Comments
 (0)