[ARVADOS-WORKBENCH2] updated: 5320327aa99710bb1cd1ce090fcb8e2b1d6de0da

Git user git at public.curoverse.com
Wed Jun 6 13:46:43 EDT 2018


Summary of changes:
 src/store/auth/auth-reducer.test.ts | 35 +++++++++++++++++++++++++++++++++++
 src/store/auth/auth-reducer.ts      |  2 +-
 2 files changed, 36 insertions(+), 1 deletion(-)

       via  5320327aa99710bb1cd1ce090fcb8e2b1d6de0da (commit)
      from  49102c744e277370da62c279d25563d633295cc2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 5320327aa99710bb1cd1ce090fcb8e2b1d6de0da
Author: Daniel Kos <daniel.kos at contractors.roche.com>
Date:   Wed Jun 6 19:46:40 2018 +0200

    Add login/logout tests
    
    Feature #13563
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos at contractors.roche.com>:

diff --git a/src/store/auth/auth-reducer.test.ts b/src/store/auth/auth-reducer.test.ts
index 3d60c4f..9290f57 100644
--- a/src/store/auth/auth-reducer.test.ts
+++ b/src/store/auth/auth-reducer.test.ts
@@ -10,6 +10,7 @@ import {
     USER_FIRST_NAME_KEY,
     USER_LAST_NAME_KEY
 } from "../../services/auth-service/auth-service";
+import { API_HOST } from "../../common/server-api";
 
 require('jest-localstorage-mock');
 
@@ -80,4 +81,38 @@ describe('auth-reducer', () => {
 
         expect(localStorage.getItem(API_TOKEN_KEY)).toBe("token");
     });
+
+    it('should fire external url to login', () => {
+        const initialState = undefined;
+
+        const location = {
+            href: 'http://localhost:3000',
+            protocol: 'http:',
+            host: 'localhost:3000'
+        };
+
+        global['window'] = { location };
+
+        authReducer(initialState, actions.LOGIN());
+        expect(window.location.href).toBe(
+            `${API_HOST}/login?return_to=${location.protocol}//${location.host}/token`
+        );
+    });
+
+    it('should fire external url to logout', () => {
+        const initialState = undefined;
+
+        const location = {
+            href: 'http://localhost:3000',
+            protocol: 'http:',
+            host: 'localhost:3000'
+        };
+
+        global['window'] = { location };
+
+        authReducer(initialState, actions.LOGOUT());
+        expect(window.location.href).toBe(
+            `${API_HOST}/logout?return_to=${location.protocol}//${location.host}`
+        );
+    });
 });
diff --git a/src/store/auth/auth-reducer.ts b/src/store/auth/auth-reducer.ts
index 730312f..c5a4856 100644
--- a/src/store/auth/auth-reducer.ts
+++ b/src/store/auth/auth-reducer.ts
@@ -22,7 +22,7 @@ const authReducer = (state: AuthState = {}, action: AuthAction) => {
         INIT: () => {
             const user = authService.getUser();
             const token = authService.getApiToken();
-            return { user, apiToken: token };
+            return {user, apiToken: token};
         },
         LOGIN: () => {
             authService.login();

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list