forked from hyperledger-archives/aries-framework-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock_secretlock.go
35 lines (27 loc) · 928 Bytes
/
mock_secretlock.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package secretlock
import "github.com/Universal-Health-Chain/aries-framework-go/pkg/secretlock"
// MockSecretLock mocking a Secret Lock service.
type MockSecretLock struct {
ValEncrypt string
ValDecrypt string
ErrEncrypt error
ErrDecrypt error
}
// Encrypt req for master key in keyURI.
func (m *MockSecretLock) Encrypt(keyURI string, req *secretlock.EncryptRequest) (*secretlock.EncryptResponse, error) {
if m.ErrEncrypt != nil {
return nil, m.ErrEncrypt
}
return &secretlock.EncryptResponse{Ciphertext: m.ValEncrypt}, nil
}
// Decrypt req for master key in keyURI.
func (m *MockSecretLock) Decrypt(keyURI string, req *secretlock.DecryptRequest) (*secretlock.DecryptResponse, error) {
if m.ErrDecrypt != nil {
return nil, m.ErrDecrypt
}
return &secretlock.DecryptResponse{Plaintext: m.ValDecrypt}, nil
}