Skip to content

Commit 96778bd

Browse files
authored
Merge pull request #143 from FieldDB/support-couchapp-attachments
Support couchapp attachments
2 parents 9e5d2ca + 0b1111f commit 96778bd

3 files changed

Lines changed: 30 additions & 2 deletions

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

nyc.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
],
88
'check-coverage': true,
99
branches: 65,
10-
functions: 66,
10+
functions: 65,
1111
lines: 76,
1212
statements: 76,
1313
reporter: ['text', 'lcov'],

test/integration/install.js

Lines changed: 23 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,39 @@ 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+
// The couchapp is public but only admins can write to it
535+
members: { roles: [] },
536+
admins: { roles: ["_admin"] },
537+
});
538+
})
539+
.then((res) => {
540+
expect(res.body.ok).to.equal(true);
541+
542+
return supertest(couchUrl)
528543
.get(`/${dbnameToReplicate}/_design/prototype`)
529544
.set('Accept', 'application/json');
530545
})
531546
.then((res) => {
532547
debug('res.body prototype after ', res.body);
533548
expect(res.body.couchapp && res.body.couchapp.name).to.contain('Prototype (has the most features of the apps)', JSON.stringify(res.body));
534549

535-
return supertest(destination)
550+
return supertest(couchUrl)
536551
.get(`/${dbnameToReplicate}/_design/prototype/user.html`);
537552
})
538553
.then((res) => {
539554
debug('res.body prototype after ', res.body);
540555
expect(res.status).to.equal(200);
556+
557+
return supertest(couchUrl)
558+
.get(`/${dbnameToReplicate}/_design/prototype/app/app.css`);
559+
})
560+
.then((res) => {
561+
debug('attachments prototype after ', res.body);
562+
expect(res.status).to.equal(200);
541563
});
542564
});
543565
});

0 commit comments

Comments
 (0)