From 5a62b6c20c1c4d3482e552a2409fa602987bcb39 Mon Sep 17 00:00:00 2001 From: Aaron L Date: Sun, 28 Oct 2018 23:28:04 -0700 Subject: [PATCH] Fix some broken tests --- authboss.go | 8 ++++---- authboss_test.go | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/authboss.go b/authboss.go index 39a4c9b..11cf72d 100644 --- a/authboss.go +++ b/authboss.go @@ -144,13 +144,13 @@ func MountedMiddleware(ab *Authboss, mountPathed, redirectToLogin, forceFullAuth return } - if u, err := ab.LoadCurrentUser(&r); err != nil { + if _, err := ab.LoadCurrentUser(&r); err == ErrUserNotFound { + fail(w, r) + return + } else if err != nil { log.Errorf("error fetching current user: %+v", err) w.WriteHeader(http.StatusInternalServerError) return - } else if u == nil { - fail(w, r) - return } else { next.ServeHTTP(w, r) } diff --git a/authboss_test.go b/authboss_test.go index 80b7adb..5ae6fc8 100644 --- a/authboss_test.go +++ b/authboss_test.go @@ -5,6 +5,8 @@ import ( "net/http" "net/http/httptest" "testing" + + "github.com/davecgh/go-spew/spew" ) func TestAuthBossInit(t *testing.T) { @@ -135,6 +137,8 @@ func TestAuthbossMiddleware(t *testing.T) { rec, called, hadUser := setupMore(false, false, false, false) + spew.Dump(ab.Storage) + if rec.Code != http.StatusNotFound { t.Error("wrong code:", rec.Code) }