forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeypolicy_test.go
67 lines (60 loc) · 1.5 KB
/
keypolicy_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var keyPolicyBody = `{
"@odata.type": "#KeyPolicy.v1_0_0.KeyPolicy",
"Id": "0",
"Name": "Default NVMeoF Key Policy",
"IsDefault": true,
"KeyPolicyType": "NVMeoF",
"NVMeoF": {
"SecurityTransportAllowList": [
"TLSv2",
"TLSv3"
],
"CipherSuiteAllowList": [
"TLS_AES_128_GCM_SHA256",
"TLS_AES_256_GCM_SHA384"
],
"SecurityProtocolAllowList": [
"DHHC",
"TLS_PSK"
],
"DHGroupAllowList": [
"FFDHE2048",
"FFDHE3072",
"FFDHE4096",
"FFDHE6144",
"FFDHE8192"
],
"SecureHashAllowList": [
"SHA384",
"SHA512"
]
},
"@odata.id": "/redfish/v1/KeyService/NVMeoFKeyPolicies/0"
}`
// TestKeyPolicy tests the parsing of KeyPolicy objects.
func TestKeyPolicy(t *testing.T) {
var result KeyPolicy
err := json.NewDecoder(strings.NewReader(keyPolicyBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "0", result.ID)
assertEquals(t, "Default NVMeoF Key Policy", result.Name)
assertEquals(t, "NVMeoF", string(result.KeyPolicyType))
assertEquals(t, "TLSv3", string(result.NVMeoF.SecurityTransportAllowList[1]))
assertEquals(t, "TLS_AES_256_GCM_SHA384", string(result.NVMeoF.CipherSuiteAllowList[1]))
assertEquals(t, "DHHC", string(result.NVMeoF.SecurityProtocolAllowList[0]))
assertEquals(t, "SHA512", string(result.NVMeoF.SecureHashAllowList[1]))
if !result.IsDefault {
t.Error("Expected to be the default")
}
}