1
0
mirror of https://github.com/volatiletech/authboss.git synced 2025-07-13 01:20:17 +02:00

Add router tests.

- Rename Endpoint to Location in ErrAndRedirect
This commit is contained in:
Aaron
2015-02-24 14:45:37 -08:00
parent e369d626a8
commit 1075149bb8
8 changed files with 244 additions and 55 deletions

View File

@ -22,30 +22,6 @@ func TestAuthBossInit(t *testing.T) {
}
}
func TestAuthBossRouter(t *testing.T) {
NewConfig()
Cfg.Storer = mockStorer{}
Cfg.CookieStoreMaker = func(_ http.ResponseWriter, _ *http.Request) ClientStorer {
return mockClientStore{}
}
Cfg.SessionStoreMaker = SessionStoreMaker(Cfg.CookieStoreMaker)
Cfg.MountPath = "/candycanes"
if err := Init(); err != nil {
t.Error("Unexpected error:", err)
}
router := NewRouter()
r, _ := http.NewRequest("GET", "/candycanes/testroute", nil)
response := httptest.NewRecorder()
router.ServeHTTP(response, r)
if response.Header().Get("testhandler") != "test" {
t.Error("Expected a header to have been set.")
}
}
func TestAuthBossCurrentUser(t *testing.T) {
NewConfig()
Cfg.Storer = mockStorer{"joe": Attributes{"email": "john@john.com", "password": "lies"}}