From 5066e16ea777e843aebbbc9fb5b07e8b55cd2f8b Mon Sep 17 00:00:00 2001 From: drewwarren Date: Tue, 21 Feb 2017 20:18:14 -0500 Subject: [PATCH] mocks to mock.js --- oauth3.issuer.js | 23 ----------------------- oauth3.issuer.mock.js | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/oauth3.issuer.js b/oauth3.issuer.js index 5bec66d..979c0c5 100644 --- a/oauth3.issuer.js +++ b/oauth3.issuer.js @@ -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); diff --git a/oauth3.issuer.mock.js b/oauth3.issuer.mock.js index 2afe1ee..f60118d 100644 --- a/oauth3.issuer.mock.js +++ b/oauth3.issuer.mock.js @@ -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);