|
@@ -10,6 +10,9 @@ module('Acceptance: ForgottenPassword', {
|
|
|
},
|
|
|
|
|
|
afterEach: function() {
|
|
|
+ Ember.$('#hidden-login-form').off('submit.stopInTest');
|
|
|
+ Ember.$('#loginModal').off();
|
|
|
+ Ember.$('body').removeClass('modal-open');
|
|
|
Ember.run(application, 'destroy');
|
|
|
Ember.$.mockjax.clear();
|
|
|
}
|
|
@@ -38,7 +41,7 @@ test('request password change link without entering e-mail', function(assert) {
|
|
|
test('request password change link with invalid e-mail', function(assert) {
|
|
|
var message = 'Entered e-mail is invalid.';
|
|
|
Ember.$.mockjax({
|
|
|
- url: "/api/change-password/send-link/",
|
|
|
+ url: '/api/change-password/send-link/',
|
|
|
status: 400,
|
|
|
responseText: {
|
|
|
'detail': message,
|
|
@@ -61,7 +64,7 @@ test('request password change link with invalid e-mail', function(assert) {
|
|
|
test('request password change link with non-existing e-mail', function(assert) {
|
|
|
var message = 'No user with this e-mail exists.';
|
|
|
Ember.$.mockjax({
|
|
|
- url: "/api/change-password/send-link/",
|
|
|
+ url: '/api/change-password/send-link/',
|
|
|
status: 400,
|
|
|
responseText: {
|
|
|
'detail': message,
|
|
@@ -84,7 +87,7 @@ test('request password change link with non-existing e-mail', function(assert) {
|
|
|
test('request password change link with user-activated account', function(assert) {
|
|
|
var message = 'You have to activate your account before you will be able to sign in.';
|
|
|
Ember.$.mockjax({
|
|
|
- url: "/api/change-password/send-link/",
|
|
|
+ url: '/api/change-password/send-link/',
|
|
|
status: 400,
|
|
|
responseText: {
|
|
|
'detail': message,
|
|
@@ -107,7 +110,7 @@ test('request password change link with user-activated account', function(assert
|
|
|
test('request password change link with admin-activated account', function(assert) {
|
|
|
var message = 'Your account has to be activated by Administrator before you will be able to sign in.';
|
|
|
Ember.$.mockjax({
|
|
|
- url: "/api/change-password/send-link/",
|
|
|
+ url: '/api/change-password/send-link/',
|
|
|
status: 400,
|
|
|
responseText: {
|
|
|
'detail': message,
|
|
@@ -130,7 +133,7 @@ test('request password change link with admin-activated account', function(asser
|
|
|
test('request password change link with banned account', function(assert) {
|
|
|
var done = assert.async();
|
|
|
Ember.$.mockjax({
|
|
|
- url: "/api/change-password/send-link/",
|
|
|
+ url: '/api/change-password/send-link/',
|
|
|
status: 400,
|
|
|
responseText: {
|
|
|
'detail': {
|
|
@@ -162,7 +165,7 @@ test('request password change link with banned account', function(assert) {
|
|
|
test('request password change link', function(assert) {
|
|
|
var done = assert.async();
|
|
|
Ember.$.mockjax({
|
|
|
- url: "/api/change-password/send-link/",
|
|
|
+ url: '/api/change-password/send-link/',
|
|
|
status: 200,
|
|
|
responseText: {
|
|
|
'username': 'BobBoberson',
|
|
@@ -181,3 +184,145 @@ test('request password change link', function(assert) {
|
|
|
done();
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+test('invalid token is handled', function(assert) {
|
|
|
+ var message = 'Token was rejected.';
|
|
|
+ Ember.$.mockjax({
|
|
|
+ url: '/api/change-password/1/token/validate-token/',
|
|
|
+ status: 404,
|
|
|
+ responseText: {
|
|
|
+ 'detail': message
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ visit('/forgotten-password/1/token/');
|
|
|
+
|
|
|
+ andThen(function() {
|
|
|
+ assert.equal(currentPath(), 'forgotten-password.index');
|
|
|
+
|
|
|
+ var errorMessage = Ember.$.trim(find('.flash-message>p').text());
|
|
|
+ assert.equal(errorMessage, message);
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+test('permission denied is handled', function(assert) {
|
|
|
+ var message = 'Token was rejected.';
|
|
|
+ Ember.$.mockjax({
|
|
|
+ url: '/api/change-password/1/token/validate-token/',
|
|
|
+ status: 403,
|
|
|
+ responseText: {
|
|
|
+ 'detail': message
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ visit('/forgotten-password/1/token/');
|
|
|
+
|
|
|
+ andThen(function() {
|
|
|
+ assert.equal(currentPath(), 'error-403');
|
|
|
+
|
|
|
+ var errorMessage = Ember.$.trim(find('.lead').text());
|
|
|
+ assert.equal(errorMessage, message);
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+test('token is validated', function(assert) {
|
|
|
+ Ember.$.mockjax({
|
|
|
+ url: '/api/change-password/1/token/validate-token/',
|
|
|
+ status: 200,
|
|
|
+ responseText: {
|
|
|
+ 'user_id': 1,
|
|
|
+ 'token': 'token',
|
|
|
+ 'change_password_url': '/api/change-password-url/'
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ visit('/forgotten-password/1/token/');
|
|
|
+
|
|
|
+ andThen(function() {
|
|
|
+ assert.equal(currentPath(), 'forgotten-password.change-form');
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+test('no new password is entered', function(assert) {
|
|
|
+ Ember.$.mockjax({
|
|
|
+ url: '/api/change-password/1/token/validate-token/',
|
|
|
+ status: 200,
|
|
|
+ responseText: {
|
|
|
+ 'user_id': 1,
|
|
|
+ 'token': 'token',
|
|
|
+ 'change_password_url': '/api/change-password-url/'
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ visit('/forgotten-password/1/token/');
|
|
|
+ click('.forgotten-password-page form .btn-primary');
|
|
|
+
|
|
|
+ andThen(function() {
|
|
|
+ assert.equal(currentPath(), 'forgotten-password.change-form');
|
|
|
+
|
|
|
+ var error = Ember.$.trim(find('.flash-message p').text());
|
|
|
+ assert.equal(error, 'Enter new password.');
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+test('new password is invalid', function(assert) {
|
|
|
+ Ember.$.mockjax({
|
|
|
+ url: '/api/change-password/1/token/validate-token/',
|
|
|
+ status: 200,
|
|
|
+ responseText: {
|
|
|
+ 'user_id': 1,
|
|
|
+ 'token': 'token',
|
|
|
+ 'change_password_url': '/api/change-password-url/'
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ var message = 'Entered password is not allowed.';
|
|
|
+ Ember.$.mockjax({
|
|
|
+ url: '/api/change-password-url/',
|
|
|
+ status: 400,
|
|
|
+ responseText: {
|
|
|
+ 'detail': message
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ visit('/forgotten-password/1/token/');
|
|
|
+ fillIn('.forgotten-password-page form .control-input input', 'newp4ssw0rd');
|
|
|
+ click('.forgotten-password-page form .btn-primary');
|
|
|
+
|
|
|
+ andThen(function() {
|
|
|
+ assert.equal(currentPath(), 'forgotten-password.change-form');
|
|
|
+
|
|
|
+ var error = Ember.$.trim(find('.flash-message p').text());
|
|
|
+ assert.equal(error, message);
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+test('new password is accepted', function(assert) {
|
|
|
+ Ember.$.mockjax({
|
|
|
+ url: '/api/change-password/1/token/validate-token/',
|
|
|
+ status: 200,
|
|
|
+ responseText: {
|
|
|
+ 'user_id': 1,
|
|
|
+ 'token': 'token',
|
|
|
+ 'change_password_url': '/api/change-password-url/'
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ var message = 'lul';
|
|
|
+ Ember.$.mockjax({
|
|
|
+ url: '/api/change-password-url/',
|
|
|
+ status: 200
|
|
|
+ });
|
|
|
+
|
|
|
+ visit('/forgotten-password/1/token/');
|
|
|
+ fillIn('.forgotten-password-page form .control-input input', 'newp4ssw0rd');
|
|
|
+ click('.forgotten-password-page form .btn-primary');
|
|
|
+
|
|
|
+ andThen(function() {
|
|
|
+ assert.equal(currentPath(), 'forgotten-password.change-form');
|
|
|
+ assert.ok(find('#loginModal').hasClass('in'));
|
|
|
+
|
|
|
+ var message = Ember.$.trim(find('.flash-message p').text());
|
|
|
+ assert.equal(message, "Your password has been changed.");
|
|
|
+ });
|
|
|
+});
|