Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,4 @@ node_modules
.DS_Store
~*
*.swp
FieldDB
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN ls -alt; \
ls config/local.js || echo " config/local.js is required to be able to run the tests against deployed couchdb"

ENV DEBUG="*,-express*"
ENV NODE_ENV=beta
ENV NODE_ENV=localhost

EXPOSE 3183

Expand Down
2 changes: 1 addition & 1 deletion etc/local.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ credentials = true
attachments_enable = true
; https://docs.couchdb.org/en/stable/cve/2021-38295.html
; use nginx instead to allow only signed couchapps when on deployed server
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';"
attachments_header_value = "child-src 'self' data: blob:; default-src 'self'; connect-src 'self' https://corpusdev.example.com https://localhost:3183 https://www.google-analytics.com; img-src 'self' data: https://secure.gravatar.com; font-src 'self' https://themes.googleusercontent.com; script-src 'self' 'unsafe-eval' https://www.google-analytics.com; style-src 'self' 'unsafe-inline';"

[couchdb]
single_node=true
Expand Down
8 changes: 5 additions & 3 deletions lib/corpus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { couchKeys } = require('config');
const { couchKeys, usersDbConnection } = require('config');
const debug = require('debug')('lib:corpus');
const url = require('url');
const { Corpus } = require('fielddb/api/corpus/Corpus');
Expand All @@ -16,7 +16,7 @@ const contributor = 'writer';
const admin = 'admin';

// Only create users on the same server.
const parsed = url.parse('http://localhost:5984');
const parsed = url.parse(usersDbConnection.url);
const couchConnectUrl = `${parsed.protocol}//${couchKeys.username}:${couchKeys.password}@${parsed.host}`;
debug('Using corpus url: ', couchConnectUrl);

Expand Down Expand Up @@ -377,6 +377,7 @@ function createNewCorpus({
// }
// });
return newDatabase.bulk({
// TODO this might be using the connction rather than the config's connection about where to write the docs
docs: docsNeededForAProperFieldDBCorpus,
});
})
Expand Down Expand Up @@ -421,7 +422,8 @@ function createNewCorpus({
const err = {
...errOriginal,
};
debug('createNewCorpus', err);
// eslint-disable-next-line no-console
console.error('createNewCorpus', err);
// Clean the error of couchdb leaks
delete err.request;
delete err.headers;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@
},
"scripts": {
"docker:build": "docker build -t fielddb-auth .",
"docker:test": "echo 'module.exports = { usersDbConnection: { url: \"http://localhost:5984\" } };' > config/local.js && docker compose up -d && sleep 3 && docker compose logs && npm run setup && npm run test:deprecated",
"docker:test:no-cache": "echo 'module.exports = { usersDbConnection: { url: \"http://localhost:5984\" } };' > config/local.js && docker compose build --no-cache && docker compose up -d && sleep 15 && docker compose logs && npm run setup && npm run test:deprecated",
"test:integration": "echo 'module.exports = { usersDbConnection: { url: \"http://couchdb:5984\" } };' > config/local.js && docker compose up -d && sleep 3 && docker compose logs && npm run setup && npm run test:deprecated",
"docker:test:no-cache": "echo 'module.exports = { usersDbConnection: { url: \"http://couchdb:5984\" } };' > config/local.js && docker compose build --no-cache && docker compose up -d && sleep 15 && docker compose logs && npm run setup && npm run test:deprecated",
"coverage": "NODE_ENV=test BUNYAN_LOG_LEVEL=FATAL nyc npm test",
"lint": "eslint ",
"lint:ci": "eslint .",
"setup": "REPLAY=bloody NODE_TLS_REJECT_UNAUTHORIZED=0 SOURCE_URL=${SOURCE_URL:-https://public:none@corpusdev.example.org} mocha --timeout 20000 test/integration/install.js",
"start": "node ./bin/www.js",
"test": "SOURCE_URL=${SOURCE_URL:-https://public:none@corpusdev.example.org} NODE_ENV=test NODE_TLS_REJECT_UNAUTHORIZED=0 mocha --timeout 100000 --recursive test",
"test:debug": "node-debug _mocha test/integration/oauth.js",
"test:deprecated": "DEBUG=${DEBUG:-lib:user} REPLAY=bloody NODE_TLS_REJECT_UNAUTHORIZED=0 nyc mocha --timeout 25000 test/routes/deprecated-spec.js",
"test:deprecated": "DEBUG=${DEBUG:-lib:user} REPLAY=bloody NODE_TLS_REJECT_UNAUTHORIZED=0 URL=https://localhost:3183 nyc mocha --timeout 25000 test/routes/deprecated-spec.js",
"test:fielddb": "NODE_ENV=localhost jasmine-node node_modules/fielddb/tests",
"test:production": "ls config/production.js",
"watch": "nodemon ./bin/www.js"
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/replay/localhost-5984/176495332887018347
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GET /prototype/_design/prototype
GET /prototypedev/_design/prototype
accept-encoding: gzip, deflate
accept: application/json
authorization: Basic YWRtaW46bm9uZQ==
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/replay/localhost-5984/176522423245686959
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GET /prototype/_design/prototype/user.html
GET /prototypedev/_design/prototype/user.html
accept-encoding: gzip, deflate
authorization: Basic YWRtaW46bm9uZQ==

Expand Down
2 changes: 1 addition & 1 deletion test/integration/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ describe('install', () => {
* and the app expects and requires https
*/
it('should replicate prototype', () => {
const dbnameToReplicate = 'prototype';
const dbnameToReplicate = 'prototypedev';

return supertest(destination)
.post('/_replicate')
Expand Down
2 changes: 1 addition & 1 deletion test/routes/deprecated-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('/ deprecated', () => {
// eslint-disable-next-line no-underscore-dangle
debug('before replay localhosts', replay._localhosts);

return supertest(config.usersDbConnection.url)
return supertest(config.usersDbConnection.url.replace('://couchdb', '://localhost'))
.get('/')
.set('Accept', 'application/json')
.then((res) => {
Expand Down
Loading