internal/sessions: fix cookie clear session (#376)

CookieStore's ClearSession now properly clears the user session cookie by setting MaxAge to -1.

internal/sessions: move encoder interface to encoding package, and rename to MarshalUnmarshaler.
internal/encoding: move mock to own package
authenticate: use INFO log level for authZ error.

Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
Bobby DeSimone 2019-11-09 10:49:24 -08:00 committed by GitHub
parent d3d60d1055
commit b9ab49c32c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 173 additions and 217 deletions

View file

@ -0,0 +1,18 @@
package mock // import "github.com/pomerium/pomerium/internal/encoding/mock"
// Encoder MockCSRFStore is a mock implementation of Cipher.
type Encoder struct {
MarshalResponse []byte
MarshalError error
UnmarshalError error
}
// Marshal is a mock implementation of Encoder.
func (mc Encoder) Marshal(i interface{}) ([]byte, error) {
return mc.MarshalResponse, mc.MarshalError
}
// Unmarshal is a mock implementation of Encoder.
func (mc Encoder) Unmarshal(s []byte, i interface{}) error {
return mc.UnmarshalError
}

View file

@ -0,0 +1,26 @@
package mock // import "github.com/pomerium/pomerium/internal/encoding/mock"
import (
"errors"
"testing"
)
func TestMockEncoder(t *testing.T) {
e := errors.New("err")
mc := Encoder{
MarshalResponse: []byte("MarshalResponse"),
MarshalError: e,
UnmarshalError: e,
}
s, err := mc.Marshal("test")
if err != e {
t.Error("unexpected Marshal error")
}
if string(s) != "MarshalResponse" {
t.Error("unexpected MarshalResponse error")
}
err = mc.Unmarshal([]byte("s"), "s")
if err != e {
t.Error("unexpected Unmarshal error")
}
}