diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4f21417..1d4154c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,13 +6,21 @@ jobs: steps: - uses: actions/checkout@v2 - name: Install and run Argos with test data - run: docker-compose up -d + run: | + export COUCHDB_USER="TO_BE_CHANGED" + export COUCHDB_PASSWORD="TO_BE_CHANGED" + docker-compose up -d - name: Install test tools run: npm install - - uses: nev7n/wait_for_response@v1 + - name: Wait for database service + uses: docker://benel/wait-for-response:1 with: - url: http://localhost/ - responseCode: 200 + args: http://localhost:5984/hyperglosae 401 5000 500 + - name: Enable public access + run: | + export COUCHDB_USER="TO_BE_CHANGED" + export COUCHDB_PASSWORD="TO_BE_CHANGED" + curl -X PUT -u "${COUCHDB_USER}:${COUCHDB_PASSWORD}" -s localhost:5984/hyperglosae/_security --data '{"members":{"roles":[]},"admins":{"roles":["_admin"]}}' - name: Run tests run : npm test shell: 'script -q -e -c "bash {0}"' diff --git a/app/lists/topicV1.js b/app/lists/topicV1.js index 19b22e3..00fecec 100644 --- a/app/lists/topicV1.js +++ b/app/lists/topicV1.js @@ -39,20 +39,20 @@ function(head, req) { } } send('\n'); - for each (b in broader) { + for (let b of broader) { send(''); send(b.name); send('\n'); } - for each (n in narrower) { + for (let n of narrower) { send(''); send(n.name); send('\n'); } - for each (i in items) { + for (let i of items) { send('\n'); } - for each (h in highlights) { + for (let h of Object.values(highlights)) { send(''); send(util.xmlencode(h.text)); diff --git a/app/lists/viewpointV1.js b/app/lists/viewpointV1.js index 094f5e3..cb13dbe 100644 --- a/app/lists/viewpointV1.js +++ b/app/lists/viewpointV1.js @@ -17,7 +17,7 @@ function(head, req) { } } send('\n'); - for each (t in topics) { + for (let t of Object.values(topics)) { send(''+t.name+'\n'); } send('\n'); diff --git a/app/views/attribute/map.js b/app/views/attribute/map.js index afacb4f..cb49b42 100644 --- a/app/views/attribute/map.js +++ b/app/views/attribute/map.js @@ -29,8 +29,8 @@ function(o) { [o.item_corpus, key, value], {item:{id:o._id, name: o.item_name}} ); - } else { - for each (v in value) { + } else { //array + for (let v of value) { emit( [o.item_corpus, key, v], {item:{id:o._id, name: o.item_name}} diff --git a/app/views/fragmentV1/map.js b/app/views/fragmentV1/map.js index 56a7c72..09ac2fd 100644 --- a/app/views/fragmentV1/map.js +++ b/app/views/fragmentV1/map.js @@ -9,7 +9,7 @@ function(o) { return result; } - for each (h in o.highlights) { + for (let h of Object.values(o.highlights)) { emit([o._id, format(h.coordinates)], { text: h.text, viewpoint: h.viewpoint, diff --git a/app/views/user/map.js b/app/views/user/map.js index 5e9d933..416f625 100644 --- a/app/views/user/map.js +++ b/app/views/user/map.js @@ -1,5 +1,5 @@ function(o) { - for each (u in o.users) { + for (let u of o.users) { if (o.viewpoint_name) { emit([u], {viewpoint:{id:o._id, name:o.viewpoint_name}}); } else if (o.corpus_name) { diff --git a/app/views/viewpoint/map.js b/app/views/viewpoint/map.js index ee6401b..3d46248 100644 --- a/app/views/viewpoint/map.js +++ b/app/views/viewpoint/map.js @@ -20,7 +20,7 @@ function(o) { id:t, name:topics[t].name }); - } else for each(b in broader) { + } else for (let b of broader) { broaderArray.push({ id:b, name:topics[b].name diff --git a/app/views/viewpointV1/map.js b/app/views/viewpointV1/map.js index d8bb65f..470c4e6 100644 --- a/app/views/viewpointV1/map.js +++ b/app/views/viewpointV1/map.js @@ -3,7 +3,7 @@ function(o) { //viewpoint name emit([o._id], {name:o.viewpoint_name}); //viewpoint users - for each (var u in o.users) { + for (let u of o.users) { emit([o._id], {user:u}); } //topics @@ -15,7 +15,7 @@ function(o) { var broader = topics[t].broader; if (broader==null || broader.length==0) { emit([o._id], {upper:{id:t, name:topics[t].name}}); - } else for each(b in broader) { + } else for (let b of broader) { emit([o._id, t], {broader: {id:b, name:topics[b].name}}); emit([o._id, b], {narrower: {id:t, name:topics[t].name}}); } diff --git a/conf/couchdb.ini b/conf/couchdb.ini index 628bc63..e3303dc 100644 --- a/conf/couchdb.ini +++ b/conf/couchdb.ini @@ -1,10 +1,10 @@ [httpd] bind_address = any -secure_rewrites = false ; To use CouchDB users as Argos users [chttpd] bind_address = any authentication_handlers = {chttpd_auth, cookie_authentication_handler}, {chttpd_auth, proxy_authentication_handler}, {chttpd_auth, default_authentication_handler} +secure_rewrites = false ; To use CouchDB users as Argos users -[couch_httpd_auth] +[chttpd_auth] secret = TO_BE_CHANGED diff --git a/docker-compose.yml b/docker-compose.yml index 2179431..e40ec93 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,9 +3,12 @@ version: '3' services: couchdb: - image: couchdb:2 + image: couchdb:3 ports: - 5984:5984 + environment: + - COUCHDB_USER=${COUCHDB_USER} + - COUCHDB_PASSWORD=${COUCHDB_PASSWORD} volumes: - ./data:/opt/couchdb/data - ./conf/couchdb.ini:/opt/couchdb/etc/local.d/docker.ini @@ -30,7 +33,7 @@ services: image: benel/couchapp command: pushdocs . environment: - - URI=http://couchdb:5984/argos + - URI=http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb:5984/argos volumes: - ./__tests__/api/fixtures:/app depends_on: @@ -40,7 +43,7 @@ services: image: benel/couchapp command: push . environment: - - URI=http://couchdb:5984/argos + - URI=http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb:5984/argos volumes: - ./app:/app depends_on: