This repository has been archived by the owner on May 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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.
- Loading branch information
Shane Tomlinson
committed
Dec 9, 2016
1 parent
77a6e89
commit 3611594
Showing
12 changed files
with
235 additions
and
2,408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env node | ||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
|
||
require('../tests/lib/test_env.js'); | ||
|
||
const assert = require('assert'); | ||
const http = require('http'); | ||
const vows = require('vows'); | ||
const start_stop = require('../tests/lib/start-stop.js'); | ||
const wsapi = require('../lib/wsapi.js'); | ||
|
||
const WSAPI_PREFIX = '/wsapi/'; | ||
const allAPIs = wsapi.allAPIs(); | ||
|
||
var suite = vows.describe('wsapi routes'); | ||
|
||
// disable vows (often flakey?) async error behavior | ||
suite.options.error = false; | ||
|
||
start_stop.addStartupBatches(suite); | ||
|
||
const batch = {}; | ||
|
||
Object.keys(allAPIs).forEach(function (apiName) { | ||
const API = allAPIs[apiName]; | ||
addRouteTest(API.method, apiName, 410); | ||
}); | ||
|
||
addRouteTest('get', 'non-existent', 404); | ||
addRouteTest('post', 'non-existent', 404); | ||
|
||
suite.addBatch(batch); | ||
|
||
function addRouteTest (method, pathname, expectedStatus) { | ||
batch[method + ': ' + pathname] = { | ||
topic: function () { | ||
makeRequest(method, pathname, this.callback); | ||
}, | ||
|
||
'returns the expected status': function (res) { | ||
assert.equal(res.statusCode, expectedStatus); | ||
} | ||
}; | ||
} | ||
|
||
function makeRequest(method, pathname, done) { | ||
var req = http.request({ | ||
host: '127.0.0.1', | ||
port: '10002', | ||
path: WSAPI_PREFIX + pathname, | ||
agent: false, | ||
method: method.toUpperCase() | ||
}, function (res) { | ||
res.on('end', done(res)); | ||
}); | ||
|
||
req.end(); | ||
} | ||
|
||
start_stop.addShutdownBatches(suite); | ||
|
||
// run or export the suite. | ||
if (process.argv[1] === __filename) suite.run(); | ||
else suite.export(module); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env node | ||
|
||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
|
||
require('../tests/lib/test_env.js'); | ||
|
||
const assert = require('assert'); | ||
const vows = require('vows'); | ||
const start_stop = require('../tests/lib/start-stop.js'); | ||
const wsapi = require('../lib/wsapi.js'); | ||
|
||
var suite = vows.describe('wsapi'); | ||
|
||
// disable vows (often flakey?) async error behavior | ||
suite.options.error = false; | ||
|
||
start_stop.addStartupBatches(suite); | ||
|
||
suite.addBatch({ | ||
'allAPIs': { | ||
topic: function() { | ||
return wsapi.allAPIs(); | ||
}, | ||
|
||
'works': function(allAPIs) { | ||
assert.equal(typeof allAPIs, 'object'); | ||
assert.equal(Object.keys(allAPIs).length, 38); | ||
} | ||
} | ||
}); | ||
|
||
var appMock; | ||
suite.addBatch({ | ||
'routeSetup': { | ||
topic: function() { | ||
appMock = { | ||
getCount: 0, | ||
postCount: 0, | ||
routeCount: 0, | ||
|
||
get: function (route, callback) { | ||
this.getCount++; | ||
this.routeCount++; | ||
}, | ||
|
||
post: function () { | ||
this.postCount++; | ||
this.routeCount++; | ||
} | ||
}; | ||
|
||
wsapi.routeSetup(appMock); | ||
return true; | ||
}, | ||
|
||
'sets up the appropriate number of routes': function () { | ||
assert.equal(appMock.getCount, 16); | ||
assert.equal(appMock.postCount, 22); | ||
assert.equal(appMock.routeCount, 38); | ||
} | ||
} | ||
}); | ||
|
||
start_stop.addShutdownBatches(suite); | ||
|
||
// run or export the suite. | ||
if (process.argv[1] === __filename) suite.run(); | ||
else suite.export(module); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.