Skip to content

Commit

Permalink
Tests: Remove dependency from production wikis
Browse files Browse the repository at this point in the history
Bug: T231933
Change-Id: I7a33b370da0232d3a694a0e00bcec5e5339c6f45
  • Loading branch information
Petr Pchelko committed Jan 3, 2020
1 parent 9d07f35 commit e1e0ad2
Show file tree
Hide file tree
Showing 20 changed files with 276 additions and 494 deletions.
31 changes: 7 additions & 24 deletions config.frontend.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'}}"
Expand Down Expand Up @@ -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:
Expand Down
30 changes: 7 additions & 23 deletions config.fullstack.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'}}"
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/parsoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
34 changes: 17 additions & 17 deletions test/features/events/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
]
});
});
Expand All @@ -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);
Expand Down Expand Up @@ -71,19 +71,19 @@ 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',
},
body: [
{
meta: {
uri: '//fake.wikipedia.org/wiki/User:Pchelolo'
uri: '//fake.fakepedia.org/wiki/User:Pchelolo'
},
tags: ['test']
},
Expand All @@ -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']
}
Expand All @@ -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']
}
Expand Down
34 changes: 17 additions & 17 deletions test/features/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading

0 comments on commit e1e0ad2

Please sign in to comment.