@@ -276,6 +276,36 @@ func TestEndPostSuccessLogin(t *testing.T) {
276276 RecoverTokenExpiry : time .Now ().UTC ().AddDate (0 , 0 , 1 ),
277277 }
278278
279+ callbacks := 0
280+ h .ab .Events .After (authboss .EventRecoverEnd , func (w http.ResponseWriter , r * http.Request , handled bool ) (bool , error ) {
281+ if callbacks != 0 {
282+ t .Error ("after recover end was not called 1st" )
283+ }
284+ callbacks += 1
285+ return false , nil
286+ })
287+ h .ab .Events .Before (authboss .EventAuth , func (w http.ResponseWriter , r * http.Request , handled bool ) (bool , error ) {
288+ if callbacks != 1 {
289+ t .Error ("before auth was not called 2nd" )
290+ }
291+ callbacks += 1
292+ return false , nil
293+ })
294+ h .ab .Events .Before (authboss .EventAuthHijack , func (w http.ResponseWriter , r * http.Request , handled bool ) (bool , error ) {
295+ if callbacks != 2 {
296+ t .Error ("before auth hijack was not called 3rd" )
297+ }
298+ callbacks += 1
299+ return false , nil
300+ })
301+ h .ab .Events .After (authboss .EventAuth , func (w http.ResponseWriter , r * http.Request , handled bool ) (bool , error ) {
302+ if callbacks != 3 {
303+ t .Error ("after auth was not called 4th" )
304+ }
305+ callbacks += 1
306+ return false , nil
307+ })
308+
279309 r := mocks .Request ("POST" )
280310 w := httptest .NewRecorder ()
281311
@@ -295,6 +325,9 @@ func TestEndPostSuccessLogin(t *testing.T) {
295325 if ! strings .Contains (h .redirector .Options .Success , "logged in" ) {
296326 t .Error ("should talk about logging in" )
297327 }
328+ if callbacks != 4 {
329+ t .Error ("all 4 callbacks were not called" )
330+ }
298331}
299332
300333func TestEndPostValidationFailure (t * testing.T ) {
0 commit comments