@@ -263,11 +263,24 @@ func TestDriverDefault_Hooks(t *testing.T) {
263
263
{
264
264
uc : "Only session hook configured for password strategy" ,
265
265
config : map [string ]any {
266
- config .ViperKeySelfServiceVerificationEnabled : true ,
267
266
config .ViperKeySelfServiceRegistrationAfter + ".password.hooks" : []map [string ]any {
268
267
{"hook" : "session" },
269
268
},
270
269
},
270
+ expect : func (reg * driver.RegistryDefault ) []registration.PostHookPostPersistExecutor {
271
+ return []registration.PostHookPostPersistExecutor {
272
+ hook .NewSessionIssuer (reg ),
273
+ }
274
+ },
275
+ },
276
+ {
277
+ uc : "Session hook and verification hook configured for password strategy" ,
278
+ config : map [string ]any {
279
+ config .ViperKeySelfServiceRegistrationAfter + ".password.hooks" : []map [string ]any {
280
+ {"hook" : "verification" },
281
+ {"hook" : "session" },
282
+ },
283
+ },
271
284
expect : func (reg * driver.RegistryDefault ) []registration.PostHookPostPersistExecutor {
272
285
return []registration.PostHookPostPersistExecutor {
273
286
hook .NewVerifier (reg ),
@@ -278,15 +291,13 @@ func TestDriverDefault_Hooks(t *testing.T) {
278
291
{
279
292
uc : "A session hook and a web_hook are configured for password strategy" ,
280
293
config : map [string ]any {
281
- config .ViperKeySelfServiceVerificationEnabled : true ,
282
294
config .ViperKeySelfServiceRegistrationAfter + ".password.hooks" : []map [string ]any {
283
295
{"hook" : "web_hook" , "config" : map [string ]any {"headers" : map [string ]string {"X-Custom-Header" : "test" }, "url" : "foo" , "method" : "POST" , "body" : "bar" }},
284
296
{"hook" : "session" },
285
297
},
286
298
},
287
299
expect : func (reg * driver.RegistryDefault ) []registration.PostHookPostPersistExecutor {
288
300
return []registration.PostHookPostPersistExecutor {
289
- hook .NewVerifier (reg ),
290
301
hook .NewWebHook (reg , json .RawMessage (`{"body":"bar","headers":{"X-Custom-Header":"test"},"method":"POST","url":"foo"}` )),
291
302
hook .NewSessionIssuer (reg ),
292
303
}
@@ -317,11 +328,9 @@ func TestDriverDefault_Hooks(t *testing.T) {
317
328
config .ViperKeySelfServiceRegistrationAfter + ".hooks" : []map [string ]any {
318
329
{"hook" : "web_hook" , "config" : map [string ]any {"url" : "bar" , "method" : "POST" , "headers" : map [string ]string {"X-Custom-Header" : "test" }}},
319
330
},
320
- config .ViperKeySelfServiceVerificationEnabled : true ,
321
331
},
322
332
expect : func (reg * driver.RegistryDefault ) []registration.PostHookPostPersistExecutor {
323
333
return []registration.PostHookPostPersistExecutor {
324
- hook .NewVerifier (reg ),
325
334
hook .NewWebHook (reg , json .RawMessage (`{"headers":{"X-Custom-Header":"test"},"method":"GET","url":"foo"}` )),
326
335
hook .NewSessionIssuer (reg ),
327
336
}
@@ -553,7 +562,9 @@ func TestDriverDefault_Hooks(t *testing.T) {
553
562
{
554
563
uc : "Only verify hook configured for the strategy" ,
555
564
config : map [string ]any {
556
- config .ViperKeySelfServiceVerificationEnabled : true ,
565
+ config .ViperKeySelfServiceSettingsAfter + ".profile.hooks" : []map [string ]any {
566
+ {"hook" : "verification" },
567
+ },
557
568
// I think this is a bug as there is a hook named verify defined for both profile and password
558
569
// strategies. Instead of using it, the code makes use of the property used above and which
559
570
// is defined in an entirely different flow (verification).
@@ -570,11 +581,9 @@ func TestDriverDefault_Hooks(t *testing.T) {
570
581
config .ViperKeySelfServiceSettingsAfter + ".profile.hooks" : []map [string ]any {
571
582
{"hook" : "web_hook" , "config" : map [string ]any {"headers" : []map [string ]string {{"X-Custom-Header" : "test" }}, "url" : "foo" , "method" : "POST" , "body" : "bar" }},
572
583
},
573
- config .ViperKeySelfServiceVerificationEnabled : true ,
574
584
},
575
585
expect : func (reg * driver.RegistryDefault ) []settings.PostHookPostPersistExecutor {
576
586
return []settings.PostHookPostPersistExecutor {
577
- hook .NewVerifier (reg ),
578
587
hook .NewWebHook (reg , json .RawMessage (`{"body":"bar","headers":[{"X-Custom-Header":"test"}],"method":"POST","url":"foo"}` )),
579
588
}
580
589
},
@@ -597,7 +606,6 @@ func TestDriverDefault_Hooks(t *testing.T) {
597
606
{
598
607
uc : "Hooks are configured on a global level, as well as on a strategy level" ,
599
608
config : map [string ]any {
600
- config .ViperKeySelfServiceVerificationEnabled : true ,
601
609
config .ViperKeySelfServiceSettingsAfter + ".profile.hooks" : []map [string ]any {
602
610
{"hook" : "web_hook" , "config" : map [string ]any {"url" : "foo" , "method" : "GET" , "headers" : map [string ]string {"X-Custom-Header" : "test" }}},
603
611
},
@@ -607,7 +615,6 @@ func TestDriverDefault_Hooks(t *testing.T) {
607
615
},
608
616
expect : func (reg * driver.RegistryDefault ) []settings.PostHookPostPersistExecutor {
609
617
return []settings.PostHookPostPersistExecutor {
610
- hook .NewVerifier (reg ),
611
618
hook .NewWebHook (reg , json .RawMessage (`{"headers":{"X-Custom-Header":"test"},"method":"GET","url":"foo"}` )),
612
619
}
613
620
},
0 commit comments