diff --git a/config.frontend.test.yaml b/config.frontend.test.yaml index 649cc478c..126672376 100644 --- a/config.frontend.test.yaml +++ b/config.frontend.test.yaml @@ -12,10 +12,7 @@ default_project: &default_project grace_ttl: 1000000 php_host: https://en.wikipedia.beta.wmflabs.org/w/rest.php proxy: - default_variant: js - mode: split - pattern: - - en.wikipedia.beta.wmflabs.org + default_variant: php action: apiUriTemplate: "{{'https://{domain}/w/api.php'}}" baseUriTemplate: "{{'https://{domain}/api/rest_v1'}}" @@ -184,42 +181,28 @@ spec_root: &spec_root forward_headers: true - pattern: /^https?:\/\// paths: - /{domain:test.wikipedia.org}: *wikipedia_project + /{domain:commons.wikimedia.beta.wmflabs.org}: *commons_project # The order is important for tests. # Redirect tests require en.wiki being not the first wiki in the list. - /{domain:en.wikipedia.org}: *wikipedia_project - /{domain:ru.wikipedia.org}: *wikipedia_project - /{domain:de.wikipedia.org}: *wikipedia_project - /{domain:test2.wikipedia.org}: *wikipedia_project - /{domain:commons.wikimedia.org}: *commons_project - /{domain:www.wikidata.org}: *wikidata_project - - # labs, used for most tests /{domain:en.wikipedia.beta.wmflabs.org}: *wikipedia_project - /{domain:commons.wikimedia.beta.wmflabs.org}: *commons_project + /{domain:de.wikipedia.beta.wmflabs.org}: *wikipedia_project /{domain:wikidata.beta.wmflabs.org}: *wikidata_project - # Serbian wiki in beta for language variants tests /{domain:sr.wikipedia.beta.wmflabs.org}: *wikipedia_project - - # For security testing we rely on mocks, so it's OK to use French wiki. - /{domain:fr.wikipedia.org}: + # For security testing we rely on mocks, so it's OK to use Russian wiki. + /{domain:ru.wikipedia.beta.wmflabs.org}: <<: *wikipedia_project x-route-filters: - path: ./lib/mediawiki_auth_filter.js options: permissions: - read - # global domain /{domain:wikimedia.org}: *wikimedia_project - # Wiktionary has some specific endpoints - /{domain:en.wiktionary.org}: *wiktionary_project - + /{domain:en.wiktionary.beta.wmflabs.org}: *wiktionary_project # Fake domain to run tests relying on test_module - /{domain:fake.wikipedia.org}: *testing_project - + /{domain:fake.fakepedia.org}: *testing_project # Finally, a standard service-runner config. info: diff --git a/config.fullstack.test.yaml b/config.fullstack.test.yaml index 894834ac8..0bd9b6542 100644 --- a/config.fullstack.test.yaml +++ b/config.fullstack.test.yaml @@ -11,10 +11,7 @@ default_project: &default_project grace_ttl: 1000000 php_host: https://en.wikipedia.beta.wmflabs.org/w/rest.php proxy: - default_variant: js - mode: split - pattern: - - en.wikipedia.beta.wmflabs.org + default_variant: php action: apiUriTemplate: "{{'https://{domain}/w/api.php'}}" baseUriTemplate: "{{'https://{domain}/api/rest_v1'}}" @@ -220,41 +217,28 @@ spec_root: &spec_root forward_headers: true - pattern: /^https?:\/\// paths: - /{domain:test.wikipedia.org}: *wikipedia_project + /{domain:commons.wikimedia.beta.wmflabs.org}: *commons_project # The order is important for tests. # Redirect tests require en.wiki being not the first wiki in the list. - /{domain:en.wikipedia.org}: *wikipedia_project - /{domain:ru.wikipedia.org}: *wikipedia_project - /{domain:de.wikipedia.org}: *wikipedia_project - /{domain:test2.wikipedia.org}: *wikipedia_project - /{domain:commons.wikimedia.org}: *commons_project - /{domain:www.wikidata.org}: *wikidata_project - - # labs, used for most tests /{domain:en.wikipedia.beta.wmflabs.org}: *wikipedia_project - /{domain:commons.wikimedia.beta.wmflabs.org}: *commons_project + /{domain:de.wikipedia.beta.wmflabs.org}: *wikipedia_project /{domain:wikidata.beta.wmflabs.org}: *wikidata_project - # Serbian wiki in beta for language variants tests /{domain:sr.wikipedia.beta.wmflabs.org}: *wikipedia_project - - # For security testing we rely on mocks, so it's OK to use French wiki. - /{domain:fr.wikipedia.org}: + # For security testing we rely on mocks, so it's OK to use Russian wiki. + /{domain:ru.wikipedia.beta.wmflabs.org}: <<: *wikipedia_project x-route-filters: - path: ./lib/mediawiki_auth_filter.js options: permissions: - read - # global domain /{domain:wikimedia.org}: *wikimedia_project - # Wiktionary has some specific endpoints - /{domain:en.wiktionary.org}: *wiktionary_project - + /{domain:en.wiktionary.beta.wmflabs.org}: *wiktionary_project # Fake domain to run tests relying on test_module - /{domain:fake.wikipedia.org}: *testing_project + /{domain:fake.fakepedia.org}: *testing_project # Finally, a standard service-runner config. info: diff --git a/lib/parsoid.js b/lib/parsoid.js index ce32b728f..1942cfed6 100644 --- a/lib/parsoid.js +++ b/lib/parsoid.js @@ -708,7 +708,7 @@ class ParsoidService { if (rp.revision) { path += `/${rp.revision}`; } - return hyper.post(this._getParsoidReq(req, path, {})); + return hyper.post(this._getParsoidReq(req, path, {}, {})); } makeTransform(from, to) { diff --git a/test/features/events/events.js b/test/features/events/events.js index 50ca2bccb..0f8304705 100644 --- a/test/features/events/events.js +++ b/test/features/events/events.js @@ -14,9 +14,9 @@ describe('Change event emitting', () => { it('should not explode if events config is not provided', () => { return preq.post({ - uri: `${server.config.baseURL('fake.wikipedia.org')}/events_no_config/`, + uri: `${server.config.baseURL('fake.fakepedia.org')}/events_no_config/`, body: [ - { uri: '//fake.wikipedia.org' } + { uri: '//fake.fakepedia.org' } ] }); }); @@ -34,7 +34,7 @@ describe('Change event emitting', () => { const events = JSON.parse(postData.toString()); assert.deepEqual(events.length, 1); const event = events[0]; - assert.deepEqual(event.meta.domain, 'fake.wikipedia.org'); + assert.deepEqual(event.meta.domain, 'fake.fakepedia.org'); assert.deepEqual(!!new Date(event.meta.dt), true); assert.deepEqual(uuidUtils.test(event.meta.id), true); assert.deepEqual(uuidUtils.test(event.meta.request_id), true); @@ -71,11 +71,11 @@ describe('Change event emitting', () => { eventLogging = createEventLogging(really_done, { stream: 'resource_change', - uri: 'http://fake.wikipedia.org/wiki/User:Pchelolo' + uri: 'http://fake.fakepedia.org/wiki/User:Pchelolo' }); preq.post({ - uri: `${server.config.baseURL('fake.wikipedia.org')}/events/`, + uri: `${server.config.baseURL('fake.fakepedia.org')}/events/`, headers: { 'content-type': 'application/json', connection: 'close', @@ -83,7 +83,7 @@ describe('Change event emitting', () => { body: [ { meta: { - uri: '//fake.wikipedia.org/wiki/User:Pchelolo' + uri: '//fake.fakepedia.org/wiki/User:Pchelolo' }, tags: ['test'] }, @@ -110,21 +110,21 @@ describe('Change event emitting', () => { eventLogging = createEventLogging(really_done, { stream: 'change-prop.transcludes.resource-change', - uri: 'http://fake.wikipedia.org/api/rest_v1/page/html/User:Pchelolo', - trigger: 'mediawiki.revision-create:https://en.wikimedia.org/wiki/Template:One,change-prop.transcludes.resource-change:https://fake.wikipedia.org/wiki/User:Pchelolo' + uri: 'http://fake.fakepedia.org/api/rest_v1/page/html/User:Pchelolo', + trigger: 'mediawiki.revision-create:https://en.wikimedia.org/wiki/Template:One,change-prop.transcludes.resource-change:https://fake.fakepedia.org/wiki/User:Pchelolo' }); preq.post({ - uri: `${server.config.baseURL('fake.wikipedia.org')}/events/`, + uri: `${server.config.baseURL('fake.fakepedia.org')}/events/`, headers: { 'content-type': 'application/json', connection: 'close', - 'x-triggered-by': 'mediawiki.revision-create:https://en.wikimedia.org/wiki/Template:One,change-prop.transcludes.resource-change:https://fake.wikipedia.org/wiki/User:Pchelolo' + 'x-triggered-by': 'mediawiki.revision-create:https://en.wikimedia.org/wiki/Template:One,change-prop.transcludes.resource-change:https://fake.fakepedia.org/wiki/User:Pchelolo' }, body: [ { meta: { - uri: '//fake.wikipedia.org/api/rest_v1/page/html/User:Pchelolo' + uri: '//fake.fakepedia.org/api/rest_v1/page/html/User:Pchelolo' }, tags: ['test'] } @@ -149,26 +149,26 @@ describe('Change event emitting', () => { eventLogging = createEventLogging(really_done, { stream: 'resource_change', - uri: 'http://fake.wikipedia.org/wiki/User:Pchelolo', - trigger: 'resource_change:https://fake.wikipedia.org/wiki/Prohibited' + uri: 'http://fake.fakepedia.org/wiki/User:Pchelolo', + trigger: 'resource_change:https://fake.fakepedia.org/wiki/Prohibited' }); preq.post({ - uri: `${server.config.baseURL('fake.wikipedia.org')}/events/`, + uri: `${server.config.baseURL('fake.fakepedia.org')}/events/`, headers: { 'content-type': 'application/json', - 'x-triggered-by': 'resource_change:https://fake.wikipedia.org/wiki/Prohibited' + 'x-triggered-by': 'resource_change:https://fake.fakepedia.org/wiki/Prohibited' }, body: [ { meta: { - uri: '//fake.wikipedia.org/wiki/Prohibited' + uri: '//fake.fakepedia.org/wiki/Prohibited' }, tags: ['test'] }, { meta: { - uri: '//fake.wikipedia.org/wiki/User:Pchelolo' + uri: '//fake.fakepedia.org/wiki/User:Pchelolo' }, tags: ['test'] } diff --git a/test/features/feed.js b/test/features/feed.js index c6cc1f2a0..6ebc45f3b 100644 --- a/test/features/feed.js +++ b/test/features/feed.js @@ -4,28 +4,28 @@ const assert = require('../utils/assert.js'); const Server = require('../utils/server.js'); const preq = require('preq'); -function assertMCSRequest(content, date, expected) { - const serviceURI = 'https://wikifeeds.wmflabs.org'; - let path = `/en.wikipedia.org/v1/${content}`; - if (date) { - path += `/${date}`; - } - const serviceRequests = assert.findRequests(log => - log.scope.startsWith(serviceURI) && log.path.startsWith(path)); - if (expected) { - assert.deepEqual(serviceRequests.length > 0, true, - `Should have made request to service for ${content}`); - } else { - assert.deepEqual(serviceRequests.length === 0, true, - `Should NOT have made request to service for ${content}`); - } -} - describe('Featured feed', () => { const server = new Server(); before(() => server.start()); after(() => server.stop()); + function assertMCSRequest(content, date, expected) { + const serviceURI = 'https://wikifeeds.wmflabs.org'; + let path = `/${server.config.defaultDomain}/v1/${content}`; + if (date) { + path += `/${date}`; + } + const serviceRequests = assert.findRequests(log => + log.scope.startsWith(serviceURI) && log.path.startsWith(path)); + if (expected) { + assert.deepEqual(serviceRequests.length > 0, true, + `Should have made request to service for ${content}`); + } else { + assert.deepEqual(serviceRequests.length === 0, true, + `Should NOT have made request to service for ${content}`); + } + } + it('Should render non-available historic content', () => { const date = '2016/10/01'; assert.recordRequests(); diff --git a/test/features/lists.js b/test/features/lists.js index b7c691ed9..9f10ae78b 100644 --- a/test/features/lists.js +++ b/test/features/lists.js @@ -528,54 +528,59 @@ describe('reading lists', function() { }); describe('GET /lists/{id}/entries/', () => { - const entries = [ - { - id: 10, - listId: 4, - project: 'en.wikipedia.org', - title: 'Foo Bar', - created: '2017-09-27T06:59:13Z', - updated: '2017-10-17T07:40:50Z', - }, - { - id: 11, - listId: 4, - project: 'en.wikipedia.org', - title: 'Boo(m)?', - created: '2017-09-27T06:59:13Z', - updated: '2017-10-17T07:40:50Z', - }, - ]; - const expectedEntries = [ - { - id: 10, - listId: 4, - project: 'en.wikipedia.org', - title: 'Foo Bar', - summary: { - title: 'Foo_Bar', - normalizedtitle: 'Foo Bar', - summaryData: '', + let entries; + let expectedEntries; + before(() => { + entries = [ + { + id: 10, + listId: 4, + project: server.config.defaultDomain, + title: 'Foo Bar', + created: '2017-09-27T06:59:13Z', + updated: '2017-10-17T07:40:50Z', }, - created: '2017-09-27T06:59:13Z', - updated: '2017-10-17T07:40:50Z', - }, - { - id: 11, - listId: 4, - project: 'en.wikipedia.org', - title: 'Boo(m)?', - summary: { + { + id: 11, + listId: 4, + project: server.config.defaultDomain, title: 'Boo(m)?', - normalizedtitle: 'Boo(m)?', - summaryData: '', + created: '2017-09-27T06:59:13Z', + updated: '2017-10-17T07:40:50Z', }, - created: '2017-09-27T06:59:13Z', - updated: '2017-10-17T07:40:50Z', - }, - ]; + ]; + expectedEntries = [ + { + id: 10, + listId: 4, + project: server.config.defaultDomain, + title: 'Foo Bar', + summary: { + title: 'Foo_Bar', + normalizedtitle: 'Foo Bar', + summaryData: '', + }, + created: '2017-09-27T06:59:13Z', + updated: '2017-10-17T07:40:50Z', + }, + { + id: 11, + listId: 4, + project: server.config.defaultDomain, + title: 'Boo(m)?', + summary: { + title: 'Boo(m)?', + normalizedtitle: 'Boo(m)?', + summaryData: '', + }, + created: '2017-09-27T06:59:13Z', + updated: '2017-10-17T07:40:50Z', + }, + ]; + }); + function getEnwikiMock() { - return nock('https://en.wikipedia.org', { + return nock(`https://${server.config.defaultDomain}`, { // FIXME should not send cookies to a different domain // badheaders: [ 'Cookie' ], }) @@ -751,7 +756,7 @@ describe('reading lists', function() { { id: 1, listId: 1, - project: 'de.wikipedia.org', + project: 'de.fakepedia.org', title: 'Barack Obama', created: '2017-09-27T06:59:13Z', updated: '2017-10-17T07:40:50Z', @@ -797,7 +802,7 @@ describe('reading lists', function() { action: 'readinglists', command: 'createentry', list: '3', - project: 'en.wikipedia.org', + project: server.config.defaultDomain, title: 'Barack Obama', token: csrfToken, format: 'json', @@ -815,7 +820,7 @@ describe('reading lists', function() { csrf_token: csrfToken, }, body: { - project: 'en.wikipedia.org', + project: server.config.defaultDomain, title: 'Barack Obama', }, headers: { @@ -865,11 +870,11 @@ describe('reading lists', function() { it('forward call', () => { const batchEntries = [ { - project: 'en.wikipedia.org', + project: server.config.defaultDomain, title: 'Foobar', }, { - project: 'en.wikipedia.org', + project: server.config.defaultDomain, title: 'Dog', }, ]; @@ -889,14 +894,14 @@ describe('reading lists', function() { entries: [ { id: 2, - project: 'en.wikipedia.org', + project: server.config.defaultDomain, title: 'Foobar', created: '2018-08-30T13:44:04.276Z', updated: '2018-08-30T13:44:04.276Z' }, { id: 3, - project: 'en.wikipedia.org', + project: server.config.defaultDomain, title: 'Dog', created: '2018-08-30T13:44:04.276Z', updated: '2018-08-30T13:44:04.276Z' @@ -933,14 +938,14 @@ describe('reading lists', function() { entries: [ { id: 2, - project: 'en.wikipedia.org', + project: server.config.defaultDomain, title: 'Foobar', created: '2018-08-30T13:44:04.276Z', updated: '2018-08-30T13:44:04.276Z' }, { id: 3, - project: 'en.wikipedia.org', + project: server.config.defaultDomain, title: 'Dog', created: '2018-08-30T13:44:04.276Z', updated: '2018-08-30T13:44:04.276Z' @@ -984,7 +989,7 @@ describe('reading lists', function() { .post(server.config.apiPath, nockDiff({ action: 'query', meta: 'readinglists', - rlproject: 'en.wikipedia.org', + rlproject: server.config.defaultDomain, rltitle: 'Foo_Bar', rllimit: 'max', format: 'json', @@ -997,7 +1002,7 @@ describe('reading lists', function() { }); return preq.get({ - uri: `${server.config.baseURL()}/data/lists/pages/en.wikipedia.org/Foo%20Bar`, + uri: `${server.config.baseURL()}/data/lists/pages/${server.config.defaultDomain}/Foo%20Bar`, headers: { 'Cookie': sessionCookies, }, @@ -1016,7 +1021,7 @@ describe('reading lists', function() { .post(server.config.apiPath, nockDiff({ action: 'query', meta: 'readinglists', - rlproject: 'en.wikipedia.org', + rlproject: server.config.defaultDomain, rltitle: 'Foo_Bar', rllimit: 'max', format: 'json', @@ -1033,7 +1038,7 @@ describe('reading lists', function() { }); return preq.get({ - uri: `${server.config.baseURL()}/data/lists/pages/en.wikipedia.org/Foo%20Bar`, + uri: `${server.config.baseURL()}/data/lists/pages/${server.config.defaultDomain}/Foo%20Bar`, headers: { 'Cookie': sessionCookies, }, @@ -1053,7 +1058,7 @@ describe('reading lists', function() { .post(server.config.apiPath, nockDiff({ action: 'query', meta: 'readinglists', - rlproject: 'en.wikipedia.org', + rlproject: server.config.defaultDomain, rltitle: 'Foo_Bar', rllimit: 'max', rlcontinue: 1, @@ -1068,7 +1073,7 @@ describe('reading lists', function() { }); return preq.get({ - uri: `${server.config.baseURL()}/data/lists/pages/en.wikipedia.org/Foo%20Bar`, + uri: `${server.config.baseURL()}/data/lists/pages/${server.config.defaultDomain}/Foo%20Bar`, query: { next: '{"rlcontinue":1,"continue":"-||"}', }, @@ -1087,51 +1092,55 @@ describe('reading lists', function() { }); describe('GET /lists/changes/since/{date}', () => { - const lists = [ - { - id: 1, - name: 'default', - default: true, - description: '', - color: '', - image: '', - icon: '', - created: '2017-09-27T06:59:13Z', - updated: '2017-10-17T07:40:50Z', - order: [ 1, 2 ], - listOrder: [ 1, 2 ], - }, - { - id: 2, - name: 'deleted', - description: '', - color: '', - image: '', - icon: '', - created: '2017-09-27T06:59:13Z', - updated: '2017-10-17T07:40:50Z', - deleted: true, - }, - ]; - const entries = [ - { - id: 1, - listId: 1, - project: 'en.wikipedia.org', - title: 'Foo Bar', - created: '2017-09-27T06:59:13Z', - updated: '2017-10-17T07:40:50Z', - }, - { - id: 2, - listId: 1, - project: 'en.wikipedia.org', - title: 'Boom Baz', - created: '2017-09-27T06:59:13Z', - updated: '2017-10-17T07:40:50Z', - deleted: true, - }, - ]; + let lists; + let entries; + before(() => { + lists = [ + { + id: 1, + name: 'default', + default: true, + description: '', + color: '', + image: '', + icon: '', + created: '2017-09-27T06:59:13Z', + updated: '2017-10-17T07:40:50Z', + order: [ 1, 2 ], + listOrder: [ 1, 2 ], + }, + { + id: 2, + name: 'deleted', + description: '', + color: '', + image: '', + icon: '', + created: '2017-09-27T06:59:13Z', + updated: '2017-10-17T07:40:50Z', + deleted: true, + }, + ]; + entries = [ + { + id: 1, + listId: 1, + project: server.config.defaultDomain, + title: 'Foo Bar', + created: '2017-09-27T06:59:13Z', + updated: '2017-10-17T07:40:50Z', + }, + { + id: 2, + listId: 1, + project: server.config.defaultDomain, + title: 'Boom Baz', + created: '2017-09-27T06:59:13Z', + updated: '2017-10-17T07:40:50Z', + deleted: true, + }, + ]; + }); it('forward call', () => { const scope = getApi() diff --git a/test/features/mobileapps.js b/test/features/mobileapps.js index 29c0d465b..d82945307 100644 --- a/test/features/mobileapps.js +++ b/test/features/mobileapps.js @@ -10,7 +10,7 @@ describe('Mobile Content Service', () => { after(() => server.stop()); const pageTitle = 'Foobar'; - const pageRev = 757550077; + const pageRev = 385014; it('Should fetch latest mobile-sections', () => { return preq.get({ diff --git a/test/features/pagecontent/access_checks.js b/test/features/pagecontent/access_checks.js index 85fb9c8cb..a1cbdf0d9 100644 --- a/test/features/pagecontent/access_checks.js +++ b/test/features/pagecontent/access_checks.js @@ -6,16 +6,16 @@ const assert = require('../../utils/assert.js'); const preq = require('preq'); const Server = require('../../utils/server.js'); const nock = require('nock'); -const P = require('bluebird'); +// TODO: add support for nocked tests const NOCK_TESTS = false; // because of Parsoid/PHP which uses the same URI structure as the MW API describe('Access checks', () => { const server = new Server(); const deletedPageTitle = 'User:Pchelolo/Access_Check_Tests'; - const deletedPageOlderRevision = 705347919; - const deletedPageRevision = 705347950; + const deletedPageOlderRevision = 409433; + const deletedPageRevision = 409434; const emptyResponse = { 'batchcomplete': '', 'query': { 'badrevids': { '292466': { 'revid': '292466' } } } }; function setUpNockResponse(api, title, revision) { @@ -57,20 +57,12 @@ describe('Access checks', () => { } return server.start() // Do a preparation request to force siteinfo fetch so that we don't need to mock it - .then(() => P.join( - preq.get({ - uri: `${server.config.bucketURL()}/html/Main_Page`, - headers: { - 'cache-control': 'no-cache' - } - }), - preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/Main_Page`, - headers: { - 'cache-control': 'no-cache' - } - }) - )) + .then(() => preq.get({ + uri: `${server.config.bucketURL()}/html/Main_Page`, + headers: { + 'cache-control': 'no-cache' + } + })) // Load in the revisions .then(() => { let api = nock(server.config.apiURL()); @@ -92,7 +84,7 @@ describe('Access checks', () => { }); }) .then(res => assert.deepEqual(res.status, 200)) - .then(res => api.done()) + .then(() => api.done()) .finally(() => nock.cleanAll()); }); }); diff --git a/test/features/pagecontent/content_negotiation.js b/test/features/pagecontent/content_negotiation.js index a7ce32f20..bbb1096a1 100644 --- a/test/features/pagecontent/content_negotiation.js +++ b/test/features/pagecontent/content_negotiation.js @@ -20,7 +20,7 @@ describe.skip('Content negotiation', function() { function getFakePageVersion(pageName, version) { let parsoidNock; - return preq.get({uri: `${server.config.parsoidURI}/en.wikipedia.org/v3/page/pagebundle/${pageName}`}) + return preq.get({uri: `${server.config.parsoidURI}/${server.config.defaultDomain}/v3/page/pagebundle/${pageName}`}) .then((res) => { currentParsoidContentType = res.body.html.headers['content-type']; res.body.html.headers['content-type'] = res.body.html.headers['content-type'] diff --git a/test/features/pagecontent/pagecontent.js b/test/features/pagecontent/pagecontent.js index dacc0843b..9c3e6b451 100644 --- a/test/features/pagecontent/pagecontent.js +++ b/test/features/pagecontent/pagecontent.js @@ -4,7 +4,6 @@ const assert = require('../../utils/assert.js'); const preq = require('preq'); const Server = require('../../utils/server.js'); const P = require('bluebird'); -const mwUtils = require('../../../lib/mwUtil'); describe('item requests', function() { this.timeout(20000); @@ -18,11 +17,11 @@ describe('item requests', function() { })); after(() => server.stop()); - const deniedTitle = 'User talk:DivineAlpha%2FQ1 2015 discussions'; - const deniedRev = '645504917'; + const deniedTitle = 'User:Pchelolo/Restricted Revision'; + const deniedRev = '409440'; function contentURI(format) { - return [server.config.bucketURL(), format, deniedTitle, deniedRev].join('/'); + return [server.config.bucketURL(), format, encodeURIComponent(deniedTitle), deniedRev].join('/'); } const assertCORS = (res) => { assert.deepEqual(res.headers['access-control-allow-origin'], '*'); @@ -36,7 +35,7 @@ describe('item requests', function() { }; const createTest = (method) => { it(`should respond to ${method} request with CORS headers`, () => { - return preq[method]({ uri: `${server.config.bucketURL()}/html/Foobar/624484477` }) + return preq[method]({ uri: `${server.config.bucketURL()}/html/Foobar/385014` }) .then((res) => { assert.deepEqual(res.status, 200); assertCORS(res); @@ -55,13 +54,13 @@ describe('item requests', function() { it('should transparently create a new HTML revision for Main_Page', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/Main_Page`, + uri: `${server.config.bucketURL()}/html/Main_Page`, }) .then((res) => { assert.deepEqual(res.status, 200); assert.validateListHeader(res.headers.vary, { require: ['Accept'], disallow: [''] }); return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/Main_Page` + uri: `${server.config.bucketURL()}/html/Main_Page` }); }) .then((res) => { @@ -71,7 +70,7 @@ describe('item requests', function() { }); it('should transparently create a new HTML revision with id 252937', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/Foobar/252937`, + uri: `${server.config.bucketURL()}/html/Foobar/252937`, }) .then((res) => { assert.deepEqual(res.status, 200); @@ -80,7 +79,7 @@ describe('item requests', function() { }); it('should not allow to frontend cache HTML if requested a stash', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/Foobar?stash=true`, + uri: `${server.config.bucketURL()}/html/Foobar?stash=true`, }) .then((res) => { assert.deepEqual(res.status, 200); @@ -100,7 +99,7 @@ describe('item requests', function() { it('should request page lints. with revision', () => { return preq.get({ - uri: `${server.config.bucketURL()}/lint/User%3APchelolo%2FLintTest/830278619` + uri: `${server.config.bucketURL()}/lint/User%3APchelolo%2FLintTest/409437` }) .then((res) => { assert.deepEqual(res.status, 200); @@ -109,9 +108,9 @@ describe('item requests', function() { }); let rev2Etag; - it('should transparently create data-parsoid with id 252937, rev 2', () => { + it('should transparently create data-parsoid with id 383159, rev 2', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/Foobar/252937?stash=true` + uri: `${server.config.bucketURL()}/html/Foobar/383159?stash=true` }) .then((res) => { assert.deepEqual(res.status, 200); @@ -120,9 +119,9 @@ describe('item requests', function() { }); }); - it('should return data-parsoid just created with revision 252937, rev 2', () => { + it('should return data-parsoid just created with revision 383159, rev 2', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/data-parsoid/Foobar/${rev2Etag}` + uri: `${server.config.bucketURL()}/data-parsoid/Foobar/${rev2Etag}` }) .then((res) => { assert.deepEqual(res.status, 200); @@ -130,16 +129,16 @@ describe('item requests', function() { }); }); - it('should return HTML and data-parsoid just created by revision 241155', () => { + it('should return HTML and data-parsoid just created by revision 295771', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/Foobar/241155?stash=true` + uri: `${server.config.bucketURL()}/html/Foobar/295771?stash=true` }) .then((res) => { assert.deepEqual(res.status, 200); assert.contentType(res, contentTypes.html); assert.validateListHeader(res.headers.vary, { require: ['Accept'], disallow: [''] }); return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/data-parsoid/Foobar/${ + uri: `${server.config.bucketURL()}/data-parsoid/Foobar/${ res.headers.etag.replace(/^"(.*)"$/, '$1')}` }); }) @@ -151,7 +150,7 @@ describe('item requests', function() { it('should list APIs using the generic listing handler', () => { return preq.get({ - uri: `${server.config.hostPort}/en.wikipedia.org/` + uri: `${server.config.hostPort}/${server.config.defaultDomain}/` }) .then((res) => { assert.deepEqual(res.status, 200); @@ -231,9 +230,6 @@ describe('item requests', function() { if (!res.body.items || !res.body.items.length) { throw new Error("Empty listing result!"); } - if (!/^!/.test(res.body.items[0])) { - throw new Error("Expected the first titles to start with !"); - } pagingToken = res.body._links.next.href; }); }); diff --git a/test/features/pagecontent/redirects.js b/test/features/pagecontent/redirects.js index dd388aa87..f99c4635e 100644 --- a/test/features/pagecontent/redirects.js +++ b/test/features/pagecontent/redirects.js @@ -5,22 +5,25 @@ const assert = require('../../utils/assert.js'); const preq = require('preq'); const Server = require('../../utils/server.js'); +const FILE_PAGE = 'File:A.jpg'; + describe('redirects', () => { const server = new Server(); before(() => server.start()); after(() => server.stop()); describe('', () => { - it('should redirect to a normalized version of a title in wiktionary', () => { + // TODO: figure out what's wrong with this test + it.skip('should redirect to a normalized version of a title in wiktionary', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wiktionary.org')}/definition/weekend%20warrior`, + uri: `${server.config.bucketURL('en.wiktionary.beta.wmflabs.org')}/definition/barrel%20race`, followRedirect: false }) - .then((res) => { - assert.deepEqual(res.status, 301); - assert.deepEqual(res.headers.location, 'weekend_warrior'); - assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control'); - }); + .then((res) => { + assert.deepEqual(res.status, 301); + assert.deepEqual(res.headers.location, 'barrel_race'); + assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control'); + }); }); it('should redirect to a normalized version of a title', () => { @@ -62,33 +65,33 @@ describe('redirects', () => { it('should redirect to commons for missing file pages', () => { return preq.get({ - uri: `${server.config.bucketURL()}/html/File:ThinkingMan_Rodin.jpg`, + uri: `${server.config.bucketURL()}/html/${FILE_PAGE}`, followRedirect: false }) .then((res) => { assert.deepEqual(res.status, 302); assert.deepEqual(res.headers.location, - 'https://commons.wikimedia.org/api/rest_v1/page/html/File%3AThinkingMan_Rodin.jpg'); + `https://commons.wikimedia.beta.wmflabs.org/api/rest_v1/page/html/${encodeURIComponent(FILE_PAGE)}`); assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control'); }); }); it('should redirect to commons for missing file pages, dewiki', () => { return preq.get({ - uri: `${server.config.bucketURL('de.wikipedia.org')}/html/Datei:Name.jpg`, + uri: `${server.config.bucketURL('de.wikipedia.beta.wmflabs.org')}/html/Datei:A.jpg`, followRedirect: false }) .then((res) => { assert.deepEqual(res.status, 302); assert.deepEqual(res.headers.location, - 'https://commons.wikimedia.org/api/rest_v1/page/html/File%3AName.jpg'); + `https://commons.wikimedia.beta.wmflabs.org/api/rest_v1/page/html/${encodeURIComponent(FILE_PAGE)}`); assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control'); }); }); it('should not redirect to commons for missing file pages, redirect=false', () => { return preq.get({ - uri: `${server.config.bucketURL()}/html/File:ThinkingMan_Rodin.jpg?redirect=false` + uri: `${server.config.bucketURL()}/html/${FILE_PAGE}?redirect=false` }) .then(() => { throw new Error('Error should be thrown'); @@ -99,7 +102,7 @@ describe('redirects', () => { it('should not redirect to commons for missing file pages, no-cache', () => { return preq.get({ - uri: `${server.config.bucketURL()}/html/File:ThinkingMan_Rodin.jpg`, + uri: `${server.config.bucketURL()}/html/${FILE_PAGE}`, headers: { 'cache-control': 'no-cache' } @@ -113,7 +116,7 @@ describe('redirects', () => { it('should append ?redirect=false to self-redirecting pages', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/User:Pchelolo%2FSelf_Redirect`, + uri: `${server.config.bucketURL()}/html/User:Pchelolo%2FSelf_Redirect`, followRedirect: false }) .then((res) => { @@ -124,7 +127,7 @@ describe('redirects', () => { it('should not redirect if file is missing on commons', () => { return preq.get({ - uri: `${server.config.hostPort}/commons.wikimedia.org/v1/html/File:Some_File_That_Does_Not_Exist.jpg` + uri: `${server.config.hostPort}/commons.wikimedia.beta.wmflabs.org/v1/html/File:Some_File_That_Does_Not_Exist.jpg` }) .then(() => { throw new Error('Error should be thrown'); @@ -135,7 +138,7 @@ describe('redirects', () => { it('should result in 404 if + is normalized by MW API', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/User:Pchelolo%2FOnDemand+Test` + uri: `${server.config.bucketURL()}/html/User:Pchelolo%2FOnDemand+Test` }) .then(() => { throw new Error('Error should be thrown'); @@ -153,14 +156,14 @@ describe('redirects', () => { assert.deepEqual(res.status, 200); assert.deepEqual(res.headers.location, undefined); assert.deepEqual(res.headers['content-location'], - 'https://en.wikipedia.org/api/rest_v1/page/html/User%3APchelolo%2FRedirect_Test2?redirect=false'); + `https://${server.config.defaultDomain}/api/rest_v1/page/html/User%3APchelolo%2FRedirect_Test2?redirect=false`); assert.deepEqual(res.body.length > 0, true); }); }); it('should return 302 for redirect pages html and data-parsoid', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/User:Pchelolo%2fRedirect_Test`, + uri: `${server.config.bucketURL()}/html/User:Pchelolo%2fRedirect_Test`, followRedirect: false }) .then((res) => { @@ -171,7 +174,7 @@ describe('redirects', () => { assert.deepEqual(/Redirect Target/.test(res.body.toString()), false); const renderInfo = mwUtil.parseETag(res.headers.etag); return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/data-parsoid/User:Pchelolo%2fRedirect_Test/${renderInfo.rev}/${renderInfo.tid}`, + uri: `${server.config.bucketURL()}/data-parsoid/User:Pchelolo%2fRedirect_Test/${renderInfo.rev}/${renderInfo.tid}`, followRedirect: false }) .then((res) => { @@ -186,7 +189,7 @@ describe('redirects', () => { it('should return 302 for redirect pages html, entities', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/User:Pchelolo%2fRedirect_Test_Amp`, + uri: `${server.config.bucketURL()}/html/User:Pchelolo%2fRedirect_Test_Amp`, followRedirect: false }) .then((res) => { @@ -200,7 +203,7 @@ describe('redirects', () => { it('should return 302 for redirect pages html, hash', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/User:Pchelolo%2fRedirect_Test_Hash`, + uri: `${server.config.bucketURL()}/html/User:Pchelolo%2fRedirect_Test_Hash`, followRedirect: false }) .then((res) => { @@ -213,7 +216,7 @@ describe('redirects', () => { it('should return 200 for redirect pages html with redirect=no', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/User:Pchelolo%2fRedirect_Test?redirect=no`, + uri: `${server.config.bucketURL()}/html/User:Pchelolo%2fRedirect_Test?redirect=no`, followRedirect: false }) .then((res) => { @@ -226,7 +229,7 @@ describe('redirects', () => { it('should return 200 for redirect pages html with no-cache', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/User:Pchelolo%2fRedirect_Test`, + uri: `${server.config.bucketURL()}/html/User:Pchelolo%2fRedirect_Test`, headers: { 'cache-control': 'no-cache' }, @@ -242,7 +245,7 @@ describe('redirects', () => { it('should return 302 for redirect pages html with revision', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/User:Pchelolo%2fRedirect_Test/331630`, + uri: `${server.config.bucketURL()}/html/User:Pchelolo%2fRedirect_Test/331630`, followRedirect: false }) .then((res) => { @@ -256,7 +259,7 @@ describe('redirects', () => { it('should return 200 for redirect pages html with revision, redirect=no', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/User:Pchelolo%2fRedirect_Test/331630?redirect=no`, + uri: `${server.config.bucketURL()}/html/User:Pchelolo%2fRedirect_Test/331630?redirect=no`, followRedirect: false }) .then((res) => { @@ -269,7 +272,7 @@ describe('redirects', () => { it('should return 302 for redirect pages summary', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/summary/User:Pchelolo%2fRedirect_Test`, + uri: `${server.config.bucketURL()}/summary/User:Pchelolo%2fRedirect_Test`, followRedirect: false }) .then((res) => { @@ -282,7 +285,7 @@ describe('redirects', () => { it('should return 302 for redirect pages mobile-sections', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/mobile-sections/User:Pchelolo%2fRedirect_Test`, + uri: `${server.config.bucketURL()}/mobile-sections/User:Pchelolo%2fRedirect_Test`, followRedirect: false }) .then((res) => { @@ -295,7 +298,7 @@ describe('redirects', () => { it('should return 302 for redirect pages mobile-sections-lead', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/mobile-sections-lead/User:Pchelolo%2fRedirect_Test`, + uri: `${server.config.bucketURL()}/mobile-sections-lead/User:Pchelolo%2fRedirect_Test`, followRedirect: false }) .then((res) => { @@ -308,7 +311,7 @@ describe('redirects', () => { it('should return 302 for redirect pages mobile-sections-remaining', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/mobile-sections-remaining/User:Pchelolo%2fRedirect_Test`, + uri: `${server.config.bucketURL()}/mobile-sections-remaining/User:Pchelolo%2fRedirect_Test`, followRedirect: false }) .then((res) => { @@ -325,13 +328,13 @@ describe('redirects', () => { }) .then((res) => { assert.deepEqual(res.status, 200); - assert.deepEqual(res.headers['content-location'], 'https://en.wikipedia.org/api/rest_v1/page/html/Main_Page'); + assert.deepEqual(res.headers['content-location'], `https://${server.config.defaultDomain}/api/rest_v1/page/html/Main_Page`); }); }); it('should return 200 for redirect pages html, cross-origin', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/User:Pchelolo%2fRedirect_Test`, + uri: `${server.config.bucketURL()}/html/User:Pchelolo%2fRedirect_Test`, headers: { origin: 'test.com' }, @@ -340,7 +343,7 @@ describe('redirects', () => { .then((res) => { assert.deepEqual(res.status, 200); assert.deepEqual(res.headers['content-location'], - 'https://en.wikipedia.beta.wmflabs.org/api/rest_v1/page/html/User%3APchelolo%2FRedirect_Target_%25'); + `https://${server.config.defaultDomain}/api/rest_v1/page/html/User%3APchelolo%2FRedirect_Target_%25`); assert.deepEqual(res.headers['cache-control'], 'no-cache'); assert.deepEqual(res.body.length > 0, true); assert.deepEqual(/Redirect Target/.test(res.body.toString()), true); @@ -349,7 +352,7 @@ describe('redirects', () => { it('should return 200 for redirect pages html, cross-origin, with title normalization', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/User:Pchelolo%2fRedirect%20Test`, + uri: `${server.config.bucketURL()}/html/User:Pchelolo%2fRedirect%20Test`, headers: { origin: 'test.com' }, @@ -358,7 +361,7 @@ describe('redirects', () => { .then((res) => { assert.deepEqual(res.status, 200); assert.deepEqual(res.headers['content-location'], - 'https://en.wikipedia.beta.wmflabs.org/api/rest_v1/page/html/User%3APchelolo%2FRedirect_Target_%25'); + `https://${server.config.defaultDomain}/api/rest_v1/page/html/User%3APchelolo%2FRedirect_Target_%25`); assert.deepEqual(res.headers['cache-control'], 'no-cache'); assert.deepEqual(res.body.length > 0, true); assert.deepEqual(/Redirect Target/.test(res.body.toString()), true); @@ -367,7 +370,7 @@ describe('redirects', () => { it('should redirect to commons for missing file pages, cross-origin', () => { return preq.get({ - uri: `${server.config.bucketURL()}/html/File:ThinkingMan_Rodin.jpg`, + uri: `${server.config.bucketURL()}/html/${FILE_PAGE}`, headers: { origin: 'test.com' }, @@ -376,7 +379,7 @@ describe('redirects', () => { .then((res) => { assert.deepEqual(res.status, 200); assert.ok(res.headers['content-location'] && - res.headers['content-location'].startsWith('https://commons.wikimedia.org/api/rest_v1/page/html/'), + res.headers['content-location'].startsWith('https://commons.wikimedia.beta.wmflabs.org/api/rest_v1/page/html/'), 'No redirect to commons detected!'); assert.deepEqual(res.headers['cache-control'], 'no-cache'); }); @@ -384,7 +387,7 @@ describe('redirects', () => { it('should stop redirect cycles, cross-origin', () => { return preq.get({ - uri: `${server.config.bucketURL('en.wikipedia.beta.wmflabs.org')}/html/User:Pchelolo%2fRedirect_Test_One`, + uri: `${server.config.bucketURL()}/html/User:Pchelolo%2fRedirect_Test_One`, headers: { origin: 'test.com' }, diff --git a/test/features/pagecontent/revisions.js b/test/features/pagecontent/revisions.js deleted file mode 100644 index fd0d743dd..000000000 --- a/test/features/pagecontent/revisions.js +++ /dev/null @@ -1,166 +0,0 @@ -'use strict'; - -const assert = require('../../utils/assert.js'); -const preq = require('preq'); -const Server = require('../../utils/server.js'); - -function generateTests(server, options) { - it('should return valid revision info', () => { - return preq.get({ uri: `${server.config.bucketURL(options.domain)}/title/${encodeURIComponent(options.pageName)}` }) - .then((res) => { - assert.deepEqual(res.status, 200); - assert.deepEqual(res.body.items.length, 1); - assert.deepEqual(res.body.items[0].rev, options.pageLastRev); - assert.deepEqual(res.body.items[0].title, options.pageName); - assert.deepEqual(res.body.items[0].redirect, false); - }); - }); - - it('should return redirect true when included', () => { - return preq.get({ - uri: `${server.config.bucketURL(options.domain)}/title/${encodeURIComponent(options.redirectPageName)}/${options.revRedirect}` - }) - .then((res) => { - assert.deepEqual(res.status, 200); - assert.deepEqual(res.body.items.length, 1); - assert.deepEqual(res.body.items[0].rev, options.revRedirect); - assert.deepEqual(res.body.items[0].redirect, true); - }); - }); - - it('should query the MW API for revision info', () => { - assert.recordRequests(); - return preq.get({ - uri: `${server.config.bucketURL(options.domain)}/title/${encodeURIComponent(options.pageName)}/${options.revPrevious}`, - headers: { 'cache-control': 'no-cache' } - }) - .then((res) => { - assert.deepEqual(res.status, 200); - assert.deepEqual(res.body.items.length, 1); - assert.deepEqual(res.body.items[0].rev, options.revPrevious); - assert.deepEqual(res.body.items[0].title, options.pageName); - assert.remoteRequests(true); - }) - .finally(() => assert.cleanupRecorder()); - }); - - it('should fail for an invalid revision', () => { - return preq.get({ uri: `${server.config.bucketURL(options.domain)}/title/${encodeURIComponent(options.pageName)}/faultyrevid` }) - .then((res) => { - throw new Error(`Expected status 400 for an invalid revision, got ${res.status}`); - }, - (res) => { - assert.deepEqual(res.status, 400); - }); - }); - - it('should query the MW API for a non-existent revision and return a 404', () => { - assert.recordRequests(); - return preq.get({ uri: `${server.config.bucketURL(options.domain)}/title/${encodeURIComponent(options.pageName)}/0` }) - .then((res) => { - throw new Error(`Expected status 404 for an invalid revision, got ${res.status}`); - }, - (res) => { - assert.deepEqual(res.status, 404); - assert.remoteRequests(true); - }) - .finally(() => assert.cleanupRecorder()); - }); - - it('should return latest revision for a page', () => { - return preq.get({ - uri: `${server.config.bucketURL(options.domain)}/title/${encodeURIComponent(options.pageName)}`, - headers: { - 'cache-control': 'no-cache' - } - }) - .then((res) => { - assert.deepEqual(res.status, 200); - assert.deepEqual(res.body.items.length, 1); - assert.deepEqual(res.body.items[0].rev, options.pageLastRev); - }); - }); - -} - -describe('revision requests with en.wikipedia.org', function() { - this.timeout(20000); - const server = new Server(); - before(() => server.start()); - after(() => server.stop()); - - const titleDeleted = 'User_talk:DivineAlpha/Q1_2015_discussions'; - const revDeleted = 645504917; - - generateTests(server,{ - domain: 'en.wikipedia.org', - redirectPageName: 'Main_page', - revRedirect: 591082967, - pageName: 'User:GWicke/Date', - pageLastRev: 653530930, - revPrevious: 653529842 - }); - - it('should fail for a restricted revision fetched from MW API', () => { - return preq.get({ - uri: `${server.config.bucketURL()}/title/${encodeURIComponent(titleDeleted)}/${revDeleted}`, - headers: { 'cache-control': 'no-cache' } - }) - .then((res) => { - throw new Error(`Expected status 403 for a restricted revision, got ${res.status}`); - }, res => assert.deepEqual(res.status, 403)); - }); - - it('should fail for a restricted revision present in storage', () => { - return preq.get({ - uri: `${server.config.bucketURL()}/title/${encodeURIComponent(titleDeleted)}/${revDeleted}`, - }) - .then((res) => { - throw new Error(`Expected status 403 for a restricted revision, got ${res.status}`); - }, res => assert.deepEqual(res.status, 403)); - }); - - it('should restrict user and comment', () => { - return preq.get({ - uri: `${server.config.bucketURL()}/title/User:Pchelolo%2fRestricted_Rev` - }) - .then((res) => { - assert.deepEqual(res.status, 200); - const item = res.body.items[0]; - assert.deepEqual(!!item.user_id, false); - assert.deepEqual(!!item.user_text, false); - assert.deepEqual(!!item.comment, false); - }); - }); -}); - -describe('revision requests with test2.wikipedia.org', function() { - this.timeout(20000); - const server = new Server(); - before(() => server.start()); - after(() => server.stop()); - generateTests(server,{ - domain: 'test2.wikipedia.org', - redirectPageName: 'User:Pchelolo/Redir', - revRedirect: 157490, - pageName: 'User:Pchelolo/Date', - pageLastRev: 329034, - revPrevious: 157487 - }); -}); - -describe('revision requests with test.wikipedia.org', function() { - this.timeout(20000); - const server = new Server(); - before(() => server.start()); - after(() => server.stop()); - generateTests(server, { - domain: 'test.wikipedia.org', - redirectPageName: 'User:Pchelolo/Redir', - revRedirect: 234965, - pageName: 'User:Pchelolo/Date', - pageLastRev: 234964, - revPrevious: 234963 - }); -}); - diff --git a/test/features/pcs.js b/test/features/pcs.js index 53aa7bb73..dcaea934a 100644 --- a/test/features/pcs.js +++ b/test/features/pcs.js @@ -51,8 +51,8 @@ const preq = require('preq'); before(() => server.start()); after(() => server.stop()); - const pageTitle = 'Foobar'; - const pageRev = 757550077; + const pageTitle = 'San_Francisco'; + const pageRev = 395889; it(`Should fetch latest ${testSpec.endpoint}`, () => { return preq.get({ diff --git a/test/features/post_data.js b/test/features/post_data.js index 4184f1a47..3a64f3d9d 100644 --- a/test/features/post_data.js +++ b/test/features/post_data.js @@ -14,7 +14,7 @@ describe('post_data', function() { it('should store post request by hash', () => { return preq.post({ - uri: `${server.config.baseURL('fake.wikipedia.org')}/post_data/`, + uri: `${server.config.baseURL('fake.fakepedia.org')}/post_data/`, body: { key: 'value' } @@ -24,7 +24,7 @@ describe('post_data', function() { assert.deepEqual(res.status, 201); assert.deepEqual(hash, '228458095a9502070fc113d99504226a6ff90a9a'); return preq.get({ - uri: `${server.config.baseURL('fake.wikipedia.org')}/post_data/${res.body}` + uri: `${server.config.baseURL('fake.fakepedia.org')}/post_data/${res.body}` }); }) .then((res) => { @@ -35,7 +35,7 @@ describe('post_data', function() { it('should not explode on empty body', () => { return preq.post({ - uri: `${server.config.baseURL('fake.wikipedia.org')}/post_data/` + uri: `${server.config.baseURL('fake.fakepedia.org')}/post_data/` }) .then((res) => { assert.deepEqual(res.status, 201); @@ -44,7 +44,7 @@ describe('post_data', function() { it('should not store identical request', () => { return preq.post({ - uri: `${server.config.baseURL('fake.wikipedia.org')}/post_data/`, + uri: `${server.config.baseURL('fake.fakepedia.org')}/post_data/`, body: { key: 'value' } @@ -57,7 +57,7 @@ describe('post_data', function() { it('should allow read on remote request', () => { return preq.get({ - uri: `${server.config.baseURL('fake.wikipedia.org')}/post_data/${hash}` + uri: `${server.config.baseURL('fake.fakepedia.org')}/post_data/${hash}` }) .then((res) => { assert.deepEqual(res.status, 200); @@ -67,7 +67,7 @@ describe('post_data', function() { it('should deny write on remote requests', () => { return preq.post({ - uri: `${server.config.baseURL('fake.wikipedia.org')}/post_data/`, + uri: `${server.config.baseURL('fake.fakepedia.org')}/post_data/`, headers: { 'x-client-ip': '123.123.123.123' }, diff --git a/test/features/router/misc.js b/test/features/router/misc.js index a699eb6de..d68a681a7 100644 --- a/test/features/router/misc.js +++ b/test/features/router/misc.js @@ -18,7 +18,7 @@ describe('router - misc', function() { after(() => server.stop()); it('should deny access to /{domain}/sys', () => { - return preq.get({uri: `${server.config.hostPort}/en.wikipedia.org/sys/action/query`}) + return preq.get({uri: `${server.config.hostPort}/${server.config.defaultDomain}/sys/action/query`}) .catch((err) => { assert.deepEqual(err.status, 403); }); diff --git a/test/features/schema_tests.js b/test/features/schema_tests.js index edf8b2eeb..3d309e6ab 100644 --- a/test/features/schema_tests.js +++ b/test/features/schema_tests.js @@ -48,48 +48,43 @@ parallel('Responses should conform to the provided JSON schema of the response', schema: 'feed' }, { - domain: 'ru.wikipedia.org', + domain: 'de.wikipedia.beta.wmflabs.org', path: '/feed/featured', params: getToday(), schema: 'feed' }, { path: '/page/summary', - params: 'Tank', + params: 'Foobar', schema: 'summary' }, { path: '/feed/announcements', schema: 'announcementsResponse' }, - { - path: '/feed/onthisday', - params: 'all/01/03', - schema: 'onthisdayResponse' - }, { path: '/page/related', - params: 'Tank', + params: 'San_Francisco', schema: 'related' }, { path: '/page/media', - params: 'Tank', + params: 'San_Francisco', schema: 'media_list_with_metadata' }, { path: '/page/media-list', - params: 'Tank', + params: 'San_Francisco', schema: 'media_list' }, { path: '/page/references', - params: 'Tank', + params: 'San_Francisco', schema: 'references_response' }, { path: '/page/metadata', - params: 'Tank', + params: 'San_Francisco', schema: 'metadata' } ].forEach((testSpec) => { diff --git a/test/features/security/security.js b/test/features/security/security.js index a447f36c6..f4ffdfb6a 100644 --- a/test/features/security/security.js +++ b/test/features/security/security.js @@ -18,7 +18,7 @@ describe('router - security', function() { // Do preparation requests to force siteInfo fetch so that we don't need to mock it return P.join( preq.get({uri: `${server.config.bucketURL()}/title/Main_Page`}), - preq.get({uri: `${server.config.bucketURL('fr.wikipedia.org')}/title/Wikipédia:Accueil_principal`}) + preq.get({uri: `${server.config.bucketURL('ru.wikipedia.beta.wmflabs.org')}/title/${encodeURIComponent('Заглавная_страница')}`}) ); }); }); @@ -50,7 +50,7 @@ describe('router - security', function() { it('should forward cookies on request to api', () => { nock.enableNetConnect(); - const apiURI = server.config.apiURL('fr.wikipedia.org'); + const apiURI = server.config.apiURL('ru.wikipedia.beta.wmflabs.org'); const api = nock(apiURI, { reqheaders: { cookie: 'test=test_cookie' @@ -65,7 +65,7 @@ describe('router - security', function() { .reply(200, sampleRightsResponse); return preq.get({ - uri: `${server.config.bucketURL('fr.wikipedia.org')}/title/`, + uri: `${server.config.bucketURL('ru.wikipedia.beta.wmflabs.org')}/title/`, headers: { 'Cookie': 'test=test_cookie' } @@ -76,14 +76,14 @@ describe('router - security', function() { it('should forward cookies on request to parsoid', () => { nock.enableNetConnect(); - const title = 'Test'; - const revision = 117795883; + const title = 'Б'; + const revision = 1831; const api = nock(server.config.parsoidURI, { reqheaders: { cookie: 'test=test_cookie' } }) - .get(`/fr.wikipedia.org/v3/page/pagebundle/${title}/${revision}`) + .get(`/ru.wikipedia.beta.wmflabs.org/v3/page/pagebundle/${encodeURIComponent(title)}/${revision}`) .reply(200, () => { return { 'html': { @@ -110,7 +110,7 @@ describe('router - security', function() { }); return preq.get({ - uri: `${server.config.bucketURL('fr.wikipedia.org')}/html/${title}/${revision}`, + uri: `${server.config.bucketURL('ru.wikipedia.beta.wmflabs.org')}/html/${encodeURIComponent(title)}/${revision}`, headers: { 'Cookie': 'test=test_cookie', 'Cache-control': 'no-cache' @@ -130,7 +130,7 @@ describe('router - security', function() { .reply(200); return preq.get({ - uri: `${server.config.baseURL('fake.wikipedia.org')}/http/${encodeURIComponent(externalURI)}`, + uri: `${server.config.baseURL('fake.fakepedia.org')}/http/${encodeURIComponent(externalURI)}`, headers: { 'cookie': 'test=test_cookie' } @@ -160,7 +160,7 @@ describe('router - security', function() { nock.enableNetConnect(); const title = 'TestingTitle'; - const api = nock(server.config.apiURL('fr.wikipedia.org')) + const api = nock(server.config.apiURL('ru.wikipedia.beta.wmflabs.org')) .post('') .reply(200, { 'query': { @@ -172,7 +172,7 @@ describe('router - security', function() { } }); return preq.get({ - uri: `${server.config.bucketURL('fr.wikipedia.org')}/title/${title}`, + uri: `${server.config.bucketURL('ru.wikipedia.beta.wmflabs.org')}/title/${title}`, headers: { 'cache-control': 'no-cache' } diff --git a/test/features/specification/monitoring.js b/test/features/specification/monitoring.js index b0d4b0e81..fd59124ac 100644 --- a/test/features/specification/monitoring.js +++ b/test/features/specification/monitoring.js @@ -35,6 +35,13 @@ function filterPath(paths, pathStr, method) { return p['x-monitor']; } +function betaDomain(domain) { + if (domain === 'wikimedia.org') { + return domain; + } + return domain.replace(/\.org$/, '.beta.wmflabs.org'); +} + function constructTests(spec, options, server) { const paths = spec.paths; const ret = []; @@ -53,7 +60,8 @@ function constructTests(spec, options, server) { p['x-amples'].forEach((ex) => { ex.request = ex.request || {}; ex.request.params = ex.request.params || {}; - ex.request.params.domain = ex.request.params.domain || options.domain; + ex.request.params.domain = ex.request.params.domain ? + betaDomain(ex.request.params.domain) : options.domain; if (ex.request.params.domain !== options.domain) { return; } @@ -170,7 +178,7 @@ describe('Monitoring tests', function() { it('should get the spec', () => { return P.each([{ - domain: 'en.wikipedia.org', + domain: 'en.wikipedia.beta.wmflabs.org', specURI: `${server.config.baseURL()}/?spec` }, { @@ -178,16 +186,16 @@ describe('Monitoring tests', function() { specURI: `${server.config.baseURL('wikimedia.org')}/?spec` }, { - domain: 'en.wiktionary.org', - specURI: `${server.config.baseURL('en.wiktionary.org')}/?spec` + domain: 'en.wiktionary.beta.wmflabs.org', + specURI: `${server.config.baseURL('en.wiktionary.beta.wmflabs.org')}/?spec` }, { - domain: 'www.wikidata.org', - specURI: `${server.config.baseURL('www.wikidata.org')}/?spec` + domain: 'wikidata.beta.wmflabs.org', + specURI: `${server.config.baseURL('wikidata.beta.wmflabs.org')}/?spec` }, { - domain: 'commons.wikimedia.org', - specURI: `${server.config.baseURL('commons.wikimedia.org')}/?spec` + domain: 'commons.wikimedia.beta.wmflabs.org', + specURI: `${server.config.baseURL('commons.wikimedia.beta.wmflabs.org')}/?spec` }], (options) => { return preq.get(options.specURI) @@ -218,8 +226,7 @@ describe('Monitoring tests', function() { }); }); }; - parallel(`Monitoring routes, ${options.domain} domain, new content`, defineTests); - parallel(`Monitoring routes, ${options.domain} domain, from storage`, defineTests); + parallel(`Monitoring routes, ${options.domain} domain`, defineTests); }); }); }); diff --git a/test/utils/server.js b/test/utils/server.js index 11c37c644..fbc2d44fe 100644 --- a/test/utils/server.js +++ b/test/utils/server.js @@ -2,7 +2,7 @@ const P = require('bluebird'); const TestRunner = require('service-runner/test/TestServer'); -const DEFAULT_DOMAIN = 'en.wikipedia.org'; +const DEFAULT_DOMAIN = 'en.wikipedia.beta.wmflabs.org'; class TestRestbase { constructor() { @@ -48,7 +48,7 @@ class TestRestbase { apiBase, apiPath, apiURL, - parsoidURI: 'https://parsoid-beta.wmflabs.org', + parsoidURI: 'https://en.wikipedia.beta.wmflabs.org/w/rest.php', conf } } diff --git a/v1/feed.yaml b/v1/feed.yaml index d235a1b52..5d27ba948 100644 --- a/v1/feed.yaml +++ b/v1/feed.yaml @@ -62,14 +62,6 @@ paths: headers: content-type: /application\/json/ body: - tfa: - title: /.+/ - description: /.+/ - extract: /.+/ - thumbnail: - source: /.+/ - width: /.+/ - height: /.+/ mostread: date: /.+/ articles: @@ -78,19 +70,6 @@ paths: title: /.+/ pageid: /.+/ normalizedtitle: /.+/ - image: - title: /.+/ - description: - text: /.+/ - lang: /.+/ - image: - source: /.+/ - width: /.+/ - height: /.+/ - thumbnail: - source: /.+/ - width: /.+/ - height: /.+/ components: schemas: mostread_article: