mirror of
https://github.com/volatiletech/authboss.git
synced 2025-07-15 01:24:33 +02:00
Introduce new type of client storage
- This addresses the problem of having to update multiple times during one request. It's hard to have a nice interface especially with JWT because you always end up having to decode the request, encode new response, write header, then a second write to it comes, and where do you grab the value from? Often you don't have access to the response as a "read" structure. So we store it as events instead, and play those events against the original data right before the response is written to set the headers.
This commit is contained in:
@ -65,7 +65,7 @@ func TestErrorList_Map(t *testing.T) {
|
||||
func TestValidate(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
req := mockRequest(StoreUsername, "john", StoreEmail, "john@john.com")
|
||||
req := newMockRequest(StoreUsername, "john", StoreEmail, "john@john.com")
|
||||
|
||||
errList := Validate(req, []Validator{
|
||||
mockValidator{
|
||||
@ -96,19 +96,19 @@ func TestValidate(t *testing.T) {
|
||||
func TestValidate_Confirm(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
req := mockRequest(StoreUsername, "john", "confirmUsername", "johnny")
|
||||
req := newMockRequest(StoreUsername, "john", "confirmUsername", "johnny")
|
||||
errs := Validate(req, nil, StoreUsername, "confirmUsername").Map()
|
||||
if errs["confirmUsername"][0] != "Does not match username" {
|
||||
t.Error("Expected a different error for confirmUsername:", errs["confirmUsername"][0])
|
||||
}
|
||||
|
||||
req = mockRequest(StoreUsername, "john", "confirmUsername", "john")
|
||||
req = newMockRequest(StoreUsername, "john", "confirmUsername", "john")
|
||||
errs = Validate(req, nil, StoreUsername, "confirmUsername").Map()
|
||||
if len(errs) != 0 {
|
||||
t.Error("Expected no errors:", errs)
|
||||
}
|
||||
|
||||
req = mockRequest(StoreUsername, "john", "confirmUsername", "john")
|
||||
req = newMockRequest(StoreUsername, "john", "confirmUsername", "john")
|
||||
errs = Validate(req, nil, StoreUsername).Map()
|
||||
if len(errs) != 0 {
|
||||
t.Error("Expected no errors:", errs)
|
||||
|
Reference in New Issue
Block a user