Skip to content
This repository was archived by the owner on May 10, 2019. It is now read-only.

Commit e687879

Browse files
author
Shane Tomlinson
committed
Persona end of life.
* All frontend routes show a "Persona has shutdown... See more" message. * All wsapi requests return 410 (Gone). * All navigator.id calls are gutted except those that open the Persona EOL dialog. * Add tests in eol-tests to ensure all wsapi routes return 410. So long, and thanks for all the fish.
1 parent a17aa35 commit e687879

File tree

12 files changed

+234
-2408
lines changed

12 files changed

+234
-2408
lines changed

eol-tests/wsapi-routes-test.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env node
2+
3+
/* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6+
7+
8+
require('../tests/lib/test_env.js');
9+
10+
const assert = require('assert');
11+
const http = require('http');
12+
const vows = require('vows');
13+
const start_stop = require('../tests/lib/start-stop.js');
14+
const wsapi = require('../lib/wsapi.js');
15+
16+
const WSAPI_PREFIX = '/wsapi/';
17+
const allAPIs = wsapi.allAPIs();
18+
19+
var suite = vows.describe('wsapi routes');
20+
21+
// disable vows (often flakey?) async error behavior
22+
suite.options.error = false;
23+
24+
start_stop.addStartupBatches(suite);
25+
26+
const batch = {};
27+
28+
Object.keys(allAPIs).forEach(function (apiName) {
29+
const API = allAPIs[apiName];
30+
addRouteTest(API.method, apiName, 410);
31+
});
32+
33+
addRouteTest('get', 'non-existent', 404);
34+
addRouteTest('post', 'non-existent', 404);
35+
36+
suite.addBatch(batch);
37+
38+
function addRouteTest (method, pathname, expectedStatus) {
39+
batch[method + ': ' + pathname] = {
40+
topic: function () {
41+
makeRequest(method, pathname, this.callback);
42+
},
43+
44+
'returns the expected status': function (res) {
45+
assert.equal(res.statusCode, expectedStatus);
46+
}
47+
};
48+
}
49+
50+
function makeRequest(method, pathname, done) {
51+
var req = http.request({
52+
host: '127.0.0.1',
53+
port: '10002',
54+
path: WSAPI_PREFIX + pathname,
55+
agent: false,
56+
method: method.toUpperCase()
57+
}, function (res) {
58+
res.on('end', done(res));
59+
});
60+
61+
req.end();
62+
}
63+
64+
start_stop.addShutdownBatches(suite);
65+
66+
// run or export the suite.
67+
if (process.argv[1] === __filename) suite.run();
68+
else suite.export(module);

eol-tests/wsapi-test.js

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env node
2+
3+
/* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6+
7+
8+
require('../tests/lib/test_env.js');
9+
10+
const assert = require('assert');
11+
const vows = require('vows');
12+
const start_stop = require('../tests/lib/start-stop.js');
13+
const wsapi = require('../lib/wsapi.js');
14+
15+
var suite = vows.describe('wsapi');
16+
17+
// disable vows (often flakey?) async error behavior
18+
suite.options.error = false;
19+
20+
start_stop.addStartupBatches(suite);
21+
22+
suite.addBatch({
23+
'allAPIs': {
24+
topic: function() {
25+
return wsapi.allAPIs();
26+
},
27+
28+
'works': function(allAPIs) {
29+
assert.equal(typeof allAPIs, 'object');
30+
assert.equal(Object.keys(allAPIs).length, 38);
31+
}
32+
}
33+
});
34+
35+
var appMock;
36+
suite.addBatch({
37+
'routeSetup': {
38+
topic: function() {
39+
appMock = {
40+
getCount: 0,
41+
postCount: 0,
42+
routeCount: 0,
43+
44+
get: function (route, callback) {
45+
this.getCount++;
46+
this.routeCount++;
47+
},
48+
49+
post: function () {
50+
this.postCount++;
51+
this.routeCount++;
52+
}
53+
};
54+
55+
wsapi.routeSetup(appMock);
56+
return true;
57+
},
58+
59+
'sets up the appropriate number of routes': function () {
60+
assert.equal(appMock.getCount, 16);
61+
assert.equal(appMock.postCount, 22);
62+
assert.equal(appMock.routeCount, 38);
63+
}
64+
}
65+
});
66+
67+
start_stop.addShutdownBatches(suite);
68+
69+
// run or export the suite.
70+
if (process.argv[1] === __filename) suite.run();
71+
else suite.export(module);

lib/static/views.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ exports.setup = function(app) {
209209
app.get('/sign_in', function(req, res) {
210210
renderCachableView(req, res, 'dialog.ejs', {
211211
title: _('A Better Way to Sign In'),
212-
layout: 'dialog_layout.ejs',
212+
layout: 'layout.ejs',
213213
useJavascript: true,
214214
measureDomLoading: config.get('measure_dom_loading'),
215215
production: config.get('use_minified_resources'),
@@ -219,15 +219,16 @@ exports.setup = function(app) {
219219

220220
app.get('/communication_iframe', function(req, res) {
221221
renderCachableView(req, res, 'communication_iframe.ejs', {
222-
layout: false,
222+
title: _('Persona communication iframe'),
223+
layout: 'layout.ejs',
223224
production: config.get('use_minified_resources')
224225
});
225226
});
226227

227228
app.get("/unsupported_dialog", function(req,res) {
228229
renderCachableView(req, res, 'unsupported_dialog.ejs', {
229230
title: _('Unsupported Browser'),
230-
layout: 'dialog_layout.ejs',
231+
layout: 'layout.ejs',
231232
useJavascript: false,
232233
// without the javascript bundle, there is no point in measuring the
233234
// window opened time.
@@ -239,7 +240,7 @@ exports.setup = function(app) {
239240
app.get("/unsupported_dialog_without_watch", function(req,res) {
240241
renderCachableView(req, res, 'unsupported_dialog_without_watch.ejs', {
241242
title: _('Unsupported Browser without Watch'),
242-
layout: 'dialog_layout.ejs',
243+
layout: 'layout.ejs',
243244
useJavascript: false,
244245
// without the javascript bundle, there is no point in measuring the
245246
// window opened time.
@@ -251,7 +252,7 @@ exports.setup = function(app) {
251252
app.get("/cookies_disabled", function(req,res) {
252253
renderCachableView(req, res, 'cookies_disabled.ejs', {
253254
title: _('Cookies Are Disabled'),
254-
layout: 'dialog_layout.ejs',
255+
layout: 'layout.ejs',
255256
useJavascript: false,
256257
// without the javascript bundle, there is no point in measuring the
257258
// window opened time.
@@ -263,23 +264,25 @@ exports.setup = function(app) {
263264
// Used for a relay page for communication.
264265
app.get("/relay", function(req, res) {
265266
renderCachableView(req, res, 'relay.ejs', {
266-
layout: false,
267-
production: config.get('use_minified_resources')
267+
layout: 'layout.ejs',
268+
production: config.get('use_minified_resources'),
269+
title: _('Persona relay page')
268270
});
269271
});
270272

271273
// Native IdP Support
272274
app.get('/provision', function(req, res) {
273275
renderCachableView(req, res, 'provision.ejs', {
274-
layout: false,
275-
production: config.get('use_minified_resources')
276+
layout: 'layout.ejs',
277+
production: config.get('use_minified_resources'),
278+
title: _('Persona provisioning page')
276279
});
277280
});
278281

279282
app.get('/auth', function(req, res) {
280283
renderCachableView(req, res, 'dialog.ejs', {
281284
title: _('A Better Way to Sign In'),
282-
layout: 'authenticate_layout.ejs',
285+
layout: 'layout.ejs',
283286
useJavascript: true,
284287
measureDomLoading: config.get('measure_dom_loading'),
285288
production: config.get('use_minified_resources'),

0 commit comments

Comments
 (0)