forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcertificatelocations_test.go
47 lines (39 loc) · 1.13 KB
/
certificatelocations_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var body = `{
"@odata.type": "#CertificateLocations.v1_0_1.CertificateLocations",
"@odata.id": "/redfish/v1/CertificateService/CertificateLocations",
"Id": "CertificateLocations",
"Name": "Certificate Locations",
"Links": {
"Certificates": [
{
"@odata.id": "/redfish/v1/Managers/1/NetworkProtocol/HTTPS/Certificates/1"
}
]
}
}`
// TestCertificateLocations tests the parsing of CertificateLocations objects.
func TestCertificateLocations(t *testing.T) {
var result CertificateLocations
err := json.NewDecoder(strings.NewReader(body)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
if result.ID != "CertificateLocations" {
t.Errorf("Received invalid ID: %s", result.ID)
}
if result.Name != "Certificate Locations" {
t.Errorf("Received invalid name: %s", result.Name)
}
if len(result.certificates) != 1 && result.certificates[0] != "/redfish/v1/Managers/1/NetworkProtocol/HTTPS/Certificates/1" {
t.Errorf("Received invalid certificate link: %#v", result.certificates)
}
}