mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-05 20:32:57 +02:00
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:
parent
d3d60d1055
commit
b9ab49c32c
19 changed files with 173 additions and 217 deletions
18
internal/encoding/mock/mock_encoder.go
Normal file
18
internal/encoding/mock/mock_encoder.go
Normal 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
|
||||
}
|
26
internal/encoding/mock/mock_encoder_test.go
Normal file
26
internal/encoding/mock/mock_encoder_test.go
Normal 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")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue