mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-26 13:09:47 +02:00
cryptutil: fix potential race with signer
This commit is contained in:
parent
14547a50e4
commit
e30aa2c13b
5 changed files with 66 additions and 14 deletions
44
internal/cryptutil/mock_cipher_test.go
Normal file
44
internal/cryptutil/mock_cipher_test.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package cryptutil // import "github.com/pomerium/pomerium/internal/cryptutil"
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMockCipher_Unmarshal(t *testing.T) {
|
||||
e := errors.New("err")
|
||||
mc := MockCipher{
|
||||
EncryptResponse: []byte("EncryptResponse"),
|
||||
EncryptError: e,
|
||||
DecryptResponse: []byte("DecryptResponse"),
|
||||
DecryptError: e,
|
||||
MarshalResponse: "MarshalResponse",
|
||||
MarshalError: e,
|
||||
UnmarshalError: e,
|
||||
}
|
||||
b, err := mc.Encrypt([]byte("test"))
|
||||
if string(b) != "EncryptResponse" {
|
||||
t.Error("unexpected encrypt response")
|
||||
}
|
||||
if err != e {
|
||||
t.Error("unexpected encrypt error")
|
||||
}
|
||||
b, err = mc.Decrypt([]byte("test"))
|
||||
if string(b) != "DecryptResponse" {
|
||||
t.Error("unexpected Decrypt response")
|
||||
}
|
||||
if err != e {
|
||||
t.Error("unexpected Decrypt error")
|
||||
}
|
||||
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")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue