mocks to mock.js
This commit is contained in:
parent
aac6275285
commit
5066e16ea7
|
@ -239,13 +239,6 @@ OAUTH3.urls.grants = function (directive, opts) {
|
|||
|
||||
OAUTH3.authn = {};
|
||||
OAUTH3.authn.loginMeta = function (directive, opts) {
|
||||
if (opts.mock) {
|
||||
if (opts.mockError) {
|
||||
return OAUTH3.PromiseA.resolve({ data: { error: { message: "Yikes!", code: 'E' } } });
|
||||
}
|
||||
return OAUTH3.PromiseA.resolve({ data: {} });
|
||||
}
|
||||
|
||||
return OAUTH3.request({
|
||||
method: directive.credential_meta.method || 'GET'
|
||||
// TODO lint urls
|
||||
|
@ -255,13 +248,6 @@ OAUTH3.authn.loginMeta = function (directive, opts) {
|
|||
});
|
||||
};
|
||||
OAUTH3.authn.otp = function (directive, opts) {
|
||||
if (opts.mock) {
|
||||
if (opts.mockError) {
|
||||
return OAUTH3.PromiseA.resolve({data: {error: {message: "Yikes!", code: 'E'}}});
|
||||
}
|
||||
return OAUTH3.PromiseA.resolve({data: {uuid: "uuidblah"}});
|
||||
}
|
||||
|
||||
return OAUTH3.request({
|
||||
method: directive.credential_otp.url.method || 'POST'
|
||||
, url: OAUTH3.url.resolve(directive.issuer, directive.credential_otp.url)
|
||||
|
@ -300,15 +286,6 @@ OAUTH3.authn.resourceOwnerPassword = function (directive, opts) {
|
|||
|
||||
OAUTH3.authz = {};
|
||||
OAUTH3.authz.scopes = function (providerUri, session, clientParams) {
|
||||
if (clientParams.mock) {
|
||||
return {
|
||||
pending: ['oauth3_authn'] // not yet accepted
|
||||
, granted: [] // all granted, ever
|
||||
, requested: ['oauth3_authn'] // all requested, now
|
||||
, accepted: [] // granted (ever) and requested (now)
|
||||
};
|
||||
}
|
||||
|
||||
// OAuth3.requests.grants(providerUri, {}); // return list of grants
|
||||
// OAuth3.checkGrants(providerUri, {}); //
|
||||
var clientUri = OAUTH3.uri.normalize(clientParams.client_uri || OAUTH3._browser.window.document.referrer);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
OAUTH3._base64.btoa = function (b64) {
|
||||
// http://stackoverflow.com/questions/9677985/uncaught-typeerror-illegal-invocation-in-chrome
|
||||
return (exports.btoa || require('btoa'))(b64);
|
||||
}
|
||||
};
|
||||
OAUTH3._base64.encodeUrlSafe = function (b64) {
|
||||
// Base64 to URL-safe Base64
|
||||
b64 = b64.replace(/\+/g, '-').replace(/\//g, '_');
|
||||
|
@ -36,7 +36,27 @@
|
|||
|
||||
return OAUTH3._mockToken(providerUri, opts);
|
||||
};
|
||||
OAUTH3.authn.loginMeta = function (directive, opts) {
|
||||
if (opts.mockError) {
|
||||
return OAUTH3.PromiseA.resolve({ data: { error: { message: "Yikes!", code: 'E' } } });
|
||||
}
|
||||
return OAUTH3.PromiseA.resolve({ data: {} });
|
||||
};
|
||||
OAUTH3.authn.otp = function (directive, opts) {
|
||||
if (opts.mockError) {
|
||||
return OAUTH3.PromiseA.resolve({data: {error: {message: "Yikes!", code: 'E'}}});
|
||||
}
|
||||
return OAUTH3.PromiseA.resolve({data: {uuid: "uuidblah"}});
|
||||
};
|
||||
|
||||
OAUTH3.authz.scopes = function () {
|
||||
return {
|
||||
pending: ['oauth3_authn'] // not yet accepted
|
||||
, granted: [] // all granted, ever
|
||||
, requested: ['oauth3_authn'] // all requested, now
|
||||
, accepted: [] // granted (ever) and requested (now)
|
||||
};
|
||||
};
|
||||
OAUTH3.authz.grants = function (providerUri, opts) {
|
||||
if ('POST' === opts.method) {
|
||||
return OAUTH3._mockToken(providerUri, opts);
|
||||
|
|
Loading…
Reference in New Issue