-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds some things that were missed in the TrustedComponent object. Signed-off-by: Sean McGinnis <[email protected]>
- Loading branch information
1 parent
e533598
commit e1e344d
Showing
2 changed files
with
119 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
|
||
package redfish | ||
|
||
import ( | ||
"encoding/json" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
var tcBody = `{ | ||
"@odata.type": "#TrustedComponent.v1_1_0.TrustedComponent", | ||
"@odata.context": "/redfish/v1/$metadata#TrustedComponent.TrustedComponent", | ||
"Id": "TPM", | ||
"Name": "TrustedComponent for TPM", | ||
"Description": "TrustedComponent for Trusted Platform Module", | ||
"TrustedComponentType": "Discrete", | ||
"Certificates": { | ||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/TrustedComponents/TPM/Certificates" | ||
}, | ||
"Links": { | ||
"ComponentsProtected": [ | ||
{ | ||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1" | ||
} | ||
] | ||
}, | ||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/TrustedComponents/TPM" | ||
}` | ||
|
||
// TestTrustedComponent tests the parsing of TrustedComponent objects. | ||
func TestTrustedComponent(t *testing.T) { | ||
var result TrustedComponent | ||
err := json.NewDecoder(strings.NewReader(tcBody)).Decode(&result) | ||
|
||
if err != nil { | ||
t.Errorf("Error decoding JSON: %s", err) | ||
} | ||
|
||
if result.ID != "TPM" { | ||
t.Errorf("Received invalid ID: %s", result.ID) | ||
} | ||
|
||
if result.Name != "TrustedComponent for TPM" { | ||
t.Errorf("Received invalid name: %s", result.Name) | ||
} | ||
|
||
if result.certificates != "/redfish/v1/Chassis/System.Embedded.1/TrustedComponents/TPM/Certificates" { | ||
t.Errorf("Invalid fan name: %s", result.certificates) | ||
} | ||
} |