Skip to content

Commit

Permalink
Merge pull request #315 from stevezau/fix_guardian_calls
Browse files Browse the repository at this point in the history
Fix Guardian Params
  • Loading branch information
luisrudge authored Nov 11, 2018
2 parents db720e5 + 349e77d commit 9d2b9a5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
16 changes: 8 additions & 8 deletions src/management/GuardianManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var GuardianManager = function(options) {
* @type {external:RestClient}
*/
var guardianFactorsAuth0RestClient = new Auth0RestClient(
options.baseUrl + '/guardian/factors/:factor',
options.baseUrl + '/guardian/factors/:name',
clientOptions,
options.tokenProvider
);
Expand All @@ -81,7 +81,7 @@ var GuardianManager = function(options) {
* @type {external:RestClient}
*/
var guardianFactorsTemplatesAuth0RestClient = new Auth0RestClient(
options.baseUrl + '/guardian/factors/:factor/templates',
options.baseUrl + '/guardian/factors/:name/templates',
clientOptions,
options.tokenProvider
);
Expand All @@ -96,7 +96,7 @@ var GuardianManager = function(options) {
* @type {external:RestClient}
*/
var guardianFactorsProvidersAuth0RestClient = new Auth0RestClient(
options.baseUrl + '/guardian/factors/:factor/providers/:provider',
options.baseUrl + '/guardian/factors/:name/providers/:provider',
clientOptions,
options.tokenProvider
);
Expand Down Expand Up @@ -183,7 +183,7 @@ utils.wrapPropertyMethod(GuardianManager, 'getFactors', 'factors.getAll');
* @method getFactorProvider
* @memberOf module:management.GuardianManager.prototype
*
* management.guardian.getFactorProvider({ factor: 'sms', provider: 'twilio'}, function (err, provider) {
* management.guardian.getFactorProvider({ name: 'sms', provider: 'twilio'}, function (err, provider) {
* console.log(provider);
* });
*
Expand All @@ -200,7 +200,7 @@ utils.wrapPropertyMethod(GuardianManager, 'getFactorProvider', 'factorsProviders
* @method updateFactorProvider
* @memberOf module:management.GuardianManager.prototype
*
* management.guardian.updateFactorProvider({ factor: 'sms', provider: 'twilio' }, {
* management.guardian.updateFactorProvider({ name: 'sms', provider: 'twilio' }, {
* messaging_service_sid: 'XXXXXXXXXXXXXX',
* auth_token: 'XXXXXXXXXXXXXX',
* sid: 'XXXXXXXXXXXXXX'
Expand All @@ -222,7 +222,7 @@ utils.wrapPropertyMethod(GuardianManager, 'updateFactorProvider', 'factorsProvid
* @method getFactorTemplates
* @memberOf module:management.GuardianManager.prototype
*
* management.guardian.getFactorTemplates({ factor: 'sms' }, function (err, templates) {
* management.guardian.getFactorTemplates({ name: 'sms' }, function (err, templates) {
* console.log(templates);
* });
*
Expand All @@ -239,7 +239,7 @@ utils.wrapPropertyMethod(GuardianManager, 'getFactorTemplates', 'factorsTemplate
* @method updateFactorTemplates
* @memberOf module:management.GuardianManager.prototype
*
* management.guardian.updateFactorProvider({ factor: 'sms' }, {
* management.guardian.updateFactorProvider({ name: 'sms' }, {
* enrollment_message: "{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.",
* verification_message: "{{code}} is your verification code for {{tenant.friendly_name}}"
* }, function(err, templates) {
Expand All @@ -260,7 +260,7 @@ utils.wrapPropertyMethod(GuardianManager, 'updateFactorTemplates', 'factorsTempl
* @method updateFactor
* @memberOf module:management.GuardianManager.prototype
*
* management.guardian.updateFactor({ factor: 'sms' }, {
* management.guardian.updateFactor({ name: 'sms' }, {
* enabled: true
* }, function(err, factor) {
* console.log(factor);
Expand Down
10 changes: 5 additions & 5 deletions src/management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@ utils.wrapPropertyMethod(ManagementClient, 'getGuardianFactors', 'guardian.facto
* @method getGuardianFactorProvider
* @memberOf module:management.GuardianManager.prototype
*
* management.getFactorProvider({ factor: 'sms', provider: 'twilio'}, function (err, provider) {
* management.getFactorProvider({ name: 'sms', provider: 'twilio'}, function (err, provider) {
* console.log(provider);
* });
*
Expand All @@ -1993,7 +1993,7 @@ utils.wrapPropertyMethod(
* @method updateFactorProvider
* @memberOf module:management.GuardianManager.prototype
*
* management.updateGuardianFactorProvider({ factor: 'sms', provider: 'twilio' }, {
* management.updateGuardianFactorProvider({ name: 'sms', provider: 'twilio' }, {
* messaging_service_sid: 'XXXXXXXXXXXXXX',
* auth_token: 'XXXXXXXXXXXXXX',
* sid: 'XXXXXXXXXXXXXX'
Expand All @@ -2019,7 +2019,7 @@ utils.wrapPropertyMethod(
* @method getGuardianFactorTemplates
* @memberOf module:management.GuardianManager.prototype
*
* management.getGuardianFactorTemplates({ factor: 'sms' }, function (err, templates) {
* management.getGuardianFactorTemplates({ name: 'sms' }, function (err, templates) {
* console.log(templates);
* });
*
Expand All @@ -2040,7 +2040,7 @@ utils.wrapPropertyMethod(
* @method updateGuardianFactorTemplates
* @memberOf module:management.GuardianManager.prototype
*
* management.updateGuardianFactorTemplates({ factor: 'sms' }, {
* management.updateGuardianFactorTemplates({ name: 'sms' }, {
* enrollment_message: "{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.",
* verification_message: "{{code}} is your verification code for {{tenant.friendly_name}}"
* }, function(err, templates) {
Expand All @@ -2065,7 +2065,7 @@ utils.wrapPropertyMethod(
* @method updateGuardianFactor
* @memberOf module.GuardianManager.prototype
*
* management.updateGuardianFactor({ factor: 'sms' }, {
* management.updateGuardianFactor({ name: 'sms' }, {
* enabled: true
* }, function(err, factor) {
* console.log(factor);
Expand Down
40 changes: 20 additions & 20 deletions test/management/guardian.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ describe('GuardianManager', function() {

describe('#getFactorProvider', function() {
beforeEach(function() {
this.params = { factor: 'sms', provider: 'twilio' };
this.params = { name: 'sms', provider: 'twilio' };
this.data = {
from: '+1223323',
messaging_service_sid: '5dEkAiHLPCuQ1uJj4qNXcAnERFAL6cpq',
Expand All @@ -353,7 +353,7 @@ describe('GuardianManager', function() {
};

this.request = nock(API_URL)
.get('/guardian/factors/' + this.params.factor + '/providers/' + this.params.provider)
.get('/guardian/factors/' + this.params.name + '/providers/' + this.params.provider)
.reply(200, this.data);
});

Expand Down Expand Up @@ -382,7 +382,7 @@ describe('GuardianManager', function() {
nock.cleanAll();

var request = nock(API_URL)
.get('guardian/factors/' + this.params.factor + '/providers/' + this.params.provider)
.get('guardian/factors/' + this.params.name + '/providers/' + this.params.provider)
.reply(500);

this.guardian.getFactorProvider(this.params).catch(function(err) {
Expand All @@ -396,7 +396,7 @@ describe('GuardianManager', function() {
nock.cleanAll();

var request = nock(API_URL)
.get('/guardian/factors/' + this.params.factor + '/providers/' + this.params.provider)
.get('/guardian/factors/' + this.params.name + '/providers/' + this.params.provider)
.matchHeader('Authorization', 'Bearer ' + this.token)
.reply(200);

Expand All @@ -410,7 +410,7 @@ describe('GuardianManager', function() {

describe('#updateFactorProvider', function() {
beforeEach(function() {
this.params = { factor: 'sms', provider: 'twilio' };
this.params = { name: 'sms', provider: 'twilio' };
this.data = {
from: '+1223323',
messaging_service_sid: '5dEkAiHLPCuQ1uJj4qNXcAnERFAL6cpq',
Expand All @@ -432,7 +432,7 @@ describe('GuardianManager', function() {

it('should perform a PUT request to /api/v2/guardian/factors/sms/providers/twilio', function(done) {
var request = nock(API_URL)
.put('/guardian/factors/' + this.params.factor + '/providers/' + this.params.provider)
.put('/guardian/factors/' + this.params.name + '/providers/' + this.params.provider)
.reply(200, this.data);

this.guardian.updateFactorProvider(this.params, this.data).then(function() {
Expand All @@ -446,7 +446,7 @@ describe('GuardianManager', function() {
nock.cleanAll();

var request = nock(API_URL)
.put('/guardian/factors/' + this.params.factor + '/providers/' + this.params.provider)
.put('/guardian/factors/' + this.params.name + '/providers/' + this.params.provider)
.reply(200);

this.guardian.updateFactorProvider(this.params, this.data).then(function() {
Expand All @@ -460,7 +460,7 @@ describe('GuardianManager', function() {
nock.cleanAll();

var request = nock(API_URL)
.put('/guardian/factors/' + this.params.factor + '/providers/' + this.params.provider)
.put('/guardian/factors/' + this.params.name + '/providers/' + this.params.provider)
.reply(500);

this.guardian.updateFactorProvider(this.params, this.data).catch(function(err) {
Expand All @@ -474,7 +474,7 @@ describe('GuardianManager', function() {
nock.cleanAll();

var request = nock(API_URL)
.put('/guardian/factors/' + this.params.factor + '/providers/' + this.params.provider)
.put('/guardian/factors/' + this.params.name + '/providers/' + this.params.provider)
.matchHeader('Authorization', 'Bearer ' + this.token)
.reply(200);

Expand All @@ -488,7 +488,7 @@ describe('GuardianManager', function() {

describe('#getFactorTemplates', function() {
beforeEach(function() {
this.params = { factor: 'sms' };
this.params = { name: 'sms' };

this.data = {
enrollment_message:
Expand Down Expand Up @@ -554,7 +554,7 @@ describe('GuardianManager', function() {

describe('#updateFactorTemplates', function() {
beforeEach(function() {
this.params = { factor: 'sms' };
this.params = { name: 'sms' };
this.data = {
enrollment_message:
'{{code}} is your verification code for {{tenant.friendly_name}}. Please enter this code to verify your enrollment.',
Expand All @@ -575,7 +575,7 @@ describe('GuardianManager', function() {

it('should perform a PUT request to /api/v2/guardian/factors/sms/templates', function(done) {
var request = nock(API_URL)
.put('/guardian/factors/' + this.params.factor + '/templates')
.put('/guardian/factors/' + this.params.name + '/templates')
.reply(200, this.data);

this.guardian.updateFactorTemplates(this.params, this.data).then(function() {
Expand All @@ -589,7 +589,7 @@ describe('GuardianManager', function() {
nock.cleanAll();

var request = nock(API_URL)
.put('/guardian/factors/' + this.params.factor + '/templates')
.put('/guardian/factors/' + this.params.name + '/templates')
.reply(200);

this.guardian.updateFactorTemplates(this.params, this.data).then(function() {
Expand All @@ -603,7 +603,7 @@ describe('GuardianManager', function() {
nock.cleanAll();

var request = nock(API_URL)
.put('/guardian/factors/' + this.params.factor + '/templates')
.put('/guardian/factors/' + this.params.name + '/templates')
.reply(500);

this.guardian.updateFactorTemplates(this.params, this.data).catch(function(err) {
Expand All @@ -617,7 +617,7 @@ describe('GuardianManager', function() {
nock.cleanAll();

var request = nock(API_URL)
.put('/guardian/factors/' + this.params.factor + '/templates')
.put('/guardian/factors/' + this.params.name + '/templates')
.matchHeader('Authorization', 'Bearer ' + this.token)
.reply(200);

Expand All @@ -631,7 +631,7 @@ describe('GuardianManager', function() {

describe('#updateFactor', function() {
beforeEach(function() {
this.params = { factor: 'sms' };
this.params = { name: 'sms' };
this.data = {
enabled: true
};
Expand All @@ -650,7 +650,7 @@ describe('GuardianManager', function() {

it('should perform a PUT request to /api/v2/guardian/factors/sms', function(done) {
var request = nock(API_URL)
.put('/guardian/factors/' + this.params.factor)
.put('/guardian/factors/' + this.params.name)
.reply(200, this.data);

this.guardian.updateFactor(this.params, this.data).then(function() {
Expand All @@ -664,7 +664,7 @@ describe('GuardianManager', function() {
nock.cleanAll();

var request = nock(API_URL)
.put('/guardian/factors/' + this.params.factor)
.put('/guardian/factors/' + this.params.name)
.reply(200);

this.guardian.updateFactor(this.params, this.data).then(function() {
Expand All @@ -678,7 +678,7 @@ describe('GuardianManager', function() {
nock.cleanAll();

var request = nock(API_URL)
.put('/guardian/factors/' + this.params.factor)
.put('/guardian/factors/' + this.params.name)
.reply(500);

this.guardian.updateFactor(this.params, this.data).catch(function(err) {
Expand All @@ -692,7 +692,7 @@ describe('GuardianManager', function() {
nock.cleanAll();

var request = nock(API_URL)
.put('/guardian/factors/' + this.params.factor)
.put('/guardian/factors/' + this.params.name)
.matchHeader('Authorization', 'Bearer ' + this.token)
.reply(200);

Expand Down

0 comments on commit 9d2b9a5

Please sign in to comment.