2013-09-14 01:19:02 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
2015-03-07 21:48:23 +00:00
|
|
|
// @TODO translations aren't loading
|
|
|
|
|
|
|
|
|
|
xdescribe('Auth Controller', function() {
|
2013-09-14 01:19:02 +00:00
|
|
|
|
|
|
|
|
describe('AuthCtrl', function(){
|
2013-10-02 02:20:10 +00:00
|
|
|
var scope, ctrl, user, $httpBackend, $window;
|
2013-09-14 01:19:02 +00:00
|
|
|
|
|
|
|
|
beforeEach(inject(function(_$httpBackend_, $rootScope, $controller) {
|
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
|
scope = $rootScope.$new();
|
2015-03-07 21:48:23 +00:00
|
|
|
scope.loginUsername = 'user';
|
|
|
|
|
scope.loginPassword = 'pass';
|
2013-10-02 02:20:10 +00:00
|
|
|
$window = { location: { href: ""}, alert: sinon.spy() };
|
|
|
|
|
user = { user: {}, authenticate: sinon.spy() };
|
2013-09-14 01:19:02 +00:00
|
|
|
|
2013-10-02 02:20:10 +00:00
|
|
|
ctrl = $controller('AuthCtrl', {$scope: scope, $window: $window, User: user});
|
|
|
|
|
}));
|
2013-09-14 01:19:02 +00:00
|
|
|
|
|
|
|
|
it('should log in users with correct uname / pass', function() {
|
2013-12-24 01:38:15 +00:00
|
|
|
$httpBackend.expectPOST('/api/v2/user/auth/local').respond({id: 'abc', token: 'abc'});
|
2013-10-02 02:20:10 +00:00
|
|
|
scope.auth();
|
|
|
|
|
$httpBackend.flush();
|
2014-01-04 02:28:43 +00:00
|
|
|
sinon.assert.calledOnce(user.authenticate);
|
|
|
|
|
sinon.assert.notCalled($window.alert);
|
2013-10-02 02:20:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should not log in users with incorrect uname / pass', function() {
|
2013-12-24 01:38:15 +00:00
|
|
|
$httpBackend.expectPOST('/api/v2/user/auth/local').respond(404, '');
|
2013-10-02 02:20:10 +00:00
|
|
|
scope.auth();
|
|
|
|
|
$httpBackend.flush();
|
2014-01-04 02:28:43 +00:00
|
|
|
sinon.assert.notCalled(user.authenticate);
|
|
|
|
|
sinon.assert.calledOnce($window.alert);
|
2013-09-14 01:19:02 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2014-01-12 23:00:47 +00:00
|
|
|
});
|