forked from danikarik/ncanode-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
x509_info_test.go
61 lines (53 loc) · 1.48 KB
/
x509_info_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
package ncanode_test
import (
"testing"
"github.com/danikarik/ncanode-go"
"github.com/stretchr/testify/require"
)
func TestX509Info(t *testing.T) {
client, err := ncanode.NewClient("http://127.0.0.1:14579")
require.NoError(t, err)
testCases := []struct {
Name string
Path string
VerifyOCSP bool
VerifyCRL bool
ExpectedResult bool
}{
{
Name: "Personal/Active/Auth",
Path: "personal/active/AUTH_RSA256_b2c70a9ff7a5dc59de0ccc3c0ddde3437cc1f12d.cer",
ExpectedResult: true,
},
{
Name: "Personal/Active/Sign",
Path: "personal/active/RSA256_11c707bd54cbfcccb3815e39c4eb57b1dc7dfea9.cer",
ExpectedResult: true,
},
{
Name: "Organization/Active/Auth",
Path: "organization/active/AUTH_RSA256_d682726b55b3e62600ea8fe1c74e75fc96f47790.cer",
ExpectedResult: true,
},
{
Name: "Organization/Active/Sign",
Path: "organization/active/GOSTKNCA_13a3741b52d7bf860aab199b56fad1f4652e357b.cer",
ExpectedResult: true,
},
}
for _, tc := range testCases {
t.Run(tc.Name, func(t *testing.T) {
cert, err := base64content(tc.Path)
require.NoError(t, err)
resp, err := client.X509Info(cert, tc.VerifyOCSP, tc.VerifyCRL)
require.NoError(t, err)
require.Equal(t, tc.ExpectedResult, resp.Result.Valid)
if tc.VerifyOCSP {
require.NotNil(t, resp.Result.OCSP)
}
if tc.VerifyCRL {
require.NotNil(t, resp.Result.CRL)
}
})
}
}