mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-06 12:52:53 +02:00
- 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>
26 lines
532 B
Go
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")
|
|
}
|
|
}
|