forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattributeregistry_test.go
134 lines (128 loc) · 3.97 KB
/
attributeregistry_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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var attributeRegistryBody = strings.NewReader(
`{
"@odata.type": "#AttributeRegistry.v1_3_6.AttributeRegistry",
"Description": "This registry defines a representation of BIOS Attribute instances",
"Id": "BiosAttributeRegistryG9000.v1_0_0",
"Language": "en",
"Name": "G9000 BIOS Attribute Registry",
"OwningEntity": "Contoso",
"RegistryVersion": "1.0.0",
"SupportedSystems": [
{
"ProductName": "Contoso Server GLH9000",
"SystemId": "G9000",
"FirmwareVersion": "v1.00 (06/02/2014)"
}
],
"RegistryEntries": {
"Attributes": [
{
"CurrentValue": null,
"DisplayName": "Embedded NIC 1 Boot",
"DisplayOrder": 5,
"HelpText": "Select this option to enable network boot (PXE, iSCSI, or FCoE) for the selected NIC. You may need to configure the NIC firmware for the boot option to be active.",
"MenuPath": "./SystemOptions/NetworkBootOptions",
"AttributeName": "NicBoot1",
"ReadOnly": false,
"Hidden": false,
"Type": "Enumeration",
"Value": [
{
"ValueDisplayName": "Network Boot",
"ValueName": "NetworkBoot"
},
{
"ValueDisplayName": "Disabled",
"ValueName": "Disabled"
}
],
"WarningText": "Important: When enabling network boot support for an embedded NIC, the NIC boot option does not appear in the UEFI Boot Order or Legacy IPL lists until the next system reboot."
},
{
"CurrentValue": null,
"DisplayName": "Embedded SATA Configuration",
"DisplayOrder": 74,
"HelpText": "Important: Select this option to configure the embedded chipset SATA controller.",
"MenuPath": "./SystemOptions/SataOptions",
"AttributeName": "EmbeddedSata",
"ReadOnly": false,
"Hidden": false,
"Type": "Enumeration",
"Value": [
{
"ValueDisplayName": "Enable SATA AHCI Support",
"ValueName": "Ahci"
},
{
"ValueDisplayName": "Enable Software RAID Support",
"ValueName": "Raid"
}
],
"WarningText": "Important: Software RAID is not supported when the Boot Mode is configured in Legacy BIOS Mode."
}
],
"Dependencies": [
{
"Dependency": {
"MapFrom": [
{
"MapFromAttribute": "BootMode",
"MapFromCondition": "EQU",
"MapFromProperty": "CurrentValue",
"MapFromValue": "LegacyBios"
}
],
"MapToAttribute": "EmbeddedSata",
"MapToProperty": "ReadOnly",
"MapToValue": true
},
"DependencyFor": "EmbeddedSata",
"Type": "Map"
}
],
"Menus": [
{
"DisplayName": "BIOS Configuration",
"DisplayOrder": 1,
"MenuPath": "./",
"MenuName": "BiosMainMenu",
"Hidden": false,
"ReadOnly": false
},
{
"DisplayName": "System Options",
"DisplayOrder": 2,
"MenuPath": "./SystemOptions",
"MenuName": "SystemOptions",
"Hidden": false,
"ReadOnly": false
}
]
}
}`)
// TestAttributeRegistry tests the parsing of AttributeRegistry objects.
func TestAttributeRegistry(t *testing.T) {
var result AttributeRegistry
err := json.NewDecoder(attributeRegistryBody).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "BiosAttributeRegistryG9000.v1_0_0", result.ID)
assertEquals(t, "G9000 BIOS Attribute Registry", result.Name)
assertEquals(t, "Contoso", result.OwningEntity)
assertEquals(t, "1.0.0", result.RegistryVersion)
assertEquals(t, "Embedded NIC 1 Boot", result.RegistryEntries.Attributes[0].DisplayName)
assertEquals(t, "Enable Software RAID Support", result.RegistryEntries.Attributes[1].Value[1].ValueDisplayName)
assertEquals(t, "BootMode", result.RegistryEntries.Dependencies[0].Dependency.MapFrom[0].MapFromAttribute)
assertEquals(t, "EmbeddedSata", result.RegistryEntries.Dependencies[0].DependencyFor)
assertEquals(t, "System Options", result.RegistryEntries.Menus[1].DisplayName)
}