From b82388b135c1c90e1199804bad6b06757b14d841 Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 11:27:31 -0500 Subject: [PATCH 01/18] make integration tests required --- .github/workflows/node.js.yml | 2 +- test/integration/install.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index f7017350..b81c0a08 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -28,7 +28,7 @@ jobs: cache: 'npm' - run: npm ci - run: npm run lint:ci - - run: DEBUG=replay* npm run coverage || echo "warn some tests failed remove this warning after re-recording" + - run: DEBUG=replay* npm run coverage - name: Coveralls uses: coverallsapp/github-action@master diff --git a/test/integration/install.js b/test/integration/install.js index 5a3b3673..71ef5d6a 100644 --- a/test/integration/install.js +++ b/test/integration/install.js @@ -17,14 +17,16 @@ if (!destination) { destination = url.format(destination).replace(/\/$/, ''); } const source = process.env.SOURCE_URL; +const REPLAY = process.env.REPLAY || ''; debug('destination', destination); debug('source', source); let adminSessionCookie; +let couchDBInfo; const usersDBname = config.usersDbConnection.dbname; describe('install', () => { before(() => { - if (source.includes('example.org')) { + if (REPLAY === 'bloody' && source.includes('example.org')) { throw new Error('SOURCE_URL is not set to a valid test CouchDB instance. Please export SOURCE_URL=http://public:none@thecouchinstance.org'); } // eslint-disable-next-line no-underscore-dangle @@ -44,6 +46,16 @@ describe('install', () => { const setCookie = res.headers['set-cookie'].length === 1 ? res.headers['set-cookie'][0] : res.headers['set-cookie']; [adminSessionCookie] = setCookie.split(';'); debug('adminSessionCookie', adminSessionCookie); + + return supertest(destination) + .get('/') + .set('Accept', 'application/json'); + }) + .then((res) => { + expect(res.status).to.equal(200); + debug('couchdb version', res.body); + couchDBInfo = res.body; + expect(couchDBInfo.version).to.equal('3.5.1', JSON.stringify(couchDBInfo)); }); }); after(() => { From 4a855e4e2bbf2acbc4e5bef6db93b4a5a854e90b Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 11:40:08 -0500 Subject: [PATCH 02/18] record test fixture --- .../replay/localhost-5984/176495272728627547 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/fixtures/replay/localhost-5984/176495272728627547 diff --git a/test/fixtures/replay/localhost-5984/176495272728627547 b/test/fixtures/replay/localhost-5984/176495272728627547 new file mode 100644 index 00000000..ea81c08c --- /dev/null +++ b/test/fixtures/replay/localhost-5984/176495272728627547 @@ -0,0 +1,16 @@ +GET / +accept-encoding: gzip, deflate +accept: application/json +authorization: Basic YWRtaW46bm9uZQ== + +HTTP/1.1 200 OK +cache-control: must-revalidate +connection: close +content-length: 247 +content-type: application/json +date: Fri, 05 Dec 2025 16:38:46 GMT +server: CouchDB/3.5.1 (Erlang OTP/26) +x-couch-request-id: b36d62f8f4 +x-couchdb-body-time: 0 + +{"couchdb":"Welcome","version":"3.5.1","git_sha":"44f6a43d8","uuid":"8507dcd80018afd3e0af696947fb57a0","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}} From 268a2624a1711232ffa8565db77b33168a5b6f6d Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 11:46:21 -0500 Subject: [PATCH 03/18] record new requests for data design doc --- README.md | 6 +++--- .../replay/localhost-5984/176495308615380142 | 18 ++++++++++++++++++ .../replay/localhost-5984/176495308617582340 | 18 ++++++++++++++++++ .../replay/localhost-5984/176495332885835169 | 18 ++++++++++++++++++ .../replay/localhost-5984/176495332887018347 | 17 +++++++++++++++++ .../replay/localhost-5984/176495339703342154 | 18 ++++++++++++++++++ .../replay/localhost-5984/176495339704887089 | 18 ++++++++++++++++++ test/integration/install.js | 10 +--------- 8 files changed, 111 insertions(+), 12 deletions(-) create mode 100644 test/fixtures/replay/localhost-5984/176495308615380142 create mode 100644 test/fixtures/replay/localhost-5984/176495308617582340 create mode 100644 test/fixtures/replay/localhost-5984/176495332885835169 create mode 100644 test/fixtures/replay/localhost-5984/176495332887018347 create mode 100644 test/fixtures/replay/localhost-5984/176495339703342154 create mode 100644 test/fixtures/replay/localhost-5984/176495339704887089 diff --git a/README.md b/README.md index 614e406d..8b4beea8 100644 --- a/README.md +++ b/README.md @@ -30,10 +30,10 @@ Edit your /etc/hosts to add an entry for example.org: 127.0.0.1 corpusdev.example.org ``` -Turn on your local couchdb and make sure it is running on http://127.0.0.1:5984/_utils Record tests by adding `.only` on the tests you wish to record: +Turn on your local couchdb and make sure it is running on http://127.0.0.1:5984/_utils Record tests by adding `.only` on the tests which show the error "refused: not recording and no network access": ```bash -$ DEBUG=*user*,*nock*,*replay* REPLAY=record npm test +$ SOURCE_URL:-https://public:none@corpusdev.other.org DEBUG=*user*,*nock*,*replay* REPLAY=record npm test ``` As a result you should see a directory corresponding to the server, and files with-in it representing the requests: @@ -41,7 +41,7 @@ As a result you should see a directory corresponding to the server, and files wi ```bash $ tree test/fixtures/ test/fixtures/ -└── corpusdev.example.org-5984 +└── corpusdev.other.org-5984 └── 154417467505825257 ``` diff --git a/test/fixtures/replay/localhost-5984/176495308615380142 b/test/fixtures/replay/localhost-5984/176495308615380142 new file mode 100644 index 00000000..f551ed68 --- /dev/null +++ b/test/fixtures/replay/localhost-5984/176495308615380142 @@ -0,0 +1,18 @@ +POST /_replicate +accept-encoding: gzip, deflate +accept: application/json +content-type: application/json +authorization: Basic YWRtaW46bm9uZQ== +body: {\"source\":\"https://public:none@corpusdev.example.org/new_testing_corpus\",\"target\":{\"url\":\"http://admin:none@localhost:5984/new_testing_corpus\"},\"create_target\":true} + +HTTP/1.1 200 OK +cache-control: must-revalidate +connection: close +content-length: 467 +content-type: application/json +date: Fri, 05 Dec 2025 16:44:45 GMT +server: CouchDB/3.5.1 (Erlang OTP/26) +x-couch-request-id: d8c38818eb +x-couchdb-body-time: 0 + +{"ok":true,"no_changes":true,"session_id":"8aea8e2d34fea1a6ea6ba5f998f37102","source_last_seq":22,"replication_id_version":4,"history":[{"session_id":"8aea8e2d34fea1a6ea6ba5f998f37102","start_time":"Fri, 05 Dec 2025 15:55:24 GMT","end_time":"Fri, 05 Dec 2025 15:55:30 GMT","start_last_seq":0,"end_last_seq":22,"recorded_seq":22,"missing_checked":11,"missing_found":11,"docs_read":11,"docs_written":11,"doc_write_failures":0,"bulk_get_docs":0,"bulk_get_attempts":1}]} diff --git a/test/fixtures/replay/localhost-5984/176495308617582340 b/test/fixtures/replay/localhost-5984/176495308617582340 new file mode 100644 index 00000000..f55c6248 --- /dev/null +++ b/test/fixtures/replay/localhost-5984/176495308617582340 @@ -0,0 +1,18 @@ +GET /new_testing_corpus/_design/data/_view/by_type?group=true +accept-encoding: gzip, deflate +accept: application/json +authorization: Basic YWRtaW46bm9uZQ== + +HTTP/1.1 200 OK +cache-control: must-revalidate +connection: close +content-type: application/json +date: Fri, 05 Dec 2025 16:44:45 GMT +server: CouchDB/3.5.1 (Erlang OTP/26) +transfer-encoding: chunked +x-couch-request-id: fedc7785b6 +x-couchdb-body-time: 0 + +{"rows":[ + +]} diff --git a/test/fixtures/replay/localhost-5984/176495332885835169 b/test/fixtures/replay/localhost-5984/176495332885835169 new file mode 100644 index 00000000..a4f8151c --- /dev/null +++ b/test/fixtures/replay/localhost-5984/176495332885835169 @@ -0,0 +1,18 @@ +POST /_replicate +accept-encoding: gzip, deflate +accept: application/json +content-type: application/json +authorization: Basic YWRtaW46bm9uZQ== +body: {\"source\":\"https://public:none@corpusdev.example.org/prototype\",\"target\":{\"url\":\"http://admin:none@localhost:5984/prototype\"},\"create_target\":true} + +HTTP/1.1 200 OK +cache-control: must-revalidate +connection: close +content-length: 460 +content-type: application/json +date: Fri, 05 Dec 2025 16:48:48 GMT +server: CouchDB/3.5.1 (Erlang OTP/26) +x-couch-request-id: 9cec85f832 +x-couchdb-body-time: 0 + +{"ok":true,"no_changes":true,"session_id":"4110a14cfef05159b6594966eafc187e","source_last_seq":1,"replication_id_version":4,"history":[{"session_id":"4110a14cfef05159b6594966eafc187e","start_time":"Fri, 05 Dec 2025 15:55:30 GMT","end_time":"Fri, 05 Dec 2025 15:55:36 GMT","start_last_seq":0,"end_last_seq":1,"recorded_seq":1,"missing_checked":1,"missing_found":1,"docs_read":1,"docs_written":1,"doc_write_failures":0,"bulk_get_docs":0,"bulk_get_attempts":0}]} diff --git a/test/fixtures/replay/localhost-5984/176495332887018347 b/test/fixtures/replay/localhost-5984/176495332887018347 new file mode 100644 index 00000000..3c6ce541 --- /dev/null +++ b/test/fixtures/replay/localhost-5984/176495332887018347 @@ -0,0 +1,17 @@ +GET /prototype/_design/prototype +accept-encoding: gzip, deflate +accept: application/json +authorization: Basic YWRtaW46bm9uZQ== + +HTTP/1.1 200 OK +cache-control: must-revalidate +connection: close +content-length: 13892 +content-type: application/json +date: Fri, 05 Dec 2025 16:48:48 GMT +etag: "5-aedbbb7468a2df2584ba41e2159ea783" +server: CouchDB/3.5.1 (Erlang OTP/26) +x-couch-request-id: 8c0e644481 +x-couchdb-body-time: 0 + +{"_id":"_design/prototype","_rev":"5-aedbbb7468a2df2584ba41e2159ea783","couchapp":{"name":" Prototype (has the most features of the apps)","description":"","manifest":["language","couchapp.json"],"config":"none","pushed_by":"admin","push_time":"2016-12- 7T04:05:23","build_time":"2016-12- 7T04:05:23","signatures":{"user_online_dashboard.js":"427bccc1941a59f8ceb8952ab1545cbf","user.html":"5a15621e98f97e8779516845b689edd","manifest.json":"9afa1abacbbee96c65ecf9c66a7bfc4","favicon.ico":"74477cb1846cdadaa31359a9c5eca2","corpus_online_dashboard.js":"299bb98d85d09ed6be92f1aaea9fd190","corpus.html":"755d2b38bbe7f3b9241620c697e367","activity/activity_transparent.css":"9d83bdcced24c08c2aada3dcb89cb3dc","activity/activity_feed_transparent.html":"a0e61d6df77958ccb66e96c885c64b","activity/activity_feed.html":"86e2f5a15e17862649f18dd7c66f811","activity/activity.css":"ff884b741041ae94d968d2b2aedbbe2","activity/ActivityTest.js":"ca4838be282addd6a2e1dc14812e32ca","activity/Activity.js":"8e61b582ac1e3fbcc38e5cd547a35e","activity/img/icon.png":"f1e331cb51e49dea51448a95ceaa65b9","activity/libs/require.min.js":"d3b5c0615de8c0f84e73b64aca6b5ce1","activity/libs/fielddb_activity_feed_widget.js":"a963a0608d86a5ddfef632602d7a15e0","activity/libs/angular/angular.min.js":"2a3aff50eaafdac1cde30437495f138","activity/libs/font_awesome/fontawesome-webfont.ttf":"6ea09593203493bfd053a1e838c6244","activity/libs/font_awesome/font-awesome.css":"befea2e933b9fabb68ad88da6e8a85","activity/libs/font_awesome/FontAwesome.ttf":"a92b759b75f8b0a68eb0aca86d1580","activity/partials/activity_feed_widget.html":"78de28eaad5bfecedbb687ecf4c9cfd","app/sorry.css":"b3bcd3f5b197e7881fafa6b32cff3fe","app/not_high_contrast.css":"d41d8cd98f0b24e980998ecf8427e","app/high_contrast.css":"2936b457d5b064539d6dd1d9c726493","app/app_transparent.css":"f47c83895f5fc96167ac5710ee5c6cfa","app/app_opaque.css":"ebf41ef5a94efff768363249c36747","app/app.css":"30acd02a49a48bea3b2a22483d85632d","bower_components/fielddb/fielddb.js":"54d699941207366fa959507529358","bower_components/requirejs/require.js":"6da8be361b9ee26c5e721e76c6d4afce","images/spinner.gif":"2295168fe464b9edd1719c520869bc1","images/or_venn_diagram.png":"1066613f186f7658ac799d24555953","images/loader.gif":"e6ef46d7504242302bc855ad9c8c2","images/icon48_dev.png":"2b792ccb78aa29249f25dad93b858f","images/icon16_dev.png":"d01089f31b3a30d471507720eaebc7","images/icon128_dev.png":"eaf936927e2417fee44dfb8a0317d3b","images/icon.png":"eaf936927e2417fee44dfb8a0317d3b","images/and_venn_diagram.png":"c919bcf6355c2f8bbc998528518fab5a","libs/analytics.js":"72a3cc59aa6b5e6b126c5abd12fca5ed","libs/bootstrap/css/bootstrap.min.css":"4082271c7f87b09c771ffe554e61edd","libs/bootstrap/css/bootstrap.css":"a5368494d9927b35e02b575973e9f","libs/bootstrap/css/bootstrap-responsive.min.css":"f889adb0886162aa4ceab5ff6338d888","libs/bootstrap/css/bootstrap-responsive.css":"871defe8c1a928bcbcc3efcf4a1dde42","libs/font_awesome/fontawesome-webfont.ttf":"2df212afaa8c678e50d5f7e992c890","libs/font_awesome/font-awesome.css":"3294ed9ba5ccd230a912dd737c2a6827","libs/font_awesome/FontAwesome.ttf":"a92b759b75f8b0a68eb0aca86d1580","user/layouts/layout5_everything_at_once.png":"c9a35a356064581db826cb47fa5597a7","user/layouts/layout4_compare_datalists.png":"8e321512d1ce09af82acd876281378","user/layouts/layout3_whats_happening.png":"dfc32fd3afedcf2f1a4d5dcb314e3d7","user/layouts/layout2_all_the_data.png":"e3246530ac9412c4647f1c44abeb6ac","user/layouts/layout1_just_entering.png":"c9cce36d59798c47c381ac9459eb7dc","user/skins/yellow.jpg":"eb2eb2c24e5d572d0743d1d727a4cac","user/skins/window.jpg":"b270d57bd995e6d82de666ebe67d4932","user/skins/white.jpg":"49c8e77c4bd53031c135e3fa627ef7","user/skins/weaving.jpg":"c4b28225c18c2f4e25dee496df6b6d1","user/skins/temple.jpg":"773f582c747d8a9e6d1a1801a47307e","user/skins/sunset.jpg":"37c556b7c3a16ffb6972a76c122a42","user/skins/stone_figurines.jpg":"8d3ace113b75d5fb24523dd1e3bd9e","user/skins/stbasil.jpg":"10428437cfedf75734648af6d24763","user/skins/stairs.jpg":"cff9664de6e41d36ac749b212d6f51","user/skins/salcantay.jpg":"51313e392931d37079e5d3932047cfe9","user/skins/prague.jpg":"3b29e01e3ef41d8a5d01fb330e23ff9","user/skins/machu_picchu2.jpg":"1221d78641b7dfe77cadee58fa1e10bf","user/skins/machu_picchu.jpg":"1e46c44325f724ad7522528935d07da","user/skins/llama_wool.jpg":"28a0bfcffd48ec33dd50d9cee5b5f1","user/skins/black.jpg":"e4e7c3bed6eac6f994ef28f411dfb1af","user/skins/bamboo_garden.jpg":"88bbfeb879f3a91e110a564bc53267","user/skins/Ceske_Krumlov.jpg":"8f939db480b7553651176eb5d8c3bfb4"},"objects":{}},"language":"javascript","_attachments":{"corpus_online_dashboard.js":{"content_type":"application/x-javascript","revpos":5,"digest":"md5-KZu5jYXQnta+kvGq6p/RkA==","length":4210315,"stub":true},"user_online_dashboard.js":{"content_type":"application/x-javascript","revpos":5,"digest":"md5-QnvMwZQaWfjOuJUqsVRcvw==","length":4229398,"stub":true},"bower_components/fielddb/fielddb.js":{"content_type":"application/x-javascript","revpos":4,"digest":"md5-VNaZCUEgc2b6CVlQdSkDWA==","length":1913296,"stub":true},"app/app.css":{"content_type":"text/css","revpos":4,"digest":"md5-0axYczjbHMy3In/4MuY8aA==","length":21243,"stub":true},"manifest.json":{"content_type":"text/plain","revpos":4,"digest":"md5-Iz93GYGxSJJEPhXkejNmgw==","length":952,"stub":true},"user/skins/Ceske_Krumlov.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-j5OdtIC3VTZRF2612MO/tA==","length":540608,"stub":true},"user/skins/bamboo_garden.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-iAu/64efOpHhEKVkvAUyZw==","length":447914,"stub":true},"user/skins/black.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-5OfDvtbqxvmU7yj0Ed+xrw==","length":28706,"stub":true},"user/skins/llama_wool.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-KKC/DP/UjsMD3VDZzuW18Q==","length":494350,"stub":true},"user/skins/machu_picchu.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-HkbEQyX3JK11IlKJNdAH2g==","length":249809,"stub":true},"user/skins/machu_picchu2.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-EiHXhkG33+d8re5Y+h4Qvw==","length":339235,"stub":true},"user/skins/prague.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-OyngHj70HYpdAB+zMOI/+Q==","length":369303,"stub":true},"user/skins/salcantay.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-UTE+OSkx03B55dOTIEfP6Q==","length":387882,"stub":true},"user/skins/stairs.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-z/lmTQ5uQdNqx0kLIS1vUQ==","length":749177,"stub":true},"user/skins/stbasil.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-EEKEA3z+33VzRkivbSR2Aw==","length":424689,"stub":true},"user/skins/stone_figurines.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-jTrOARO3XV+yRSPdAeO9ng==","length":565301,"stub":true},"user/skins/sunset.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-A3wFVrfDoW/7aXKnbBIqQg==","length":370127,"stub":true},"user/skins/temple.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-dz9YAsdH2Knm0aGAGkcwfg==","length":677320,"stub":true},"user/skins/weaving.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-xLKCAlwYwvTiXe5Jbfa20Q==","length":452317,"stub":true},"user/skins/white.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-ScjnfEsNBTAxwTXj+mJ+9w==","length":28706,"stub":true},"user/skins/yellow.jpg":{"content_type":"image/jpeg","revpos":3,"digest":"md5-6y6ywk4F1XLQdD0dcnpMrA==","length":28709,"stub":true},"user/skins/window.jpg":{"content_type":"image/jpeg","revpos":1,"digest":"md5-snDVe9mV5tgt5mbr5n1JMg==","length":395934,"stub":true},"user/layouts/layout1_just_entering.png":{"content_type":"image/png","revpos":1,"digest":"md5-yczjbVl5jEfDgQrJRZ633A==","length":6010,"stub":true},"user/layouts/layout2_all_the_data.png":{"content_type":"image/png","revpos":1,"digest":"md5-4yRlMKyUEsRkfxxEqw62rA==","length":9591,"stub":true},"user/layouts/layout3_whats_happening.png":{"content_type":"image/png","revpos":1,"digest":"md5-38Mv06/tDPLxpNXcsxTj1w==","length":11944,"stub":true},"user/layouts/layout4_compare_datalists.png":{"content_type":"image/png","revpos":1,"digest":"md5-COMhUS0c4Jr4Ks2HYoEDeA==","length":8055,"stub":true},"user/layouts/layout5_everything_at_once.png":{"content_type":"image/png","revpos":1,"digest":"md5-yaNaNWBkWB24JstH+lWXpw==","length":14967,"stub":true},"libs/font_awesome/FontAwesome.ttf":{"content_type":"application/x-font-ttf","revpos":1,"digest":"md5-qSt1mwdfCLCmjrCsqG0VgA==","length":23156,"stub":true},"libs/font_awesome/font-awesome.css":{"content_type":"text/css","revpos":1,"digest":"md5-n8nzHpS6uolJMmAJ5OserA==","length":19601,"stub":true},"libs/font_awesome/fontawesome-webfont.ttf":{"content_type":"application/x-font-ttf","revpos":1,"digest":"md5-LfISr6qMZ45Q1ffpCQLIkA==","length":60296,"stub":true},"libs/bootstrap/css/bootstrap-responsive.css":{"content_type":"text/css","revpos":1,"digest":"md5-kc+T1/0Qzo7AV5vXIddWKA==","length":22111,"stub":true},"libs/bootstrap/css/bootstrap-responsive.min.css":{"content_type":"text/css","revpos":1,"digest":"md5-7PxggslCSZCM38ooKKHZ1w==","length":16849,"stub":true},"libs/bootstrap/css/bootstrap.css":{"content_type":"text/css","revpos":1,"digest":"md5-8Xltrfno/gv+Qy+OFtvPEw==","length":127352,"stub":true},"libs/bootstrap/css/bootstrap.min.css":{"content_type":"text/css","revpos":1,"digest":"md5-fwPI76E2FFIYU0VIa7z6ow==","length":106015,"stub":true},"libs/analytics.js":{"content_type":"application/x-javascript","revpos":1,"digest":"md5-cqPMWaprXmsSbFq9Evyl7Q==","length":5779,"stub":true},"images/and_venn_diagram.png":{"content_type":"image/png","revpos":1,"digest":"md5-yRm89jVcL4u8mYUoUY+rWg==","length":4741,"stub":true},"images/icon.png":{"content_type":"image/png","revpos":1,"digest":"md5-6vk2kn4kF/7kTQ+4oDF9Ow==","length":26140,"stub":true},"images/icon128_dev.png":{"content_type":"image/png","revpos":1,"digest":"md5-6vk2kn4kF/7kTQ+4oDF9Ow==","length":26140,"stub":true},"images/icon16_dev.png":{"content_type":"image/png","revpos":1,"digest":"md5-0BCJ8xs6MA0EcVB3IOrrxw==","length":3586,"stub":true},"images/icon48_dev.png":{"content_type":"image/png","revpos":1,"digest":"md5-K3ksy3iqKSQJ8l2tCTuFjw==","length":7769,"stub":true},"images/loader.gif":{"content_type":"image/gif","revpos":1,"digest":"md5-Dm4PRtdQQkIwK8gFWtnIwg==","length":3897,"stub":true},"images/or_venn_diagram.png":{"content_type":"image/png","revpos":1,"digest":"md5-EGZhPxhvdlgKxwmdJFVZUw==","length":5049,"stub":true},"images/spinner.gif":{"content_type":"image/gif","revpos":1,"digest":"md5-IglRaP5GS57dFxnFIIabwQ==","length":8534,"stub":true},"bower_components/requirejs/require.js":{"content_type":"application/x-javascript","revpos":1,"digest":"md5-bai+Nhue4mxech52xtSvzg==","length":85921,"stub":true},"app/app_opaque.css":{"content_type":"text/css","revpos":1,"digest":"md5-rVFjJW71+KOxC+W7kxv0Ug==","length":354,"stub":true},"app/app_transparent.css":{"content_type":"text/css","revpos":1,"digest":"md5-LgHWLMty7P1lg5LVkKRxBQ==","length":1514,"stub":true},"app/high_contrast.css":{"content_type":"text/css","revpos":1,"digest":"md5-9ApoWSIhxoxuUu2WG0bLOw==","length":1387,"stub":true},"app/not_high_contrast.css":{"content_type":"text/css","revpos":1,"digest":"md5-cCkGbCesb17xjWYNV0GXmg==","length":0,"stub":true},"app/sorry.css":{"content_type":"text/css","revpos":1,"digest":"md5-7SJ31jNjmP6b1lgNK2tCtA==","length":202,"stub":true},"activity/partials/activity_feed_widget.html":{"content_type":"text/html","revpos":1,"digest":"md5-igL/PLeOZVc0Mvnn770geg==","length":1724,"stub":true},"activity/libs/font_awesome/FontAwesome.ttf":{"content_type":"application/x-font-ttf","revpos":1,"digest":"md5-qSt1mwdfCLCmjrCsqG0VgA==","length":23156,"stub":true},"activity/libs/font_awesome/font-awesome.css":{"content_type":"text/css","revpos":1,"digest":"md5-8EBfP+g+gZeG2hSF8QRXEA==","length":14658,"stub":true},"activity/libs/font_awesome/fontawesome-webfont.ttf":{"content_type":"application/x-font-ttf","revpos":1,"digest":"md5-bqCVkyA0k7/QU6HoOMYkBA==","length":68476,"stub":true},"activity/libs/angular/angular.min.js":{"content_type":"application/x-javascript","revpos":1,"digest":"md5-Kjr/UA6q/awc3jBDdJXxOA==","length":78280,"stub":true},"activity/libs/fielddb_activity_feed_widget.js":{"content_type":"application/x-javascript","revpos":1,"digest":"md5-qWOgYI2Gpd3+9jJgLXoV4A==","length":532538,"stub":true},"activity/libs/require.min.js":{"content_type":"application/x-javascript","revpos":1,"digest":"md5-07XAYV3owPhOc7ZKymtc4Q==","length":14536,"stub":true},"activity/img/icon.png":{"content_type":"image/png","revpos":1,"digest":"md5-8eMxy1HknepRRIqVzqpluQ==","length":19086,"stub":true},"activity/Activity.js":{"content_type":"application/x-javascript","revpos":1,"digest":"md5-jmELWAKsHj+8w45c1UejXg==","length":5188,"stub":true},"activity/ActivityTest.js":{"content_type":"application/x-javascript","revpos":1,"digest":"md5-ykg4vigq3dai4dwUgS4yyg==","length":4410,"stub":true},"activity/activity.css":{"content_type":"text/css","revpos":1,"digest":"md5-LscQnv3VMQFaD7fms8ZM0Q==","length":1734,"stub":true},"activity/activity_feed.html":{"content_type":"text/html","revpos":1,"digest":"md5-N6CxOQ5784Bg0QUbcdc3bA==","length":429,"stub":true},"activity/activity_feed_transparent.html":{"content_type":"text/html","revpos":1,"digest":"md5-8hU5G4O3ZwmfA4QodJIA4Q==","length":441,"stub":true},"activity/activity_transparent.css":{"content_type":"text/css","revpos":1,"digest":"md5-PhzJ1HN2dIBRAG/j0AgGDQ==","length":1733,"stub":true},"corpus.html":{"content_type":"text/html","revpos":1,"digest":"md5-3Smx9vVYf7n3JTX/XmiCdQ==","length":14095,"stub":true},"favicon.ico":{"content_type":"image/x-icon","revpos":1,"digest":"md5-dEd8sYRs2tqjEwUJqcXsog==","length":1150,"stub":true},"user.html":{"content_type":"text/html","revpos":1,"digest":"md5-+itkiZDS3GHzHgjTjOi3SA==","length":986,"stub":true}}} diff --git a/test/fixtures/replay/localhost-5984/176495339703342154 b/test/fixtures/replay/localhost-5984/176495339703342154 new file mode 100644 index 00000000..e8014906 --- /dev/null +++ b/test/fixtures/replay/localhost-5984/176495339703342154 @@ -0,0 +1,18 @@ +POST /_replicate +accept-encoding: gzip, deflate +accept: application/json +content-type: application/json +authorization: Basic YWRtaW46bm9uZQ== +body: {\"source\":\"https://public:none@corpusdev.example.org/new_lexicon\",\"target\":{\"url\":\"http://admin:none@localhost:5984/new_lexicon\"},\"create_target\":true} + +HTTP/1.1 200 OK +cache-control: must-revalidate +connection: close +content-length: 460 +content-type: application/json +date: Fri, 05 Dec 2025 16:49:56 GMT +server: CouchDB/3.5.1 (Erlang OTP/26) +x-couch-request-id: 94cb5df725 +x-couchdb-body-time: 0 + +{"ok":true,"no_changes":true,"session_id":"cc4843d9da47e904e3722c77afdd49fd","source_last_seq":7,"replication_id_version":4,"history":[{"session_id":"cc4843d9da47e904e3722c77afdd49fd","start_time":"Fri, 05 Dec 2025 15:55:41 GMT","end_time":"Fri, 05 Dec 2025 15:55:42 GMT","start_last_seq":0,"end_last_seq":7,"recorded_seq":7,"missing_checked":2,"missing_found":2,"docs_read":2,"docs_written":2,"doc_write_failures":0,"bulk_get_docs":0,"bulk_get_attempts":0}]} diff --git a/test/fixtures/replay/localhost-5984/176495339704887089 b/test/fixtures/replay/localhost-5984/176495339704887089 new file mode 100644 index 00000000..250330e6 --- /dev/null +++ b/test/fixtures/replay/localhost-5984/176495339704887089 @@ -0,0 +1,18 @@ +GET /new_lexicon/_design/lexicon/_view/lexiconNodes?group=true +accept-encoding: gzip, deflate +accept: application/json +authorization: Basic YWRtaW46bm9uZQ== + +HTTP/1.1 200 OK +cache-control: must-revalidate +connection: close +content-type: application/json +date: Fri, 05 Dec 2025 16:49:56 GMT +server: CouchDB/3.5.1 (Erlang OTP/26) +transfer-encoding: chunked +x-couch-request-id: 0cff5356c1 +x-couchdb-body-time: 0 + +{"rows":[ + +]} diff --git a/test/integration/install.js b/test/integration/install.js index 71ef5d6a..88b6d31d 100644 --- a/test/integration/install.js +++ b/test/integration/install.js @@ -188,7 +188,7 @@ describe('install', () => { }) .then((res) => { debug('res.body new_testing_corpus', res.body); - expect(res.body.ok).to.equal(true); + expect(res.body.ok).to.equal(true, JSON.stringify(res.body)); return supertest(destination) .get('/_all_dbs') @@ -228,14 +228,6 @@ describe('install', () => { debug('res.body prototype', res.body); expect(res.body.ok).to.equal(true); - return supertest(destination) - .get('/_all_dbs') - .set('Accept', 'application/json'); - }) - .then((res) => { - debug('res.body prototype after', res.body); - expect(res.body).includes(dbnameToReplicate); - return supertest(destination) .get(`/${dbnameToReplicate}/_design/prototype`) .set('Accept', 'application/json'); From dc5dfe6cb2d55be215a075914fa8d34099d94358 Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 12:04:20 -0500 Subject: [PATCH 04/18] use couchdb version to expect info response --- .../replay/localhost-5984/176495380910390373 | 15 +++++++++++++++ test/routes/deprecated-spec.js | 17 ++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/replay/localhost-5984/176495380910390373 diff --git a/test/fixtures/replay/localhost-5984/176495380910390373 b/test/fixtures/replay/localhost-5984/176495380910390373 new file mode 100644 index 00000000..055dd7e7 --- /dev/null +++ b/test/fixtures/replay/localhost-5984/176495380910390373 @@ -0,0 +1,15 @@ +GET / +accept-encoding: gzip, deflate +accept: application/json + +HTTP/1.1 200 OK +cache-control: must-revalidate +connection: close +content-length: 247 +content-type: application/json +date: Fri, 05 Dec 2025 16:56:48 GMT +server: CouchDB/3.5.1 (Erlang OTP/26) +x-couch-request-id: 18b668d415 +x-couchdb-body-time: 0 + +{"couchdb":"Welcome","version":"3.5.1","git_sha":"44f6a43d8","uuid":"8507dcd80018afd3e0af696947fb57a0","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}} diff --git a/test/routes/deprecated-spec.js b/test/routes/deprecated-spec.js index 5cc8b20c..f4b306de 100644 --- a/test/routes/deprecated-spec.js +++ b/test/routes/deprecated-spec.js @@ -1,15 +1,19 @@ const debug = require('debug')('test:deprecated'); const { expect } = require('chai'); +const config = require('config'); const path = require('path'); const replay = require('replay'); const supertest = require('supertest'); // eslint-disable-next-line global-require const authWebService = process.env.URL || require('../../auth_service'); +const REPLAY = process.env.REPLAY || ''; + // eslint-disable-next-line no-underscore-dangle const originalLocalhosts = replay._localhosts; const requestId = 'deprecated-spec'; replay.fixtures = path.join(__dirname, '/../fixtures/replay'); +let couchDBInfo; describe('/ deprecated', () => { const testUsername = process.env.REPLAY ? `test${Date.now()}` : 'test1637710294972'; @@ -19,6 +23,16 @@ describe('/ deprecated', () => { replay._localhosts = new Set(['127.0.0.1', '::1']); // eslint-disable-next-line no-underscore-dangle debug('before replay localhosts', replay._localhosts); + + return supertest(config.usersDbConnection.url) + .get('/') + .set('Accept', 'application/json') + .then((res) => { + expect(res.status).to.equal(200); + debug('couchdb version', res.body); + couchDBInfo = res.body; + expect(couchDBInfo.version).to.be.a('string', JSON.stringify(couchDBInfo)); + }); }); after(() => { // eslint-disable-next-line no-underscore-dangle @@ -84,7 +98,8 @@ describe('/ deprecated', () => { ], }, info: { - authentication_handlers: ['cookie', 'default'], + authentication_db: couchDBInfo.version = '1.6.1' ? '_users' : undefined, + authentication_handlers: couchDBInfo.version = '1.6.1' ? ['oauth', 'cookie', 'default'] : ['cookie', 'default'], authenticated: 'default', }, }, 'should have roles'); From 953d58b3d69e5cf28ccc0c0fa88137f0f4c08d11 Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 12:06:13 -0500 Subject: [PATCH 05/18] fix lint --- test/routes/deprecated-spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/routes/deprecated-spec.js b/test/routes/deprecated-spec.js index f4b306de..0230b705 100644 --- a/test/routes/deprecated-spec.js +++ b/test/routes/deprecated-spec.js @@ -16,7 +16,7 @@ replay.fixtures = path.join(__dirname, '/../fixtures/replay'); let couchDBInfo; describe('/ deprecated', () => { - const testUsername = process.env.REPLAY ? `test${Date.now()}` : 'test1637710294972'; + const testUsername = REPLAY ? `test${Date.now()}` : 'test1637710294972'; before(() => { // eslint-disable-next-line no-underscore-dangle @@ -99,7 +99,7 @@ describe('/ deprecated', () => { }, info: { authentication_db: couchDBInfo.version = '1.6.1' ? '_users' : undefined, - authentication_handlers: couchDBInfo.version = '1.6.1' ? ['oauth', 'cookie', 'default'] : ['cookie', 'default'], + authentication_handlers: couchDBInfo.version = '1.6.1' ? ['oauth', 'cookie', 'default'] : ['cookie', 'default'], authenticated: 'default', }, }, 'should have roles'); From c084475fc152cb5b30d25b81382befc29358249d Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 12:14:13 -0500 Subject: [PATCH 06/18] copy response from couchdb 1.6 --- .../corpusdev.example.org-5984/176495380910390373 | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/fixtures/replay/corpusdev.example.org-5984/176495380910390373 diff --git a/test/fixtures/replay/corpusdev.example.org-5984/176495380910390373 b/test/fixtures/replay/corpusdev.example.org-5984/176495380910390373 new file mode 100644 index 00000000..dbbdc0f4 --- /dev/null +++ b/test/fixtures/replay/corpusdev.example.org-5984/176495380910390373 @@ -0,0 +1,13 @@ +GET / +accept-encoding: gzip, deflate +accept: application/json + +HTTP/1.1 200 OK +cache-control: must-revalidate +connection: close +content-length: 127 +content-type: application/json +date: Fri, 05 Dec 2025 16:56:48 GMT +server: nginx/1.10.3 + +{"couchdb":"Welcome","uuid":"0f659d1403b43877255f55b51149508f","version":"1.6.1","vendor":{"name":"Ubuntu","version":"16.04"}} \ No newline at end of file From 0b9fe129807204292ad5e981127fc60a4b490e3a Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 12:22:37 -0500 Subject: [PATCH 07/18] debug replay couch version --- test/routes/deprecated-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/routes/deprecated-spec.js b/test/routes/deprecated-spec.js index 0230b705..c9cb29c3 100644 --- a/test/routes/deprecated-spec.js +++ b/test/routes/deprecated-spec.js @@ -102,7 +102,7 @@ describe('/ deprecated', () => { authentication_handlers: couchDBInfo.version = '1.6.1' ? ['oauth', 'cookie', 'default'] : ['cookie', 'default'], authenticated: 'default', }, - }, 'should have roles'); + }, 'should have roles ' + JSON.stringify(res.body)); expect(res.status).to.equal(200, JSON.stringify(res.body)); return supertest(`http://${testUsername}:test@localhost:5984`) From ad39f9a6c1aecca18c312646f838f1d47e3da652 Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 12:24:36 -0500 Subject: [PATCH 08/18] fix lint --- test/routes/deprecated-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/routes/deprecated-spec.js b/test/routes/deprecated-spec.js index c9cb29c3..cd6bee79 100644 --- a/test/routes/deprecated-spec.js +++ b/test/routes/deprecated-spec.js @@ -102,7 +102,7 @@ describe('/ deprecated', () => { authentication_handlers: couchDBInfo.version = '1.6.1' ? ['oauth', 'cookie', 'default'] : ['cookie', 'default'], authenticated: 'default', }, - }, 'should have roles ' + JSON.stringify(res.body)); + }, `should have roles ${JSON.stringify(res.body)}`); expect(res.status).to.equal(200, JSON.stringify(res.body)); return supertest(`http://${testUsername}:test@localhost:5984`) From e1b8bdec718d924c6006b3b6fd222122704105ae Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 13:31:22 -0500 Subject: [PATCH 09/18] 1.6.1 doesnt have thse --- test/routes/deprecated-spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/routes/deprecated-spec.js b/test/routes/deprecated-spec.js index cd6bee79..0108abc9 100644 --- a/test/routes/deprecated-spec.js +++ b/test/routes/deprecated-spec.js @@ -99,10 +99,10 @@ describe('/ deprecated', () => { }, info: { authentication_db: couchDBInfo.version = '1.6.1' ? '_users' : undefined, - authentication_handlers: couchDBInfo.version = '1.6.1' ? ['oauth', 'cookie', 'default'] : ['cookie', 'default'], + authentication_handlers: ['cookie', 'default'], authenticated: 'default', }, - }, `should have roles ${JSON.stringify(res.body)}`); + }, `should have roles ${JSON.stringify(couchDBInfo)}`); expect(res.status).to.equal(200, JSON.stringify(res.body)); return supertest(`http://${testUsername}:test@localhost:5984`) From 217e7ac95620ce5fd96a9839e1877eb7ecc3231b Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 13:35:45 -0500 Subject: [PATCH 10/18] debug couch info --- test/routes/deprecated-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/routes/deprecated-spec.js b/test/routes/deprecated-spec.js index 0108abc9..a0d02ce1 100644 --- a/test/routes/deprecated-spec.js +++ b/test/routes/deprecated-spec.js @@ -99,7 +99,7 @@ describe('/ deprecated', () => { }, info: { authentication_db: couchDBInfo.version = '1.6.1' ? '_users' : undefined, - authentication_handlers: ['cookie', 'default'], + authentication_handlers: couchDBInfo.version = '1.6.1' ? ['oauth', 'cookie', 'default'] : ['cookie', 'default'], authenticated: 'default', }, }, `should have roles ${JSON.stringify(couchDBInfo)}`); From 724ade01361ef5a17273bd02691196ee7fb20a81 Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 13:42:31 -0500 Subject: [PATCH 11/18] use server header to know which version of couch it is --- test/routes/deprecated-spec.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/routes/deprecated-spec.js b/test/routes/deprecated-spec.js index a0d02ce1..a15c4a7f 100644 --- a/test/routes/deprecated-spec.js +++ b/test/routes/deprecated-spec.js @@ -59,6 +59,7 @@ describe('/ deprecated', () => { email: 'testuser@lingsync.org', }) .then((res) => { + expect(res.body.user).not.to.equal(undefined, JSON.stringify(res.body)); expect(res.body.user.username).to.equal(testUsername, JSON.stringify(res.body)); expect(res.body.user.appbrand).to.equal('georgiantogether'); expect(res.body.user.prefs).to.deep.equal({ @@ -98,11 +99,11 @@ describe('/ deprecated', () => { ], }, info: { - authentication_db: couchDBInfo.version = '1.6.1' ? '_users' : undefined, - authentication_handlers: couchDBInfo.version = '1.6.1' ? ['oauth', 'cookie', 'default'] : ['cookie', 'default'], + authentication_db: res.headers.server.includes('CouchDB/1.') ? '_users' : undefined, + authentication_handlers: res.headers.server.includes('CouchDB/1.') ? ['oauth', 'cookie', 'default'] : ['cookie', 'default'], authenticated: 'default', }, - }, `should have roles ${JSON.stringify(couchDBInfo)}`); + }, `should have roles ${JSON.stringify(res.headers)}`); expect(res.status).to.equal(200, JSON.stringify(res.body)); return supertest(`http://${testUsername}:test@localhost:5984`) From 11a7c4a72f3abeaba290ba281904d840d4ef9114 Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 14:09:30 -0500 Subject: [PATCH 12/18] seperate expectations due to couchdb version --- test/routes/deprecated-spec.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/routes/deprecated-spec.js b/test/routes/deprecated-spec.js index a15c4a7f..c01c29c3 100644 --- a/test/routes/deprecated-spec.js +++ b/test/routes/deprecated-spec.js @@ -99,12 +99,13 @@ describe('/ deprecated', () => { ], }, info: { - authentication_db: res.headers.server.includes('CouchDB/1.') ? '_users' : undefined, - authentication_handlers: res.headers.server.includes('CouchDB/1.') ? ['oauth', 'cookie', 'default'] : ['cookie', 'default'], + authentication_db: res.body.info.authentication_db, + authentication_handlers: res.body.info.authentication_handlers, authenticated: 'default', }, - }, `should have roles ${JSON.stringify(res.headers)}`); + }, JSON.stringify(res.body)); expect(res.status).to.equal(200, JSON.stringify(res.body)); + expect(res.body.info.authentication_handlers).to.deep.equal(res.headers.server.includes('CouchDB/1.') ? ['oauth', 'cookie', 'default'] : ['cookie', 'default'], JSON.stringify(res.headers)); return supertest(`http://${testUsername}:test@localhost:5984`) .get(`/${testUsername}-activity_feed/_design/activities/_view/activities`) From 9a1943cdbb3f20af5d899b9aee9ede1e98e0acaa Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 14:19:38 -0500 Subject: [PATCH 13/18] move info into its own object --- test/routes/deprecated-spec.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/routes/deprecated-spec.js b/test/routes/deprecated-spec.js index c01c29c3..115a5b7c 100644 --- a/test/routes/deprecated-spec.js +++ b/test/routes/deprecated-spec.js @@ -84,6 +84,14 @@ describe('/ deprecated', () => { .set('Accept', 'application/json'); }) .then((res) => { + const expectedInfo = res.headers.server.includes('CouchDB/1.') ? { + authentication_db: '_users', + authentication_handlers: ['oauth', 'cookie', 'default'], + authenticated: 'default', + } : { + authentication_handlers: ['cookie', 'default'], + authenticated: 'default', + }; expect(res.body).to.deep.equal({ ok: true, userCtx: { @@ -98,14 +106,9 @@ describe('/ deprecated', () => { `${testUsername}-kartuli_writer`, ], }, - info: { - authentication_db: res.body.info.authentication_db, - authentication_handlers: res.body.info.authentication_handlers, - authenticated: 'default', - }, - }, JSON.stringify(res.body)); + info: expectedInfo, + }, `should have roles ${JSON.stringify(res.headers)}`); expect(res.status).to.equal(200, JSON.stringify(res.body)); - expect(res.body.info.authentication_handlers).to.deep.equal(res.headers.server.includes('CouchDB/1.') ? ['oauth', 'cookie', 'default'] : ['cookie', 'default'], JSON.stringify(res.headers)); return supertest(`http://${testUsername}:test@localhost:5984`) .get(`/${testUsername}-activity_feed/_design/activities/_view/activities`) From 05ff00f9c268193f3438adeec438dca4ee24bb7d Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 15:18:38 -0500 Subject: [PATCH 14/18] corpus creation is eventualy consistant --- package.json | 2 +- test/integration/install.js | 4 ++++ test/routes/deprecated-spec.js | 26 +++++++++++++++----------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 5661e50d..d5b9e906 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "lint:ci": "eslint .", "setup": "REPLAY=bloody SOURCE_URL=${SOURCE_URL:-https://public:none@corpusdev.example.org} mocha --timeout 20000 test/integration/install.js", "start": "node ./bin/www.js", - "test": "rm db/*test.sqlite; SOURCE_URL=${SOURCE_URL:-https://public:none@corpusdev.example.org} NODE_ENV=test NODE_TLS_REJECT_UNAUTHORIZED=0 mocha --timeout 10000 --recursive test", + "test": "rm db/*test.sqlite; 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 mocha --timeout 15000 test/routes/deprecated-spec.js", "test:fielddb": "NODE_ENV=localhost jasmine-node node_modules/fielddb/tests", diff --git a/test/integration/install.js b/test/integration/install.js index 88b6d31d..03612470 100644 --- a/test/integration/install.js +++ b/test/integration/install.js @@ -29,6 +29,10 @@ describe('install', () => { if (REPLAY === 'bloody' && source.includes('example.org')) { throw new Error('SOURCE_URL is not set to a valid test CouchDB instance. Please export SOURCE_URL=http://public:none@thecouchinstance.org'); } + + if (REPLAY === 'bloody' && destination.includes('sync.org')) { + throw new Error('The destination is not set to a valid test CouchDB instance. Please edit config.local to use a db such as http://public:none@localhost:5984'); + } // eslint-disable-next-line no-underscore-dangle replay._localhosts = new Set(); // eslint-disable-next-line no-underscore-dangle diff --git a/test/routes/deprecated-spec.js b/test/routes/deprecated-spec.js index 115a5b7c..09790b3c 100644 --- a/test/routes/deprecated-spec.js +++ b/test/routes/deprecated-spec.js @@ -1535,21 +1535,24 @@ describe('/ deprecated', () => { .post('/register') .set('x-request-id', `${requestId}-prep-syncDetails`) .send({ - username: 'testuser8', + username: testUsername, password: 'test', }) .then((res) => { - debug('register testuser8', res.body); + debug(`register ${testUsername}`, res.body); }); }); - it('should try to create all corpora listed in the user', () => supertest(authWebService) - .post('/login') - .set('x-request-id', `${requestId}-syncDetails`) - .send({ - username: testUsername, - password: 'test', + it('should try to create all corpora listed in the user', async function () { + // The corpus creation can be delayed and finish after the request to login finishes + this.retries(3); + return supertest(authWebService) + .post('/login') + .set('x-request-id', `${requestId}-syncDetails`) + .send({ + username: testUsername, + password: 'test', syncDetails: true, syncUserDetails: { newCorpusConnections: [{ @@ -1584,11 +1587,12 @@ describe('/ deprecated', () => { }) .then((res) => { if (res.status === 200) { - expect(res.body.total_rows).to.equal(1); + expect(res.body.total_rows).to.equal(1, JSON.stringify(res.body)); } else { debug('syncDetails', JSON.stringify(res.body)); - expect(res.status).to.be.oneOf([401, 404]); // delay in views creation on new resources + expect(res.status).to.be.oneOf([401, 404], JSON.stringify(res.body)); // delay in views creation on new resources } - })); + }); + }); }); }); From 81457a2f23a02bc686796d6e00666adc2106fb43 Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 15:25:26 -0500 Subject: [PATCH 15/18] delay is due to the index not being ready yet --- test/routes/deprecated-spec.js | 79 +++++++++++++++++----------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/test/routes/deprecated-spec.js b/test/routes/deprecated-spec.js index 09790b3c..9327afca 100644 --- a/test/routes/deprecated-spec.js +++ b/test/routes/deprecated-spec.js @@ -1553,46 +1553,47 @@ describe('/ deprecated', () => { .send({ username: testUsername, password: 'test', - syncDetails: true, - syncUserDetails: { - newCorpusConnections: [{ - dbname: `${testUsername}-firstcorpus`, - }, {}, { - dbname: 'someoneelsesdb-shouldnt_be_creatable', - }, { - dbname: `${testUsername}-an_offline_corpus_created_in_the_prototype${uniqueDBname}`, - }, { - dbname: `${testUsername}-firstcorpus`, - }], - }, - }) - .then((res) => { - expect(res.body.user && res.body.user.corpora && res.body.user.corpora.length >= 1) - .to.equal(true, JSON.stringify(res.body)); - expect(res.body.user.newCorpora && res.body.user.newCorpora.length) - .above(2, JSON.stringify(res.body.user.newCorpora)); - - return supertest(`http://${testUsername}:test@localhost:5984`) - .get('/someoneelsesdb-shouldnt_be_creatable') - .set('x-request-id', `${requestId}-syncDetails-after`) - .set('Accept', 'application/json'); - }) - .then((res) => { - expect(res.status).to.equal(404); + syncDetails: true, + syncUserDetails: { + newCorpusConnections: [{ + dbname: `${testUsername}-firstcorpus`, + }, {}, { + dbname: 'someoneelsesdb-shouldnt_be_creatable', + }, { + dbname: `${testUsername}-an_offline_corpus_created_in_the_prototype${uniqueDBname}`, + }, { + dbname: `${testUsername}-firstcorpus`, + }], + }, + }) + .then((res) => { + expect(res.body.user && res.body.user.corpora && res.body.user.corpora.length >= 1) + .to.equal(true, JSON.stringify(res.body)); + expect(res.body.user.newCorpora && res.body.user.newCorpora.length) + .above(2, JSON.stringify(res.body.user.newCorpora)); - return supertest(`http://${testUsername}:test@localhost:5984`) - .get(`/${testUsername}-an_offline_corpus_created_in_the_prototype${uniqueDBname}/_design/deprecated/_view/corpora`) - .set('x-request-id', `${requestId}-syncDetails`) - .set('Accept', 'application/json'); - }) - .then((res) => { - if (res.status === 200) { - expect(res.body.total_rows).to.equal(1, JSON.stringify(res.body)); - } else { - debug('syncDetails', JSON.stringify(res.body)); - expect(res.status).to.be.oneOf([401, 404], JSON.stringify(res.body)); // delay in views creation on new resources - } - }); + return supertest(`http://${testUsername}:test@localhost:5984`) + .get('/someoneelsesdb-shouldnt_be_creatable') + .set('x-request-id', `${requestId}-syncDetails-after`) + .set('Accept', 'application/json'); + }) + .then((res) => { + expect(res.status).to.equal(404); + + return supertest(`http://${testUsername}:test@localhost:5984`) + .get(`/${testUsername}-an_offline_corpus_created_in_the_prototype${uniqueDBname}/_design/deprecated/_view/corpora`) + .set('x-request-id', `${requestId}-syncDetails`) + .set('Accept', 'application/json'); + }) + .then((res) => { + if (res.status === 200) { + expect(res.body.total_rows).to.equal(1, JSON.stringify(res.body)); + } else { + debug('syncDetails', JSON.stringify(res.body)); + // delay in views creation on new resources + expect(res.status).to.be.oneOf([401, 404], JSON.stringify(res.body)); + } + }); }); }); }); From fee9c88365e43d36886221abcdc1afa9ca5463f9 Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 15:35:23 -0500 Subject: [PATCH 16/18] debug 401 --- test/integration/install.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/integration/install.js b/test/integration/install.js index 03612470..1c15e1c9 100644 --- a/test/integration/install.js +++ b/test/integration/install.js @@ -46,7 +46,8 @@ describe('install', () => { password: 'none', }) .then((res) => { - expect(res.status).to.equal(200); + expect(res.status).to.be.oneOf([401, 200], JSON.stringify(res.body)); + const setCookie = res.headers['set-cookie'].length === 1 ? res.headers['set-cookie'][0] : res.headers['set-cookie']; [adminSessionCookie] = setCookie.split(';'); debug('adminSessionCookie', adminSessionCookie); From ea2fa48ac15b9f3a710865ff1de6a952094fdde4 Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 15:38:23 -0500 Subject: [PATCH 17/18] expect the user exists --- test/integration/install.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/install.js b/test/integration/install.js index 1c15e1c9..7ecb18a4 100644 --- a/test/integration/install.js +++ b/test/integration/install.js @@ -46,7 +46,7 @@ describe('install', () => { password: 'none', }) .then((res) => { - expect(res.status).to.be.oneOf([401, 200], JSON.stringify(res.body)); + expect(res.status).to.equal(200, JSON.stringify(res.body)); const setCookie = res.headers['set-cookie'].length === 1 ? res.headers['set-cookie'][0] : res.headers['set-cookie']; [adminSessionCookie] = setCookie.split(';'); From 7f0bf648f59bcd0121fb0f44cdfeb12bb3373b09 Mon Sep 17 00:00:00 2001 From: cesine Date: Fri, 5 Dec 2025 15:47:55 -0500 Subject: [PATCH 18/18] increase timeout --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d5b9e906..5b1d7c9b 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "start": "node ./bin/www.js", "test": "rm db/*test.sqlite; 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 mocha --timeout 15000 test/routes/deprecated-spec.js", + "test:deprecated": "DEBUG=${DEBUG:-lib:user} REPLAY=bloody 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"