-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33453 from owncloud/stable10-newuserform-showpoli…
…cyerrors [stable10] Display error message in new password form
- Loading branch information
Showing
5 changed files
with
133 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (c) 2018 Sujith Haridasan <[email protected]> | ||
* | ||
* This file is licensed under the Affero General Public License version 3 | ||
* or later. | ||
* | ||
* See the COPYING-README file. | ||
* | ||
*/ | ||
|
||
describe('OCA.UserManagement.SetPassword tests', function () { | ||
var resultSpy, SetPassword, redirectURL; | ||
beforeEach(function () { | ||
$('#testArea').append( | ||
'<label id="error-message" class="warning" style="display:none"></label>' + | ||
'<form id="set-password" method="post">\n' + | ||
'<fieldset>' + | ||
'<p>' + | ||
'<label for="password" class="infield">New password</label>' + | ||
'<input type="password" name="password" id="password" value=""' + | ||
'placeholder="New Password"' + | ||
'autocomplete="off" autocapitalize="off" autocorrect="off"' + | ||
'required autofocus />' + | ||
'</p>' + | ||
'<input type="submit" id="submit" value="Please set your password"' + | ||
'</fieldset>' + | ||
'</form>' | ||
); | ||
}); | ||
|
||
describe('set newpassword', function () { | ||
beforeEach(function () { | ||
SetPassword = OCA.UserManagement.SetPassword; | ||
redirectURL = sinon.stub(OC, 'redirect'); | ||
}); | ||
afterEach(function () { | ||
resultSpy.restore(); | ||
redirectURL.restore(); | ||
}); | ||
|
||
it('set password failed', function () { | ||
resultSpy = sinon.spy(SetPassword, '_onSetPasswordFail'); | ||
var defr = $.Deferred(); | ||
defr.reject({'responseText' : '{"foo":"bar", "message": false}'}); | ||
|
||
spyOn($, 'post').and.returnValue(defr.promise()); | ||
|
||
SetPassword.init(); | ||
$('#password').val('foo'); | ||
$('#submit').click(); | ||
|
||
expect(resultSpy.calledOnce).toEqual(true); | ||
expect($('#submit').prop('disabled')).toEqual(false); | ||
expect($('#error-message').text()).toEqual('Failed to set password. Please contact your administrator.'); | ||
}); | ||
|
||
it('set password success', function () { | ||
resultSpy = sinon.spy(SetPassword, '_resetDone'); | ||
var defr = $.Deferred(); | ||
defr.resolve({'status' : 'success'}); | ||
|
||
spyOn($, 'post').and.returnValue(defr.done()); | ||
|
||
SetPassword.init(); | ||
$('#password').val('foo'); | ||
$('#submit').click(); | ||
|
||
expect(resultSpy.calledOnce).toEqual(true); | ||
expect(redirectURL.calledOnce).toEqual(true); | ||
expect(redirectURL.getCall(0).args[0]).toContain('/owncloud'); | ||
}); | ||
}); | ||
}); |
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