don't move .well-known when there is a basePath in publicUrl

This commit is contained in:
Danny Coates 2014-06-11 10:48:28 -07:00
Родитель 41fe9b8e82
Коммит 7454a9f357
2 изменённых файлов: 23 добавлений и 5 удалений

Просмотреть файл

@ -58,6 +58,9 @@ module.exports = function (
config.smtp.redirectDomain
)
var basePath = url.parse(config.publicUrl).path
if (basePath === '/') { basePath = '' }
var v1Routes = [].concat(
account,
password,
@ -65,12 +68,9 @@ module.exports = function (
sign,
util
)
v1Routes.forEach(function(r) { r.path = "/v1" + r.path })
v1Routes.forEach(function(r) { r.path = basePath + "/v1" + r.path })
var allRoutes = defaults.concat(idp, v1Routes)
var basePath = url.parse(config.publicUrl).path
if (basePath === '/') { basePath = '' }
allRoutes.forEach(function (r) { r.path = basePath + r.path })
return allRoutes
}

Просмотреть файл

@ -6,6 +6,8 @@ var test = require('../ptaptest')
var TestServer = require('../test_server')
var path = require('path')
var Client = require('../client')
var P = require('../../promise')
var request = require('request')
process.env.CONFIG_FILES = path.join(__dirname, '../config/base_path.json')
var config = require('../../config').root()
@ -18,12 +20,28 @@ TestServer.start(config)
function (t) {
var email = Math.random() + "@example.com"
var password = 'ok'
t.ok(true) // this silences log output. with no assertions tap dumps logs
// if this doesn't crash, we're all good
return Client.createAndVerify(config.publicUrl, email, password, server.mailbox)
}
)
test(
'.well-known did not move',
function (t) {
var d = P.defer()
request('http://127.0.0.1:9000/.well-known/browserid',
function (err, res, body) {
if (err) { d.reject(err) }
t.equal(res.statusCode, 200)
var json = JSON.parse(body)
t.equal(json.authentication, '/.well-known/browserid/sign_in.html')
d.resolve(json)
}
)
return d.promise
}
)
test(
'teardown',
function (t) {