Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix PassportProfileMapper.prototype.getNameIdentifier won't return email #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/claims/PassportProfileMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ PassportProfileMapper.prototype.getNameIdentifier = function () {
return {
nameIdentifier: claims[fm.nameIdentifier] ||
claims[fm.name] ||
claims[fm.emailaddress]
claims[fm.email]
};

};
Expand Down
62 changes: 62 additions & 0 deletions test/passportprofilemapper.tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
var expect = require('chai').expect;
var PassportProfileMapper = require('../lib/claims/PassportProfileMapper')

describe('PassportProfileMapper', function () {
it('PassportProfileMapper.prototype.getNameIdentifier returns id', function() {
var profileMapper = new PassportProfileMapper({
'id': 'e9f7ac44-3f9c-488c-88a2-5b4b437749a9',
'emails': [],
'displayName': null,
'name': {
'familyName': null,
'givenName': null,
}
})
var output = profileMapper.getNameIdentifier()
expect(output.nameIdentifier).to.eql('e9f7ac44-3f9c-488c-88a2-5b4b437749a9')
})

it('PassportProfileMapper.prototype.getNameIdentifier returns name', function() {
var profileMapper = new PassportProfileMapper({
'id': null,
'emails': [],
'displayName': 'Curious George',
'name': {
'familyName': null,
'givenName': null,
}
})
var output = profileMapper.getNameIdentifier()
expect(output.nameIdentifier).to.eql('Curious George')
})

it('PassportProfileMapper.prototype.getNameIdentifier returns emails', function() {
var profileMapper = new PassportProfileMapper({
'id': null,
'emails': [{
'value': '[email protected]'
}],
'displayName': null,
'name': {
'familyName': null,
'givenName': null,
}
})
var output = profileMapper.getNameIdentifier()
expect(output.nameIdentifier).to.eql('[email protected]')
})

it('PassportProfileMapper.prototype.getNameIdentifier returns undefined', function() {
var profileMapper = new PassportProfileMapper({
'id': null,
'emails': [],
'displayName': null,
'name': {
'familyName': 'Curious George',
'givenName': 'George',
}
})
var output = profileMapper.getNameIdentifier()
expect(output.nameIdentifier).to.eql(undefined)
})
})
Loading