forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutboundconnection_test.go
72 lines (63 loc) · 2.14 KB
/
outboundconnection_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var outboundConnectionBody = `{
"@odata.type": "#OutboundConnection.v1_0_1.OutboundConnection",
"Id": "1",
"Name": "Outbound Connection to contoso app",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
},
"Authentication": "MTLS",
"Certificates": {
"@odata.id": "/redfish/v1/AccountService/OutboundConnections/1/Certificates"
},
"ClientCertificates": {
"@odata.id": "/redfish/v1/AccountService/OutboundConnections/1/ClientCertificates"
},
"ConnectionEnabled": true,
"EndpointURI": "wss://ws.contoso.com:443",
"RetryPolicy": {
"ConnectionRetryPolicy": "RetryCount",
"RetryIntervalMinutes": 5,
"RetryCount": 60
},
"Roles": [
"Administrator"
],
"WebSocketPingIntervalMinutes": 10,
"@odata.id": "/redfish/v1/AccountService/OutboundConnections/1"
}`
// TestOutboundConnection tests the parsing of OutboundConnection objects.
func TestOutboundConnection(t *testing.T) {
var result OutboundConnection
err := json.NewDecoder(strings.NewReader(outboundConnectionBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "1", result.ID)
assertEquals(t, "Outbound Connection to contoso app", result.Name)
assertEquals(t, "MTLS", string(result.Authentication))
assertEquals(t, "/redfish/v1/AccountService/OutboundConnections/1/Certificates", result.certificates)
assertEquals(t, "/redfish/v1/AccountService/OutboundConnections/1/ClientCertificates", result.clientCertificates)
assertEquals(t, "wss://ws.contoso.com:443", result.EndpointURI)
assertEquals(t, "RetryCount", string(result.RetryPolicy.ConnectionRetryPolicy))
assertEquals(t, "Administrator", result.Roles[0])
if !result.ConnectionEnabled {
t.Error("Expected connection to be enabled")
}
if result.RetryPolicy.RetryIntervalMinutes != 5 {
t.Errorf("Unexpected RetryIntervalMinutes value: %d", result.RetryPolicy.RetryIntervalMinutes)
}
if result.WebSocketPingIntervalMinutes != 10 {
t.Errorf("Unexpected WebSocketPingIntervalMinutes value: %d", result.WebSocketPingIntervalMinutes)
}
}