mirror of
https://github.com/volatiletech/authboss.git
synced 2024-11-28 08:58:38 +02:00
386133a84b
In order to support multiple different types of requests, there needed to be an interface to be able to read values from a request, and subsequently validate them to return any errors. So we've adjusted the Validator interface to no longer validate a request but instead validate the object it lives on. And we've created a new BodyReader interface.
29 lines
576 B
Go
29 lines
576 B
Go
package defaults
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/volatiletech/authboss"
|
|
"github.com/volatiletech/authboss/internal/mocks"
|
|
)
|
|
|
|
func TestHTTPFormReader(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
h := NewHTTPFormReader(false)
|
|
r := mocks.Request("POST", "email", "john@john.john", "password", "flowers")
|
|
|
|
validator, err := h.Read("login", r)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
uv := validator.(authboss.UserValuer)
|
|
if "john@john.john" != uv.GetPID() {
|
|
t.Error("wrong e-mail:", uv.GetPID())
|
|
}
|
|
if "flowers" != uv.GetPassword() {
|
|
t.Error("wrong password:", uv.GetPassword())
|
|
}
|
|
}
|