fix(push): temporary fix the callback validation

This commit is contained in:
vladikoff 2018-09-07 18:01:11 -04:00
Родитель c203769372
Коммит f9f70a4adb
3 изменённых файлов: 36 добавлений и 36 удалений

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

@ -403,7 +403,7 @@ those common validations are defined here.
* `name`: isA.string.max(255).regex(DISPLAY_SAFE_UNICODE_WITH_NON_BMP)
* `nameResponse`: isA.string.max(255)
* `type`: isA.string.max(16)
* `pushCallback`: validators.pushCallbackUrl({ scheme: 'https' }).regex(PUSH_SERVER_REGEX).max(255).allow('')
* `pushCallback`: isA.string.regex(PUSH_SERVER_REGEX).max(255).allow('')
* `pushPublicKey`: isA.string.max(88).regex(URL_SAFE_BASE_64).allow('')
* `pushAuthKey`: isA.string.max(24).regex(URL_SAFE_BASE_64).allow('')
* `pushEndpointExpired`: isA.boolean.strict

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

@ -26,7 +26,7 @@ const SCHEMA = {
// so we can't assert DISPLAY_SAFE_UNICODE_WITH_NON_BMP in the response schema.
nameResponse: isA.string().max(255),
type: isA.string().max(16),
pushCallback: validators.pushCallbackUrl({ scheme: 'https' }).regex(PUSH_SERVER_REGEX).max(255).allow(''),
pushCallback: isA.string().regex(PUSH_SERVER_REGEX).max(255).allow(''),
pushPublicKey: isA.string().max(88).regex(URL_SAFE_BASE_64).allow(''),
pushAuthKey: isA.string().max(24).regex(URL_SAFE_BASE_64).allow(''),
pushEndpointExpired: isA.boolean().strict(),

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

@ -263,40 +263,40 @@ describe('remote device', function () {
}
)
it(
'update device fails with non-normalized callbackUrl',
() => {
var badPushCallback = 'https://updates.push.services.mozilla.com/invalid/\u010D/char'
var email = server.uniqueEmail()
var password = 'test password'
var deviceInfo = {
id: crypto.randomBytes(16).toString('hex'),
name: 'test device',
type: 'desktop',
availableCommands: {},
pushCallback: badPushCallback,
pushPublicKey: mocks.MOCK_PUSH_KEY,
pushAuthKey: base64url(crypto.randomBytes(16))
}
return Client.create(config.publicUrl, email, password)
.then(
function (client) {
return client.updateDevice(deviceInfo)
.then(
function (r) {
assert(false, 'request should have failed')
}
)
.catch(
function (err) {
assert.equal(err.code, 400, 'err.code was 400')
assert.equal(err.errno, 107, 'err.errno was 107, invalid parameter')
assert.equal(err.validation.keys[0], 'pushCallback', 'bad pushCallback caught in validation')
}
)
})
}
)
// it(
// 'update device fails with non-normalized callbackUrl',
// () => {
// var badPushCallback = 'https://updates.push.services.mozilla.com/invalid/\u010D/char'
// var email = server.uniqueEmail()
// var password = 'test password'
// var deviceInfo = {
// id: crypto.randomBytes(16).toString('hex'),
// name: 'test device',
// type: 'desktop',
// availableCommands: {},
// pushCallback: badPushCallback,
// pushPublicKey: mocks.MOCK_PUSH_KEY,
// pushAuthKey: base64url(crypto.randomBytes(16))
// }
// return Client.create(config.publicUrl, email, password)
// .then(
// function (client) {
// return client.updateDevice(deviceInfo)
// .then(
// function (r) {
// assert(false, 'request should have failed')
// }
// )
// .catch(
// function (err) {
// assert.equal(err.code, 400, 'err.code was 400')
// assert.equal(err.errno, 107, 'err.errno was 107, invalid parameter')
// assert.equal(err.validation.keys[0], 'pushCallback', 'bad pushCallback caught in validation')
// }
// )
// })
// }
// )
it(
'update device works with stage servers',