forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexternalaccountprovider_test.go
59 lines (53 loc) · 1.7 KB
/
externalaccountprovider_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var externalAccountProviderBody = `{
"@odata.type": "#ExternalAccountProvider.v1_7_1.ExternalAccountProvider",
"Id": "ExternalRedfishService",
"Name": "Remote Redfish Service",
"Description": "Remote Redfish Service providing additional Accounts to this Redfish Service",
"AccountProviderType": "RedfishService",
"ServiceAddresses": [
"http://redfish.dmtf.org/redfish/v1/AccountService"
],
"Authentication": {
"AuthenticationType": "Token",
"Token": null
},
"RemoteRoleMapping": [
{
"RemoteGroup": "Admin",
"LocalRole": "Administrator"
},
{
"RemoteGroup": "Operator",
"LocalRole": "Operator"
},
{
"RemoteGroup": "ReadOnly",
"LocalRole": "ReadOnly"
}
],
"@odata.id": "/redfish/v1/AccountService/ExternalAccountProviders/ExternalRedfishService"
}`
// TestExternalAccountProvider tests the parsing of ExternalAccountProvider objects.
func TestExternalAccountProvider(t *testing.T) {
var result ExternalAccountProvider
err := json.NewDecoder(strings.NewReader(externalAccountProviderBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "ExternalRedfishService", result.ID)
assertEquals(t, "Remote Redfish Service", result.Name)
assertEquals(t, "RedfishService", string(result.AccountProviderType))
assertEquals(t, "http://redfish.dmtf.org/redfish/v1/AccountService", result.ServiceAddresses[0])
assertEquals(t, "Token", string(result.Authentication.AuthenticationType))
assertEquals(t, "Admin", result.RemoteRoleMapping[0].RemoteGroup)
assertEquals(t, "Administrator", result.RemoteRoleMapping[0].LocalRole)
}