-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow passing
loginHint
option to ensureAuthenticated
- Loading branch information
1 parent
23bba66
commit 78b184c
Showing
5 changed files
with
96 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"env": { | ||
"node": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 2018 | ||
} | ||
} |
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
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,44 @@ | ||
const connectUtil = require('../../src/connectUtil.js'); | ||
|
||
jest.mock('csurf', function () { | ||
return function () { | ||
|
||
} | ||
}); | ||
|
||
var mockAuthenticate; | ||
jest.mock('passport', function () { | ||
mockAuthenticate = jest.fn().mockReturnValue(() => {}) | ||
return { | ||
authenticate: mockAuthenticate | ||
} | ||
}) | ||
|
||
|
||
|
||
describe('connectUtil', function () { | ||
describe('createLoginHandler', function () { | ||
it('passes known options to passport handler initializer', function () { | ||
const loginHandler = connectUtil.createLoginHandler({ | ||
options: { | ||
routes: { | ||
login: { | ||
} | ||
} | ||
} | ||
}); | ||
const res = {}; | ||
const req = { | ||
query: { | ||
login_hint: 'username@org.org', | ||
chown_base: true | ||
} | ||
}; | ||
|
||
loginHandler(req, res); | ||
expect(mockAuthenticate).toBeCalledWith('oidc', { | ||
login_hint: 'username@org.org' | ||
}); | ||
}); | ||
}); | ||
}); |
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