pomerium/internal/cryptutil/mock_cipher_test.go
Bobby DeSimone 7c755d833f
authenticate: encrypt & mac oauth2 callback state
- cryptutil: add hmac & tests
- cryptutil: rename cipher / encoders to be more clear
- cryptutil: simplify SecureEncoder interface
- cryptutil: renamed NewCipherFromBase64 to NewAEADCipherFromBase64
- cryptutil: move key & random generators to helpers

Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
2019-09-23 19:15:52 -07:00

26 lines
532 B
Go

package cryptutil // import "github.com/pomerium/pomerium/internal/cryptutil"
import (
"errors"
"testing"
)
func TestMockEncoder(t *testing.T) {
e := errors.New("err")
mc := MockEncoder{
MarshalResponse: "MarshalResponse",
MarshalError: e,
UnmarshalError: e,
}
s, err := mc.Marshal("test")
if err != e {
t.Error("unexpected Marshal error")
}
if s != "MarshalResponse" {
t.Error("unexpected MarshalResponse error")
}
err = mc.Unmarshal("s", "s")
if err != e {
t.Error("unexpected Unmarshal error")
}
}