@@ -23,7 +23,7 @@ describe('Unit | Identity Access Management | Domain | UseCase | reconcile-oidc-
23
23
24
24
beforeEach ( function ( ) {
25
25
identityProvider = 'genericOidcProviderCode' ;
26
- authenticationMethodRepository = { create : sinon . stub ( ) } ;
26
+ authenticationMethodRepository = { create : sinon . stub ( ) , updateLastLoggedAtByIdentityProvider : sinon . stub ( ) } ;
27
27
userLoginRepository = {
28
28
updateLastLoggedAt : sinon . stub ( ) ,
29
29
} ;
@@ -156,7 +156,7 @@ describe('Unit | Identity Access Management | Domain | UseCase | reconcile-oidc-
156
156
) ;
157
157
} ) ;
158
158
159
- it ( 'saves the last user application connection' , async function ( ) {
159
+ it ( 'saves the last user connection' , async function ( ) {
160
160
// given
161
161
const sessionContent = { idToken : 'idToken' } ;
162
162
const externalIdentifier = 'external_id' ;
@@ -192,6 +192,11 @@ describe('Unit | Identity Access Management | Domain | UseCase | reconcile-oidc-
192
192
application : 'app' ,
193
193
lastLoggedAt : sinon . match . instanceOf ( Date ) ,
194
194
} ) ;
195
+
196
+ expect ( authenticationMethodRepository . updateLastLoggedAtByIdentityProvider ) . to . be . calledWithExactly ( {
197
+ userId,
198
+ identityProvider,
199
+ } ) ;
195
200
} ) ;
196
201
} ) ;
197
202
@@ -206,7 +211,7 @@ describe('Unit | Identity Access Management | Domain | UseCase | reconcile-oidc-
206
211
207
212
beforeEach ( function ( ) {
208
213
identityProvider = POLE_EMPLOI . code ;
209
- authenticationMethodRepository = { create : sinon . stub ( ) } ;
214
+ authenticationMethodRepository = { create : sinon . stub ( ) , updateLastLoggedAtByIdentityProvider : sinon . stub ( ) } ;
210
215
userLoginRepository = {
211
216
updateLastLoggedAt : sinon . stub ( ) ,
212
217
} ;
@@ -303,13 +308,22 @@ describe('Unit | Identity Access Management | Domain | UseCase | reconcile-oidc-
303
308
} ) ;
304
309
305
310
// then
306
- sinon . assert . calledOnce ( oidcAuthenticationService . createAccessToken ) ;
307
- sinon . assert . calledOnce ( oidcAuthenticationService . saveIdToken ) ;
308
- sinon . assert . calledOnceWithExactly ( userLoginRepository . updateLastLoggedAt , { userId } ) ;
311
+ expect ( oidcAuthenticationService . createAccessToken ) . to . be . calledOnce ;
312
+ expect ( oidcAuthenticationService . saveIdToken ) . to . be . calledOnce ;
313
+ expect ( userLoginRepository . updateLastLoggedAt ) . to . have . been . calledWithExactly ( { userId } ) ;
309
314
expect ( result ) . to . deep . equal ( {
310
315
accessToken : 'accessToken' ,
311
316
logoutUrlUUID : 'logoutUrlUUID' ,
312
317
} ) ;
318
+ expect ( lastUserApplicationConnectionsRepository . upsert ) . to . be . calledWithExactly ( {
319
+ userId,
320
+ application : 'app' ,
321
+ lastLoggedAt : sinon . match . instanceOf ( Date ) ,
322
+ } ) ;
323
+ expect ( authenticationMethodRepository . updateLastLoggedAtByIdentityProvider ) . to . be . calledWithExactly ( {
324
+ userId,
325
+ identityProvider : oidcAuthenticationService . identityProvider ,
326
+ } ) ;
313
327
} ) ;
314
328
} ) ;
315
329
} ) ;
0 commit comments