-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix issue 1770 and 1774: added tests and functionality from PR 1770, …
…fixed loadUser function
- Loading branch information
Showing
3 changed files
with
42 additions
and
14 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
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 |
---|---|---|
|
@@ -154,6 +154,39 @@ describe('PasswordResetEmailRequest', () => { | |
expect(request.error).to.not.have.been.called() | ||
}) | ||
}) | ||
|
||
it('should hande a reset request with no username without privacy leakage', () => { | ||
const host = SolidHost.from({ serverUri: 'https://example.com' }) | ||
const store = { suffixAcl: '.acl' } | ||
const accountManager = AccountManager.from({ host, multiuser: true, store }) | ||
accountManager.loadAccountRecoveryEmail = sinon.stub().resolves('[email protected]') | ||
accountManager.sendPasswordResetEmail = sinon.stub().resolves() | ||
accountManager.accountExists = sinon.stub().resolves(false) | ||
|
||
const returnToUrl = 'https://example.com/resource' | ||
const username = 'alice' | ||
const response = HttpMocks.createResponse() | ||
response.render = sinon.stub() | ||
|
||
const options = { accountManager, username, returnToUrl, response } | ||
const request = new PasswordResetEmailRequest(options) | ||
|
||
sinon.spy(request, 'error') | ||
sinon.spy(request, 'validate') | ||
sinon.spy(request, 'loadUser') | ||
|
||
return PasswordResetEmailRequest.handlePost(request) | ||
.then(() => { | ||
expect(request.validate).to.have.been.called() | ||
expect(request.loadUser).to.have.been.called() | ||
expect(request.loadUser).to.throw() | ||
}).catch(() => { | ||
expect(request.error).to.have.been.called() | ||
expect(response.render).to.have.been.calledWith('auth/reset-link-sent') | ||
expect(accountManager.loadAccountRecoveryEmail).to.not.have.been.called() | ||
expect(accountManager.sendPasswordResetEmail).to.not.have.been.called() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('loadUser()', () => { | ||
|
@@ -183,7 +216,7 @@ describe('PasswordResetEmailRequest', () => { | |
const options = { accountManager, username } | ||
const request = new PasswordResetEmailRequest(options) | ||
|
||
sinon.spy(request, 'renderSuccess') | ||
sinon.spy(request, 'resetLinkMessage') | ||
sinon.spy(accountManager, 'userAccountFrom') | ||
sinon.spy(accountManager, 'verifyEmailDependencies') | ||
|
||
|
@@ -195,7 +228,7 @@ describe('PasswordResetEmailRequest', () => { | |
done() | ||
}) | ||
.catch(() => { | ||
expect(request.renderSuccess).to.have.been.called() | ||
expect(request.resetLinkMessage).to.have.been.called() | ||
done() | ||
}) | ||
}) | ||
|