1
0
mirror of https://github.com/volatiletech/authboss.git synced 2025-01-08 04:03:53 +02:00

Fix breakages from last commit

This commit is contained in:
Aaron L 2018-03-07 16:41:58 -08:00
parent 37ace55579
commit 634892e29c
13 changed files with 36 additions and 36 deletions

View File

@ -128,7 +128,7 @@ func TestAuthPostSuccess(t *testing.T) {
r := mocks.Request("POST")
resp := httptest.NewRecorder()
w := h.ab.NewResponse(resp, r)
w := h.ab.NewResponse(resp)
if err := h.auth.LoginPost(w, r); err != nil {
t.Error(err)
@ -175,7 +175,7 @@ func TestAuthPostSuccess(t *testing.T) {
r := mocks.Request("POST")
resp := httptest.NewRecorder()
w := h.ab.NewResponse(resp, r)
w := h.ab.NewResponse(resp)
if err := h.auth.LoginPost(w, r); err != nil {
t.Error(err)
@ -209,7 +209,7 @@ func TestAuthPostSuccess(t *testing.T) {
r := mocks.Request("POST")
resp := httptest.NewRecorder()
w := h.ab.NewResponse(resp, r)
w := h.ab.NewResponse(resp)
if err := h.auth.LoginPost(w, r); err != nil {
t.Error(err)
@ -253,7 +253,7 @@ func TestAuthPostBadPassword(t *testing.T) {
r := mocks.Request("POST")
resp := httptest.NewRecorder()
w := h.ab.NewResponse(resp, r)
w := h.ab.NewResponse(resp)
var afterCalled bool
h.ab.Events.After(authboss.EventAuthFail, func(w http.ResponseWriter, r *http.Request, handled bool) (bool, error) {
@ -288,7 +288,7 @@ func TestAuthPostBadPassword(t *testing.T) {
r := mocks.Request("POST")
resp := httptest.NewRecorder()
w := h.ab.NewResponse(resp, r)
w := h.ab.NewResponse(resp)
var afterCalled bool
h.ab.Events.After(authboss.EventAuthFail, func(w http.ResponseWriter, r *http.Request, handled bool) (bool, error) {
@ -328,7 +328,7 @@ func TestAuthPostUserNotFound(t *testing.T) {
r := mocks.Request("POST")
resp := httptest.NewRecorder()
w := harness.ab.NewResponse(resp, r)
w := harness.ab.NewResponse(resp)
// This event is really the only thing that separates "user not found" from "bad password"
var afterCalled bool

View File

@ -56,7 +56,7 @@ type ClientStateReadWriter interface {
// any values in the current session, or any cookie in the request
ReadState(*http.Request) (ClientState, error)
// WriteState can sometimes be called with a nil ClientState in the event
// that no ClientState was recovered from the request context.
// that no ClientState was read in from LoadClientState
WriteState(http.ResponseWriter, ClientState, []ClientStateEvent) error
}

View File

@ -64,7 +64,7 @@ func (c *Confirm) Init(ab *authboss.Authboss) (err error) {
func (c *Confirm) PreventAuth(w http.ResponseWriter, r *http.Request, handled bool) (bool, error) {
logger := c.Authboss.RequestLogger(r)
user, err := c.Authboss.CurrentUser(w, r)
user, err := c.Authboss.CurrentUser(r)
if err != nil {
return false, err
}
@ -87,7 +87,7 @@ func (c *Confirm) PreventAuth(w http.ResponseWriter, r *http.Request, handled bo
// StartConfirmationWeb hijacks a request and forces a user to be confirmed first
// it's assumed that the current user is loaded into the request context.
func (c *Confirm) StartConfirmationWeb(w http.ResponseWriter, r *http.Request, handled bool) (bool, error) {
user, err := c.Authboss.CurrentUser(w, r)
user, err := c.Authboss.CurrentUser(r)
if err != nil {
return false, err
}
@ -233,7 +233,7 @@ func (c *Confirm) Get(w http.ResponseWriter, r *http.Request) error {
func Middleware(ab *authboss.Authboss) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
user := ab.LoadCurrentUserP(w, &r)
user := ab.LoadCurrentUserP(&r)
cu := authboss.MustBeConfirmable(user)
if cu.GetConfirmed() {

View File

@ -195,7 +195,7 @@ func TestResponseRedirectNonAPI(t *testing.T) {
ab := authboss.New()
ab.Config.Storage.SessionState = mocks.NewClientRW()
ab.Config.Storage.CookieState = mocks.NewClientRW()
aw := ab.NewResponse(w, r)
aw := ab.NewResponse(w)
ro := authboss.RedirectOptions{
Success: "success", Failure: "failure",
@ -234,7 +234,7 @@ func TestResponseRedirectNonAPIFollowRedir(t *testing.T) {
ab := authboss.New()
ab.Config.Storage.SessionState = mocks.NewClientRW()
ab.Config.Storage.CookieState = mocks.NewClientRW()
aw := ab.NewResponse(w, r)
aw := ab.NewResponse(w)
ro := authboss.RedirectOptions{
RedirectPath: "/redirect", FollowRedirParam: true,

View File

@ -22,7 +22,7 @@ func TestExpireIsExpired(t *testing.T) {
r := httptest.NewRequest("GET", "/", nil)
r = r.WithContext(context.WithValue(r.Context(), authboss.CTXKeyPID, "primaryid"))
r = r.WithContext(context.WithValue(r.Context(), authboss.CTXKeyUser, struct{}{}))
w := ab.NewResponse(httptest.NewRecorder(), r)
w := ab.NewResponse(httptest.NewRecorder())
r, err := ab.LoadClientState(w, r)
if err != nil {
t.Error(err)
@ -79,7 +79,7 @@ func TestExpireNotExpired(t *testing.T) {
r := httptest.NewRequest("GET", "/", nil)
r = r.WithContext(context.WithValue(r.Context(), authboss.CTXKeyPID, "primaryid"))
r = r.WithContext(context.WithValue(r.Context(), authboss.CTXKeyUser, struct{}{}))
w := ab.NewResponse(httptest.NewRecorder(), r)
w := ab.NewResponse(httptest.NewRecorder())
r, err = ab.LoadClientState(w, r)
if err != nil {
t.Error(err)
@ -144,7 +144,7 @@ func TestExpireRefreshExpiry(t *testing.T) {
clientRW := mocks.NewClientRW()
ab.Storage.SessionState = clientRW
r := httptest.NewRequest("GET", "/", nil)
w := ab.NewResponse(httptest.NewRecorder(), r)
w := ab.NewResponse(httptest.NewRecorder())
RefreshExpiry(w, r)
w.WriteHeader(200)

View File

@ -236,7 +236,7 @@ func NewClientRW() *ClientStateRW {
}
// ReadState from memory
func (c *ClientStateRW) ReadState(http.ResponseWriter, *http.Request) (authboss.ClientState, error) {
func (c *ClientStateRW) ReadState(*http.Request) (authboss.ClientState, error) {
return &ClientState{Values: c.ClientValues}, nil
}

View File

@ -45,7 +45,7 @@ func (l *Lock) Init(ab *authboss.Authboss) error {
// BeforeAuth ensures the account is not locked.
func (l *Lock) BeforeAuth(w http.ResponseWriter, r *http.Request, handled bool) (bool, error) {
user, err := l.Authboss.CurrentUser(w, r)
user, err := l.Authboss.CurrentUser(r)
if err != nil {
return false, err
}
@ -65,7 +65,7 @@ func (l *Lock) BeforeAuth(w http.ResponseWriter, r *http.Request, handled bool)
// AfterAuthSuccess resets the attempt number field.
func (l *Lock) AfterAuthSuccess(w http.ResponseWriter, r *http.Request, handled bool) (bool, error) {
user, err := l.Authboss.CurrentUser(w, r)
user, err := l.Authboss.CurrentUser(r)
if err != nil {
return false, err
}
@ -80,7 +80,7 @@ func (l *Lock) AfterAuthSuccess(w http.ResponseWriter, r *http.Request, handled
// AfterAuthFail adjusts the attempt number and time negatively
// and locks the user if they're beyond limits.
func (l *Lock) AfterAuthFail(w http.ResponseWriter, r *http.Request, handled bool) (bool, error) {
user, err := l.Authboss.CurrentUser(w, r)
user, err := l.Authboss.CurrentUser(r)
if err != nil {
return false, err
}
@ -164,7 +164,7 @@ func (l *Lock) Unlock(ctx context.Context, key string) error {
func Middleware(ab *authboss.Authboss) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
user := ab.LoadCurrentUserP(w, &r)
user := ab.LoadCurrentUserP(&r)
lu := authboss.MustBeLockable(user)
if IsLocked(lu) {

View File

@ -40,7 +40,7 @@ func (l *Logout) Logout(w http.ResponseWriter, r *http.Request) error {
// TODO(aarondl): Evaluate this log messages usefulness, there's no other reason
// to pull the user out of the context here.
user, err := l.CurrentUser(w, r)
user, err := l.CurrentUser(r)
if err != nil {
return err
}

View File

@ -75,7 +75,7 @@ func TestLogoutLogout(t *testing.T) {
r := mocks.Request("POST")
resp := httptest.NewRecorder()
w := h.ab.NewResponse(resp, r)
w := h.ab.NewResponse(resp)
// This enables the logging portion, which is debatable-y not useful in a log out method
user := &mocks.User{Email: "test@test.com"}

View File

@ -284,7 +284,7 @@ func TestEndPostSuccessLogin(t *testing.T) {
r := mocks.Request("GET")
w := httptest.NewRecorder()
if err := h.recover.EndPost(h.ab.NewResponse(w, r), r); err != nil {
if err := h.recover.EndPost(h.ab.NewResponse(w), r); err != nil {
t.Error(err)
}

View File

@ -118,7 +118,7 @@ func TestRegisterPostSuccess(t *testing.T) {
r := mocks.Request("POST")
resp := httptest.NewRecorder()
w := h.ab.NewResponse(resp, r)
w := h.ab.NewResponse(resp)
if err := h.reg.Post(w, r); err != nil {
t.Error(err)
@ -161,7 +161,7 @@ func TestRegisterPostSuccess(t *testing.T) {
r := mocks.Request("POST")
resp := httptest.NewRecorder()
w := h.ab.NewResponse(resp, r)
w := h.ab.NewResponse(resp)
if err := h.reg.Post(w, r); err != nil {
t.Error(err)
@ -205,7 +205,7 @@ func TestRegisterPostValidationFailure(t *testing.T) {
r := mocks.Request("POST")
resp := httptest.NewRecorder()
w := h.ab.NewResponse(resp, r)
w := h.ab.NewResponse(resp)
if err := h.reg.Post(w, r); err != nil {
t.Error(err)
@ -256,7 +256,7 @@ func TestRegisterPostUserExists(t *testing.T) {
r := mocks.Request("POST")
resp := httptest.NewRecorder()
w := h.ab.NewResponse(resp, r)
w := h.ab.NewResponse(resp)
if err := h.reg.Post(w, r); err != nil {
t.Error(err)

View File

@ -51,7 +51,7 @@ func (r *Remember) RememberAfterAuth(w http.ResponseWriter, req *http.Request, h
return false, nil
}
user := r.Authboss.CurrentUserP(w, req)
user := r.Authboss.CurrentUserP(req)
hash, token, err := GenerateToken(user.GetPID())
if err != nil {
return false, err
@ -190,7 +190,7 @@ func Authenticate(ab *authboss.Authboss, w http.ResponseWriter, req *http.Reques
// AfterPasswordReset is called after the password has been reset, since
// it should invalidate all tokens associated to that user.
func (r *Remember) AfterPasswordReset(w http.ResponseWriter, req *http.Request, handled bool) (bool, error) {
user, err := r.Authboss.CurrentUser(w, req)
user, err := r.Authboss.CurrentUser(req)
if err != nil {
return false, err
}

View File

@ -62,7 +62,7 @@ func TestRememberAfterAuth(t *testing.T) {
r = r.WithContext(context.WithValue(r.Context(), authboss.CTXKeyValues, mocks.Values{Remember: true}))
r = r.WithContext(context.WithValue(r.Context(), authboss.CTXKeyUser, user))
rec := httptest.NewRecorder()
w := h.ab.NewResponse(rec, r)
w := h.ab.NewResponse(rec)
if handled, err := h.remember.RememberAfterAuth(w, r, false); err != nil {
t.Fatal(err)
@ -89,7 +89,7 @@ func TestRememberAfterAuthSkip(t *testing.T) {
r := mocks.Request("POST")
rec := httptest.NewRecorder()
w := h.ab.NewResponse(rec, r)
w := h.ab.NewResponse(rec)
if handled, err := h.remember.RememberAfterAuth(w, r, false); err != nil {
t.Fatal(err)
@ -128,7 +128,7 @@ func TestMiddlewareAuth(t *testing.T) {
r := mocks.Request("POST")
rec := httptest.NewRecorder()
w := h.ab.NewResponse(rec, r)
w := h.ab.NewResponse(rec)
var err error
r, err = h.ab.LoadClientState(w, r)
@ -168,7 +168,7 @@ func TestAuthenticateSuccess(t *testing.T) {
r := mocks.Request("POST")
rec := httptest.NewRecorder()
w := h.ab.NewResponse(rec, r)
w := h.ab.NewResponse(rec)
var err error
r, err = h.ab.LoadClientState(w, r)
@ -213,7 +213,7 @@ func TestAuthenticateTokenNotFound(t *testing.T) {
r := mocks.Request("POST")
rec := httptest.NewRecorder()
w := h.ab.NewResponse(rec, r)
w := h.ab.NewResponse(rec)
var err error
r, err = h.ab.LoadClientState(w, r)
@ -246,7 +246,7 @@ func TestAuthenticateBadTokens(t *testing.T) {
r := mocks.Request("POST")
rec := httptest.NewRecorder()
w := h.ab.NewResponse(rec, r)
w := h.ab.NewResponse(rec)
var err error
r, err = h.ab.LoadClientState(w, r)
@ -295,7 +295,7 @@ func TestAfterPasswordReset(t *testing.T) {
r := mocks.Request("POST")
r = r.WithContext(context.WithValue(r.Context(), authboss.CTXKeyUser, user))
rec := httptest.NewRecorder()
w := h.ab.NewResponse(rec, r)
w := h.ab.NewResponse(rec)
if handled, err := h.remember.AfterPasswordReset(w, r, false); err != nil {
t.Error(err)