From 88b69fcc086a4fb1dd077797c81e8e483c4e6f68 Mon Sep 17 00:00:00 2001 From: Maxime Millette-Coulombe Date: Thu, 4 Jun 2015 11:14:11 -0400 Subject: [PATCH] Increase test coverage: Add unit test to the authentication module part 1 I found that the angularjs cookies module was obtained somehow be another module. This module is not used. Change-Id: I853418f4d276de7ba7556f47ccf16f6409c322d7 Signed-off-by: Maxime Millette-Coulombe --- .../authentification/auth.services.js | 2 +- .../resources/authentification/auth.spec.js | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 modules/common-authentication-resources/src/main/resources/authentification/auth.spec.js diff --git a/modules/common-authentication-resources/src/main/resources/authentification/auth.services.js b/modules/common-authentication-resources/src/main/resources/authentification/auth.services.js index fa02910a..14c2ecc4 100644 --- a/modules/common-authentication-resources/src/main/resources/authentification/auth.services.js +++ b/modules/common-authentication-resources/src/main/resources/authentification/auth.services.js @@ -8,7 +8,7 @@ define(['common/authentification/auth.module'], function(auth) { - auth.factory('Auth', function($http, $window, $cookieStore, Base64, ENV){ + auth.factory('Auth', function($http, $window, Base64, ENV){ var factory = {}; // Set Authorization header to username + password factory.setBasic = function(user, pw) { diff --git a/modules/common-authentication-resources/src/main/resources/authentification/auth.spec.js b/modules/common-authentication-resources/src/main/resources/authentification/auth.spec.js new file mode 100644 index 00000000..548fb907 --- /dev/null +++ b/modules/common-authentication-resources/src/main/resources/authentification/auth.spec.js @@ -0,0 +1,21 @@ +define(['common/authentification/auth.services'], function() { + describe('Auth Module', function() { + var _Auth; + beforeEach(module('app.common.auth')); + + beforeEach(inject(function($injector) { + _Auth = $injector.get('Auth'); + })); + + it('Should have defined function facilate the authentication process', function() { + expect(_Auth.setBasic).toBeDefined(); + expect(_Auth.unsetBasic).toBeDefined(); + expect(_Auth.getUser).toBeDefined(); + expect(_Auth.authorize).toBeDefined(); + expect(_Auth.isAuthed).toBeDefined(); + expect(_Auth.isLoggedIn).toBeDefined(); + expect(_Auth.login).toBeDefined(); + expect(_Auth.logout).toBeDefined(); + }); + }); +}); -- 2.36.6