Adding IE8 Support, Test updates
This commit is contained in:
Родитель
73a72488ec
Коммит
a8fb9b5a8d
|
@ -6,7 +6,7 @@ module.exports = function (grunt) {
|
|||
// load all grunt tasks matching the `grunt-*` pattern
|
||||
require('load-grunt-tasks')(grunt);
|
||||
// load the Intern tasks
|
||||
grunt.loadNpmTasks('intern');
|
||||
grunt.loadNpmTasks('intern-geezer');
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json')
|
||||
|
|
|
@ -79,7 +79,7 @@ define(['sjcl'], function (sjcl) {
|
|||
return result;
|
||||
}
|
||||
|
||||
if (hawk.crypto.algorithms.indexOf(credentials.algorithm) === -1) {
|
||||
if (hawk.utils.baseIndexOf(hawk.crypto.algorithms, credentials.algorithm) === -1) {
|
||||
result.err = 'Unknown algorithm';
|
||||
return result;
|
||||
}
|
||||
|
@ -466,6 +466,18 @@ define(['sjcl'], function (sjcl) {
|
|||
return result.join('');
|
||||
},
|
||||
|
||||
baseIndexOf: function(array, value, fromIndex) {
|
||||
var index = (fromIndex || 0) - 1,
|
||||
length = array ? array.length : 0;
|
||||
|
||||
while (++index < length) {
|
||||
if (array[index] === value) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
},
|
||||
|
||||
parseUri: function (input) {
|
||||
|
||||
// Based on: parseURI 1.2.2
|
||||
|
|
|
@ -54,32 +54,36 @@ define(['./hawk', 'p', './errors'], function (hawk, P, ERRORS) {
|
|||
deferred.reject({ error: 'Unknown error', message: e.toString(), errno: 999 });
|
||||
}
|
||||
|
||||
xhr.onerror = function onerror() {
|
||||
deferred.reject(xhr.responseText);
|
||||
};
|
||||
xhr.onload = function onload() {
|
||||
var result = xhr.responseText;
|
||||
try {
|
||||
result = JSON.parse(xhr.responseText);
|
||||
} catch (e) { }
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4) {
|
||||
var result = xhr.responseText;
|
||||
try {
|
||||
result = JSON.parse(xhr.responseText);
|
||||
} catch (e) { }
|
||||
|
||||
if (result.errno) {
|
||||
// Try to recover from a timeskew error and not already tried
|
||||
if (result.errno === ERRORS.INVALID_TIMESTAMP && !options.retrying) {
|
||||
var serverTime = result.serverTime;
|
||||
self._localtimeOffsetMsec = (serverTime * 1000) - new Date().getTime();
|
||||
if (result.errno) {
|
||||
// Try to recover from a timeskew error and not already tried
|
||||
if (result.errno === ERRORS.INVALID_TIMESTAMP && !options.retrying) {
|
||||
var serverTime = result.serverTime;
|
||||
self._localtimeOffsetMsec = (serverTime * 1000) - new Date().getTime();
|
||||
|
||||
// add to options that the request is retrying
|
||||
options.retrying = true;
|
||||
// add to options that the request is retrying
|
||||
options.retrying = true;
|
||||
|
||||
return self.send(path, method, credentials, jsonPayload, options)
|
||||
.then(deferred.resolve, deferred.reject);
|
||||
return self.send(path, method, credentials, jsonPayload, options)
|
||||
.then(deferred.resolve, deferred.reject);
|
||||
|
||||
} else {
|
||||
} else {
|
||||
return deferred.reject(result);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof xhr.status === 'undefined' || xhr.status !== 200) {
|
||||
return deferred.reject(result);
|
||||
}
|
||||
|
||||
deferred.resolve(result);
|
||||
}
|
||||
deferred.resolve(result);
|
||||
};
|
||||
|
||||
// calculate Hawk header if credentials are supplied
|
||||
|
|
|
@ -47,7 +47,8 @@
|
|||
"grunt-copyright": "~0.1.0",
|
||||
"grunt-jscs-checker": "~0.4.0",
|
||||
"grunt-open": "~0.2.2",
|
||||
"intern": "~1.5.0",
|
||||
"load-grunt-tasks": "~0.2.0"
|
||||
"intern-geezer": "~1.5.0",
|
||||
"load-grunt-tasks": "~0.2.0",
|
||||
"http-proxy": "~1.0.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ define([
|
|||
}
|
||||
|
||||
AccountHelper.prototype.newVerifiedAccount = function () {
|
||||
var user = 'testHelp1' + Date.now();
|
||||
var user = 'testHelp1' + new Date().getTime();
|
||||
var email = user + "@restmail.net";
|
||||
var password = "iliketurtles";
|
||||
var respond = this.respond;
|
||||
|
@ -56,7 +56,7 @@ define([
|
|||
};
|
||||
|
||||
AccountHelper.prototype.newUnverifiedAccount = function () {
|
||||
var user = 'testHelp2' + Date.now();
|
||||
var user = 'testHelp2' + new Date().getTime();
|
||||
var email = user + "@restmail.net";
|
||||
var password = "iliketurtles";
|
||||
var respond = this.respond;
|
||||
|
|
|
@ -6,12 +6,13 @@ define([
|
|||
'tests/intern',
|
||||
'intern/node_modules/dojo/has!host-node?intern/node_modules/dojo/node!xmlhttprequest',
|
||||
'tests/addons/sinonResponder',
|
||||
'tests/addons/sinon',
|
||||
'client/FxAccountClient',
|
||||
'tests/addons/restmail',
|
||||
'tests/addons/accountHelper',
|
||||
'tests/mocks/request',
|
||||
'tests/mocks/errors'
|
||||
], function (config, XHR, SinonResponder, FxAccountClient, Restmail, AccountHelper, RequestMocks, ErrorMocks) {
|
||||
], function (config, XHR, SinonResponder, Sinon, FxAccountClient, Restmail, AccountHelper, RequestMocks, ErrorMocks) {
|
||||
|
||||
function Environment() {
|
||||
var self = this;
|
||||
|
@ -30,7 +31,7 @@ define([
|
|||
} else {
|
||||
this.requests = [];
|
||||
// switch to the fake XHR
|
||||
this.xhr = SinonResponder.useFakeXMLHttpRequest();
|
||||
this.xhr = Sinon.useFakeXMLHttpRequest();
|
||||
this.xhr.onCreate = function (xhr) {
|
||||
self.requests.push(xhr);
|
||||
};
|
||||
|
|
|
@ -8,8 +8,6 @@ define([
|
|||
], function (Sinon, P) {
|
||||
|
||||
return {
|
||||
useFakeXMLHttpRequest: Sinon.useFakeXMLHttpRequest,
|
||||
|
||||
makeMockResponder: function (requests) {
|
||||
var self = this;
|
||||
var requestIndex = 0;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
|
@ -92,11 +93,17 @@
|
|||
See Console....
|
||||
|
||||
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
|
||||
<script src="../build/fxa-client.js"></script>
|
||||
<script src="../../build/fxa-client.js"></script>
|
||||
<script>
|
||||
var email = 'example' + Date.now() + '@example.com';
|
||||
var email = 'example' + new Date().getTime() + '@example.com';
|
||||
var password = 'allyourbasearebelongtous';
|
||||
var server = 'http://127.0.0.1:9000';
|
||||
|
||||
/**
|
||||
* Server URL, adjust this to test with a proxy.
|
||||
*/
|
||||
var server = 'http://localhost:9000';
|
||||
// Proxy:
|
||||
// var server = 'http://localhost:9133';
|
||||
var client = new FxAccountClient(server);
|
||||
|
||||
// Set Email value
|
|
@ -0,0 +1,35 @@
|
|||
/* 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/. */
|
||||
|
||||
/**
|
||||
* Auth Proxy tester for better IE debugging.
|
||||
*
|
||||
* Run using: node tests/examples/proxy.js
|
||||
*/
|
||||
var http = require('http');
|
||||
var fs = require('fs');
|
||||
var httpProxy = require('http-proxy');
|
||||
|
||||
var proxy = httpProxy.createProxyServer();
|
||||
var port = 9133;
|
||||
var targetAuthServer = 'http://127.0.0.1:9000';
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
|
||||
if (req.url === '/example.html') {
|
||||
|
||||
res.end(fs.readFileSync('tests/examples/example.html'));
|
||||
} else if (req.url === '/build/fxa-client.js') {
|
||||
|
||||
res.end(fs.readFileSync('build/fxa-client.js'));
|
||||
} else {
|
||||
|
||||
proxy.web(req, res, {
|
||||
target: targetAuthServer
|
||||
});
|
||||
}
|
||||
|
||||
}).listen(port);
|
||||
|
||||
console.log('Starting proxy on', port, 'targeting', targetAuthServer, 'fxa-auth-server');
|
|
@ -45,7 +45,7 @@ define(['intern/lib/args'], function (args) {
|
|||
functionalSuites: [ ],
|
||||
AUTH_SERVER_URL: server,
|
||||
|
||||
excludeInstrumentation: /(?:.)\//
|
||||
excludeInstrumentation: /./
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -18,12 +18,14 @@ define([
|
|||
|
||||
intern.capabilities = {
|
||||
'build': '1',
|
||||
'selenium-version': '2.37.0'
|
||||
'selenium-version': '2.39.0'
|
||||
};
|
||||
|
||||
intern.environments = [
|
||||
{ browserName: 'firefox', version: '25' , platform: [ 'Windows 7', 'Linux' ] },
|
||||
{ browserName: 'internet explorer', version: '10', platform: [ 'Windows 7' ] }
|
||||
{ browserName: 'internet explorer', version: ['8', '9', '10'], platform: [ 'Windows 7' ] },
|
||||
{ browserName: 'chrome' },
|
||||
{ browserName: 'safari' }
|
||||
];
|
||||
|
||||
console.log("SAUCE", intern.proxyUrl);
|
||||
|
|
|
@ -123,7 +123,7 @@ define([
|
|||
* Password Reset
|
||||
*/
|
||||
test('#reset password', function () {
|
||||
var user = 'test5' + Date.now();
|
||||
var user = 'test5' + new Date().getTime();
|
||||
var email = user + '@restmail.net';
|
||||
var password = 'iliketurtles';
|
||||
var uid;
|
||||
|
|
|
@ -26,7 +26,7 @@ define([
|
|||
});
|
||||
|
||||
test('#signUp', function () {
|
||||
var user = "test" + Date.now();
|
||||
var user = "test" + new Date().getTime();
|
||||
var email = user + "@restmail.net";
|
||||
var password = "iliketurtles";
|
||||
var opts = {
|
||||
|
|
|
@ -32,7 +32,7 @@ define([
|
|||
});
|
||||
|
||||
test('#basic', function () {
|
||||
var user = 'test7' + Date.now();
|
||||
var user = 'test7' + new Date().getTime();
|
||||
var email = user + '@restmail.net';
|
||||
var password = 'iliketurtles';
|
||||
var newPassword = 'ilikefoxes';
|
||||
|
@ -174,7 +174,7 @@ define([
|
|||
* Changing the Password failure
|
||||
*/
|
||||
test('#changeFailure', function () {
|
||||
var user = 'test8' + Date.now();
|
||||
var user = 'test8' + new Date().getTime();
|
||||
var email = user + '@restmail.net';
|
||||
var password = 'iliketurtles';
|
||||
var newPassword = 'ilikefoxes';
|
||||
|
|
|
@ -5,37 +5,46 @@
|
|||
define([
|
||||
'intern!tdd',
|
||||
'intern/chai!assert',
|
||||
'tests/addons/environment',
|
||||
'client/lib/request',
|
||||
'intern/node_modules/dojo/has!host-node?intern/node_modules/dojo/node!xmlhttprequest',
|
||||
'tests/addons/sinonResponder',
|
||||
'tests/mocks/request'
|
||||
], function (tdd, assert, Request, XHR, SinonResponder, RequestMocks) {
|
||||
'tests/addons/sinonResponder'
|
||||
], function (tdd, assert, Environment, Request, SinonResponder) {
|
||||
with (tdd) {
|
||||
suite('request module', function () {
|
||||
var client;
|
||||
var requests;
|
||||
var baseUri = 'http://127.0.0.1:9000';
|
||||
var RequestMocks;
|
||||
var request;
|
||||
var env;
|
||||
|
||||
beforeEach(function () {
|
||||
var xhr = SinonResponder.useFakeXMLHttpRequest();
|
||||
requests = [];
|
||||
|
||||
xhr.onCreate = function (xhr) {
|
||||
requests.push(xhr);
|
||||
};
|
||||
|
||||
client = new Request(baseUri, xhr);
|
||||
env = new Environment();
|
||||
RequestMocks = env.RequestMocks;
|
||||
request = new Request(env.authServerUrl, env.xhr);
|
||||
});
|
||||
|
||||
test('#heartbeat (async)', function () {
|
||||
var heartbeatRequest = client.send("/__heartbeat__", "GET")
|
||||
.then(function (res) {
|
||||
assert.ok(res);
|
||||
});
|
||||
SinonResponder.respond(requests[0], RequestMocks.heartbeat);
|
||||
test('#heartbeat', function () {
|
||||
var heartbeatRequest = env.respond(request.send("/__heartbeat__", "GET"), RequestMocks.heartbeat)
|
||||
.then(
|
||||
function (res) {
|
||||
assert.ok(res);
|
||||
},
|
||||
assert.notOk
|
||||
);
|
||||
|
||||
return heartbeatRequest;
|
||||
});
|
||||
|
||||
test('#error', function () {
|
||||
request = new Request('http://', env.xhr);
|
||||
|
||||
request.send("/", "GET")
|
||||
.then(
|
||||
assert.notOk,
|
||||
function () {
|
||||
assert.ok(true);
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -26,7 +26,7 @@ define([
|
|||
});
|
||||
|
||||
test('#basic', function () {
|
||||
var email = "test" + Date.now() + "@restmail.net";
|
||||
var email = "test" + new Date().getTime() + "@restmail.net";
|
||||
var password = "iliketurtles";
|
||||
|
||||
return respond(client.signUp(email, password), RequestMocks.signUp)
|
||||
|
@ -43,7 +43,7 @@ define([
|
|||
});
|
||||
|
||||
test('#with keys', function () {
|
||||
var email = "test" + Date.now() + "@restmail.net";
|
||||
var email = "test" + new Date().getTime() + "@restmail.net";
|
||||
var password = "iliketurtles";
|
||||
|
||||
return respond(client.signUp(email, password), RequestMocks.signUp)
|
||||
|
|
|
@ -28,7 +28,7 @@ define([
|
|||
});
|
||||
|
||||
test('#basic', function () {
|
||||
var email = "test" + Date.now() + "@restmail.net";
|
||||
var email = "test" + new Date().getTime() + "@restmail.net";
|
||||
var password = "iliketurtles";
|
||||
|
||||
return respond(client.signUp(email, password), RequestMocks.signUp)
|
||||
|
@ -43,7 +43,7 @@ define([
|
|||
});
|
||||
|
||||
test('#withKeys', function () {
|
||||
var email = "test" + Date.now() + "@restmail.net";
|
||||
var email = "test" + new Date().getTime() + "@restmail.net";
|
||||
var password = "iliketurtles";
|
||||
var opts = {
|
||||
keys: true
|
||||
|
@ -61,7 +61,7 @@ define([
|
|||
});
|
||||
|
||||
test('#create account with service and redirectTo', function () {
|
||||
var user = "test" + Date.now();
|
||||
var user = "test" + new Date().getTime();
|
||||
var email = user + "@restmail.net";
|
||||
var password = "iliketurtles";
|
||||
var opts = {
|
||||
|
@ -90,7 +90,7 @@ define([
|
|||
});
|
||||
|
||||
test('#withService', function () {
|
||||
var user = "test" + Date.now();
|
||||
var user = "test" + new Date().getTime();
|
||||
var email = user + "@restmail.net";
|
||||
var password = "iliketurtles";
|
||||
var opts = {
|
||||
|
@ -115,7 +115,7 @@ define([
|
|||
});
|
||||
|
||||
test('#withRedirectTo', function () {
|
||||
var user = "test" + Date.now();
|
||||
var user = "test" + new Date().getTime();
|
||||
var email = user + "@restmail.net";
|
||||
var password = "iliketurtles";
|
||||
var opts = {
|
||||
|
@ -141,7 +141,7 @@ define([
|
|||
});
|
||||
|
||||
test('#preVerified', function () {
|
||||
var email = "test" + Date.now() + "@restmail.net";
|
||||
var email = "test" + new Date().getTime() + "@restmail.net";
|
||||
var password = "iliketurtles";
|
||||
var opts = {
|
||||
preVerified: true
|
||||
|
|
|
@ -9,7 +9,7 @@ define([
|
|||
], function (tdd, assert, Environment) {
|
||||
|
||||
with (tdd) {
|
||||
suite('fxa client', function () {
|
||||
suite('verifyCode', function () {
|
||||
var accountHelper;
|
||||
var respond;
|
||||
var mail;
|
||||
|
@ -28,7 +28,7 @@ define([
|
|||
});
|
||||
|
||||
test('#verifyEmail', function () {
|
||||
var user = 'test3' + Date.now();
|
||||
var user = 'test3' + new Date().getTime();
|
||||
var email = user + '@restmail.net';
|
||||
var password = 'iliketurtles';
|
||||
var uid;
|
||||
|
@ -55,7 +55,7 @@ define([
|
|||
});
|
||||
|
||||
test('#verifyEmailCheckStatus', function () {
|
||||
var user = 'test4' + Date.now();
|
||||
var user = 'test4' + new Date().getTime();
|
||||
var email = user + '@restmail.net';
|
||||
var password = 'iliketurtles';
|
||||
var uid;
|
||||
|
|
Загрузка…
Ссылка в новой задаче