-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathknox_test.go
69 lines (53 loc) · 1.44 KB
/
knox_test.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
62
63
64
65
66
67
68
69
package knox
import (
"testing"
"github.com/golang/mock/gomock"
"github.com/knox-networks/knox-go/params"
s_mock "github.com/knox-networks/knox-go/signer/mock"
)
func TestNewKnoxClient(t *testing.T) {
mock_controller := gomock.NewController(t)
mock_signer := s_mock.NewMockDynamicSigner(mock_controller)
_, err := NewKnoxClient(&KnoxConfig{
Signer: mock_signer,
})
if err != nil {
t.Errorf("Error creating knox client: %s", err)
}
}
func TestUpdateConfig(t *testing.T) {
mock_controller := gomock.NewController(t)
mock_signer := s_mock.NewMockDynamicSigner(mock_controller)
c, err := NewKnoxClient(&KnoxConfig{
Signer: mock_signer,
Network: &NetworkConfig{
CredentialAdapterURL: "localhost:5051",
AuthServiceURL: "localhost:5052",
RegistryURL: "localhost:5053",
},
})
if err != nil {
t.Errorf("Error creating knox client: %s", err)
}
cred := c.Credential
identity := c.Identity
pres := c.Presentation
_, kps, _ := c.Identity.Generate(¶ms.GenerateIdentityParams{})
c.UpdateConfig(&KnoxConfig{
Signer: kps,
Network: &NetworkConfig{
CredentialAdapterURL: "localhost:5051",
AuthServiceURL: "localhost:5052",
RegistryURL: "localhost:5053",
},
})
if cred == c.Credential {
t.Errorf("Credential client not updated")
}
if pres == c.Presentation {
t.Errorf("Presentation client not updated")
}
if identity == c.Identity {
t.Errorf("Identity client not updated")
}
}