This repository has been archived by the owner on Dec 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Need to use underscores for namespacing * Need to convert from flattened keys when constructing accounts * Need to preserve arrays
- Loading branch information
Robert Damphousse
committed
Jun 27, 2017
1 parent
95073a2
commit bb4b28d
Showing
2 changed files
with
123 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
'use strict'; | ||
|
||
var Account = require('../../lib/resource/Account'); | ||
var common = require('../common'); | ||
var assert = common.assert; | ||
|
||
|
||
describe('Account', function () { | ||
describe('.tranformOktaUser', function () { | ||
it('should map profile data onto custom data', function () { | ||
// toOktaUser is ran when new Accounts are constructed | ||
var account = new Account({ | ||
profile: { | ||
prop_a: '1', | ||
nested_property_foo: 'bar' | ||
}, | ||
_links: {} | ||
}); | ||
|
||
assert.deepEqual(account.customData, { | ||
prop: { | ||
a: '1' | ||
}, | ||
nested: { | ||
property: { | ||
foo: 'bar' | ||
} | ||
} | ||
}); | ||
|
||
}); | ||
}); | ||
describe('.toOktaUser()', function () { | ||
it('should map custom data onto okta profile data properties', function () { | ||
var account = new Account({ | ||
_links: {}, | ||
profile: {} | ||
}); | ||
account.customData.things = [1, 2, 3]; | ||
account.customData.simple = 'bar'; | ||
account.customData.prop = { | ||
a: '1' | ||
}; | ||
account.customData.nested = { | ||
property: { | ||
foo: 'bar' | ||
}, | ||
things2: ['a', 'b', 'c'] | ||
}; | ||
var oktaUser = account.toOktaUser(); | ||
assert.deepEqual(oktaUser.profile, { | ||
things: [1, 2, 3], | ||
simple: 'bar', | ||
prop_a: '1', | ||
nested_property_foo: 'bar', | ||
nested_things2: ['a', 'b', 'c'] | ||
}); | ||
}); | ||
}); | ||
describe('.toOktaUser({customDataStrategy: stringify})', function () { | ||
it('should map custom data onto okta profile data as a JSON string', function () { | ||
var account = new Account({ | ||
_links: {}, | ||
profile: {} | ||
}); | ||
account.customData.simple = 'bar'; | ||
account.customData.prop = { | ||
a: '1' | ||
}; | ||
account.customData.nested = { | ||
property: { | ||
foo: 'bar' | ||
}, | ||
things2: ['a', 'b', 'c'] | ||
}; | ||
var oktaUser = account.toOktaUser({ customDataStrategy: 'serialize' }); | ||
assert.equal(oktaUser.profile.customData, JSON.stringify(account.customData)); | ||
}); | ||
}); | ||
}); |