@@ -19,6 +19,7 @@ import { StoreModule } from '@ngrx/store';
1919import { provideMockStore } from '@ngrx/store/testing' ;
2020import { TranslateModule } from '@ngx-translate/core' ;
2121import { of } from 'rxjs' ;
22+ import { AuthMethodType } from 'src/app/core/auth/models/auth.method-type' ;
2223
2324import { authReducer } from '../../core/auth/auth.reducer' ;
2425import { AuthService } from '../../core/auth/auth.service' ;
@@ -140,6 +141,59 @@ describe('LogInComponent', () => {
140141 expect ( loginContainers . length ) . toBe ( 2 ) ;
141142
142143 } ) ;
144+
145+ it ( 'returns only password method when backdoor is enabled' , ( ) => {
146+ const authMethods = [
147+ { authMethodType : AuthMethodType . Password , position : 1 } ,
148+ { authMethodType : AuthMethodType . Ip , position : 2 } ,
149+ { authMethodType : AuthMethodType . Shibboleth , position : 3 } ,
150+ ] ;
151+ const isBackdoor = true ;
152+ component . excludedAuthMethod = undefined ;
153+ const result = component . filterAndSortAuthMethods ( authMethods , isBackdoor ) ;
154+ expect ( result ) . toEqual ( [ { authMethodType : AuthMethodType . Password , position : 1 } ] ) ;
155+ } ) ;
156+
157+ it ( 'excludes password method when standard login is disabled' , ( ) => {
158+ const authMethods = [
159+ { authMethodType : AuthMethodType . Password , position : 1 } ,
160+ { authMethodType : AuthMethodType . Shibboleth , position : 2 } ,
161+ ] ;
162+ component . excludedAuthMethod = undefined ;
163+ const result = component . filterAndSortAuthMethods ( authMethods , false , true ) ;
164+ expect ( result ) . toEqual ( [
165+ { authMethodType : AuthMethodType . Shibboleth , position : 2 } ,
166+ ] ) ;
167+ } ) ;
168+
169+ it ( 'excludes methods based on excludedAuthMethod input' , ( ) => {
170+ const authMethods = [
171+ { authMethodType : AuthMethodType . Password , position : 1 } ,
172+ { authMethodType : AuthMethodType . Ip , position : 2 } ,
173+ { authMethodType : AuthMethodType . Shibboleth , position : 3 } ,
174+ ] ;
175+ const isBackdoor = false ;
176+ component . excludedAuthMethod = AuthMethodType . Ip ;
177+ const result = component . filterAndSortAuthMethods ( authMethods , isBackdoor ) ;
178+ expect ( result ) . toEqual ( [
179+ { authMethodType : AuthMethodType . Password , position : 1 } ,
180+ { authMethodType : AuthMethodType . Shibboleth , position : 3 } ,
181+ ] ) ;
182+ } ) ;
183+
184+ it ( 'sorts methods by position' , ( ) => {
185+ const authMethods = [
186+ { authMethodType : AuthMethodType . Password , position : 2 } ,
187+ { authMethodType : AuthMethodType . Shibboleth , position : 1 } ,
188+ ] ;
189+ const isBackdoor = false ;
190+ component . excludedAuthMethod = undefined ;
191+ const result = component . filterAndSortAuthMethods ( authMethods , isBackdoor ) ;
192+ expect ( result ) . toEqual ( [
193+ { authMethodType : AuthMethodType . Shibboleth , position : 1 } ,
194+ { authMethodType : AuthMethodType . Password , position : 2 } ,
195+ ] ) ;
196+ } ) ;
143197 } ) ;
144198
145199} ) ;
0 commit comments