forked from danikarik/ncanode-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tsp_verify_test.go
35 lines (30 loc) · 2.88 KB
/
tsp_verify_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
package ncanode_test
import (
"testing"
"github.com/danikarik/ncanode-go"
"github.com/stretchr/testify/require"
)
func TestTSPVerify(t *testing.T) {
client, err := ncanode.NewClient("http://127.0.0.1:14579")
require.NoError(t, err)
testCases := []struct {
Name string
CMS string
}{
{
Name: "Default",
CMS: `MIIGCgYJKoZIhvcNAQcCoIIF+zCCBfcCAQMxDjAMBggqgw4DCgEDAQUAMIGBBgsqhkiG9w0BCRABBKByBHAwbgIBAQYIKoMOAwMCBgEwMDAMBggqgw4DCgEDAQUABCAIpej0s+OwH6xeU68Wbl47yc6B6yRJqo10TNQf\/z9ytgIU9o\/gkAAMwzNzK82Q1RFqjI86oSUYDzIwMjAwOTA2MTYzMDUxWgIGAXRkQY2\/oIID6jCCA+YwggOQoAMCAQICFFWSMI9yDWj\/ydlN47Rqas53D9HJMA0GCSqDDgMKAQEBAgUAMFMxCzAJBgNVBAYTAktaMUQwQgYDVQQDDDvSsNCb0KLQotCr0pog0JrQo9OY0JvQkNCd0JTQq9Cg0KPQqNCrINCe0KDQotCQ0JvQq9KaIChHT1NUKTAeFw0xOTEyMTIwNTIyMDVaFw0yMjEyMTEwNTIyMDVaMIIBEjEUMBIGA1UEAwwLVFNBIFNFUlZJQ0UxGDAWBgNVBAUTD0lJTjc2MTIzMTMwMDMxMzELMAkGA1UEBhMCS1oxHDAaBgNVBAcME9Cd0KPQoC3QodCj0JvQotCQ0J0xHDAaBgNVBAgME9Cd0KPQoC3QodCj0JvQotCQ0J0xfTB7BgNVBAoMdNCQ0JrQptCY0J7QndCV0KDQndCe0JUg0J7QkdCp0JXQodCi0JLQniAi0J3QkNCm0JjQntCd0JDQm9Cs0J3Qq9CVINCY0J3QpNCe0K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G9w0BCRABBDAcBgkqhkiG9w0BCQUxDxcNMjAwOTA2MTYzMDUxWjArBgsqhkiG9w0BCRACDDEcMBowGDAWBBR7gM+qyuxNgPDQbpw3HTYl1EVkbTAvBgkqhkiG9w0BCQQxIgQg3NjMhxkV9PeUAcbT\/VmzapBqfxz34Blycg5mWiD89wYwDQYJKoMOAwoBAQECBQAEQC0qgyst0V1CZY9dD1AWOS9psgd0epiVS2PigL9MiOOPfdtuvYkK1a4+\/I28itcRq\/YGror90J4nX9Elo0+VYc4=`,
},
}
for _, tc := range testCases {
t.Run(tc.Name, func(t *testing.T) {
resp, err := client.TSPVerify(tc.CMS)
require.NoError(t, err)
require.Equal(t, ncanode.GOST34311, resp.Result.TSPHashAlgorithm)
require.Equal(t, "f68fe090000cc333732bcd90d5116a8c8f3aa125", resp.Result.SerialNumber)
require.Equal(t, "08a5e8f4b3e3b01fac5e53af166e5e3bc9ce81eb2449aa8d744cd41fff3f72b6", resp.Result.Hash)
require.False(t, resp.Result.GenTime.IsZero())
require.Equal(t, "1.2.398.3.3.2.6.1", resp.Result.Policy)
})
}
}