Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
anis
anis-client
Commits
8a3c8b1b
Commit
8a3c8b1b
authored
Nov 10, 2020
by
Tifenn Guillas
Browse files
Add header comments => DONE, Add auth tests => DONE
parent
621c2ceb
Changes
18
Hide whitespace changes
Inline
Side-by-side
src/app/app.module.ts
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import
{
NgModule
}
from
'
@angular/core
'
;
import
{
BrowserModule
}
from
'
@angular/platform-browser
'
;
import
{
BrowserAnimationsModule
}
from
'
@angular/platform-browser/animations
'
;
...
...
src/app/auth/auth.module.ts
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import
{
NgModule
}
from
'
@angular/core
'
;
import
{
KeycloakAngularModule
}
from
'
keycloak-angular
'
;
...
...
src/app/auth/init.keycloak.ts
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import
{
APP_INITIALIZER
}
from
'
@angular/core
'
;
import
{
from
}
from
'
rxjs
'
;
import
{
KeycloakService
,
KeycloakEventType
}
from
'
keycloak-angular
'
;
import
{
Store
}
from
'
@ngrx/store
'
;
import
{
from
}
from
'
rxjs
'
;
import
{
KeycloakService
,
KeycloakEventType
}
from
'
keycloak-angular
'
;
import
*
as
keycloakActions
from
'
./store/auth.action
'
;
import
*
as
fromKeycloak
from
'
./store/auth.reducer
'
;
...
...
src/app/auth/store/auth.action.spec.ts
0 → 100644
View file @
8a3c8b1b
import
*
as
authActions
from
'
./auth.action
'
;
import
{
UserProfile
}
from
'
./user-profile.model
'
;
describe
(
'
[Auth] Action
'
,
()
=>
{
it
(
'
should create LoginAction
'
,
()
=>
{
const
action
=
new
authActions
.
LoginAction
();
expect
(
action
.
type
).
toEqual
(
authActions
.
LOGIN
);
});
it
(
'
should create LogoutAction
'
,
()
=>
{
const
action
=
new
authActions
.
LogoutAction
();
expect
(
action
.
type
).
toEqual
(
authActions
.
LOGOUT
);
});
it
(
'
should create AuthSuccessAction
'
,
()
=>
{
const
action
=
new
authActions
.
AuthSuccessAction
();
expect
(
action
.
type
).
toEqual
(
authActions
.
AUTH_SUCCESS
);
});
it
(
'
should create LoadUserProfileSuccessAction
'
,
()
=>
{
const
userProfile
:
UserProfile
=
{
id
:
'
toto@mail.com
'
,
username
:
'
toto
'
};
const
action
=
new
authActions
.
LoadUserProfileSuccessAction
(
userProfile
);
expect
(
action
.
type
).
toEqual
(
authActions
.
LOAD_USER_PROFILE_SUCCESS
);
expect
(
action
.
payload
).
toEqual
(
userProfile
);
});
it
(
'
should create OpenEditProfileAction
'
,
()
=>
{
const
action
=
new
authActions
.
OpenEditProfileAction
();
expect
(
action
.
type
).
toEqual
(
authActions
.
OPEN_EDIT_PROFILE
);
});
});
src/app/auth/store/auth.action.ts
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import
{
Action
}
from
'
@ngrx/store
'
;
import
{
UserProfile
}
from
'
./user-profile.model
'
;
...
...
src/app/auth/store/auth.effects.ts
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
from
}
from
'
rxjs
'
;
import
{
switchMap
,
map
,
tap
}
from
'
rxjs/operators
'
;
...
...
src/app/auth/store/auth.reducer.spec.ts
0 → 100644
View file @
8a3c8b1b
import
*
as
fromAuth
from
'
./auth.reducer
'
;
import
*
as
authActions
from
'
./auth.action
'
;
import
{
UserProfile
}
from
'
./user-profile.model
'
;
describe
(
'
[Auth] Reducer
'
,
()
=>
{
it
(
'
should return init state
'
,
()
=>
{
const
{
initialState
}
=
fromAuth
;
const
action
=
{}
as
authActions
.
Actions
;
const
state
=
fromAuth
.
reducer
(
undefined
,
action
);
expect
(
state
).
toBe
(
initialState
);
});
it
(
'
should set isAuthenticated to true
'
,
()
=>
{
const
{
initialState
}
=
fromAuth
;
const
action
=
new
authActions
.
AuthSuccessAction
();
const
state
=
fromAuth
.
reducer
(
initialState
,
action
);
expect
(
state
.
isAuthenticated
).
toBeTruthy
();
expect
(
state
.
userProfile
).
toBeNull
();
expect
(
state
).
not
.
toEqual
(
initialState
);
});
it
(
'
should set userProfile
'
,
()
=>
{
const
userProfile
:
UserProfile
=
{
id
:
'
toto@mail.com
'
,
username
:
'
toto
'
};
const
{
initialState
}
=
fromAuth
;
const
action
=
new
authActions
.
LoadUserProfileSuccessAction
(
userProfile
);
const
state
=
fromAuth
.
reducer
(
initialState
,
action
);
expect
(
state
.
isAuthenticated
).
toBeFalsy
();
expect
(
state
.
userProfile
).
toEqual
(
userProfile
);
expect
(
state
).
not
.
toEqual
(
initialState
);
});
it
(
'
should get isAuthenticated
'
,
()
=>
{
const
action
=
{}
as
authActions
.
Actions
;
const
state
=
fromAuth
.
reducer
(
undefined
,
action
);
expect
(
fromAuth
.
isAuthenticated
(
state
)).
toBeFalsy
();
});
it
(
'
should get userProfile
'
,
()
=>
{
const
action
=
{}
as
authActions
.
Actions
;
const
state
=
fromAuth
.
reducer
(
undefined
,
action
);
expect
(
fromAuth
.
getUserProfile
(
state
)).
toBeNull
();
});
});
src/app/auth/store/auth.reducer.ts
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import
*
as
actions
from
'
./auth.action
'
;
import
{
UserProfile
}
from
'
./user-profile.model
'
;
export
interface
State
{
isAuthenticated
:
boolean
;
userProfile
:
any
;
userProfile
:
UserProfile
;
}
export
const
initialState
:
State
=
{
...
...
@@ -19,11 +29,9 @@ export function reducer(state: State = initialState, action: actions.Actions): S
};
case
actions
.
LOAD_USER_PROFILE_SUCCESS
:
const
userProfile
=
action
.
payload
;
return
{
...
state
,
userProfile
userProfile
:
action
.
payload
}
default
:
...
...
src/app/auth/store/auth.selector.spec.ts
0 → 100644
View file @
8a3c8b1b
import
*
as
authSelector
from
'
./auth.selector
'
;
import
*
as
fromAuth
from
'
./auth.reducer
'
;
describe
(
'
[Auth] Selector
'
,
()
=>
{
it
(
'
should get isAuthenticated
'
,
()
=>
{
const
state
=
{
auth
:
{
...
fromAuth
.
initialState
}};
expect
(
authSelector
.
isAuthenticated
(
state
)).
toBeFalsy
();
});
it
(
'
should get userProfile
'
,
()
=>
{
const
state
=
{
auth
:
{
...
fromAuth
.
initialState
}};
expect
(
authSelector
.
getUserProfile
(
state
)).
toBeNull
();
});
});
\ No newline at end of file
src/app/auth/store/auth.selector.ts
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import
{
createSelector
,
createFeatureSelector
}
from
'
@ngrx/store
'
;
import
*
as
auth
from
'
./auth.reducer
'
;
...
...
src/app/auth/store/user-profile.model.ts
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
export
interface
UserProfile
{
id
?:
string
;
username
?:
string
;
...
...
src/app/core/components/nav.component.css
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
.dropdown-up
{
top
:
80%
!important
;
right
:
5px
!important
;
...
...
src/app/core/components/nav.component.ts
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import
{
Component
,
Input
,
Output
,
EventEmitter
,
ChangeDetectionStrategy
}
from
'
@angular/core
'
;
import
{
Instance
}
from
'
../../metamodel/model
'
;
...
...
src/app/core/containers/app.component.css
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
main
{
margin-top
:
100px
;
}
\ No newline at end of file
src/app/core/containers/app.component.ts
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import
{
Component
,
ViewEncapsulation
,
OnInit
}
from
'
@angular/core
'
;
import
{
Store
}
from
'
@ngrx/store
'
;
...
...
src/app/search/containers/dataset.component.ts
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
Store
}
from
'
@ngrx/store
'
;
...
...
src/app/static/static.module.ts
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import
{
NgModule
}
from
'
@angular/core
'
;
import
{
SharedModule
}
from
'
../shared/shared.module
'
;
...
...
src/environments/environment.ts
View file @
8a3c8b1b
/*
* This file is part of Anis Client.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment