-
Notifications
You must be signed in to change notification settings - Fork 3
/
keybrokermock.go
61 lines (50 loc) · 1.35 KB
/
keybrokermock.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Package keybrokermock implements no-op mocks for the keys package
package keybrokermock
import (
"crypto/ecdsa"
"crypto/rsa"
)
// MockRSAPublicKey resolves any source and returns a mocked RSAPublicKey Copier and Renewer
func MockRSAPublicKey(key *rsa.PublicKey) *RSAPublicKeyMock {
return &RSAPublicKeyMock{
key: key,
}
}
// RSAPublicKeyMock defines the implementation for brokering an RSA public key during testing
type RSAPublicKeyMock struct {
key *rsa.PublicKey
}
// Copy returns a shallow copy o the RSA public key
func (b *RSAPublicKeyMock) Copy() rsa.PublicKey {
return *b.key
}
// Renew is a no-op
func (b *RSAPublicKeyMock) Renew() {
// no-op
}
// Close is a no-op
func (b *RSAPublicKeyMock) Close() {
// no-op
}
// MockECDSAPublicKey resolves any source and returns a mocked ECDSAPublicKey Copier and Renewer
func MockECDSAPublicKey(key *ecdsa.PublicKey) *ECDSAPublicKeyMock {
return &ECDSAPublicKeyMock{
key: key,
}
}
// ECDSAPublicKeyMock defines the implementation for brokering an ECDSA public key during testing
type ECDSAPublicKeyMock struct {
key *ecdsa.PublicKey
}
// Copy returns a shallow copy o the ECDSA public key
func (b *ECDSAPublicKeyMock) Copy() ecdsa.PublicKey {
return *b.key
}
// Renew is a no-op
func (b *ECDSAPublicKeyMock) Renew() {
// no-op
}
// Close is a no-op
func (b *ECDSAPublicKeyMock) Close() {
// no-op
}