-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds centralized wsman error struct and decode for boot and kvm (…
- Loading branch information
1 parent
92fcb4a
commit b4ea5d3
Showing
7 changed files
with
167 additions
and
3 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
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
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,73 @@ | ||
/********************************************************************* | ||
* Copyright (c) Intel Corporation 2024 | ||
* SPDX-License-Identifier: Apache-2.0 | ||
**********************************************************************/ | ||
|
||
package common | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestDecodeWSMANError(t *testing.T) { | ||
tests := []struct { | ||
input ErrorResponse | ||
expected error | ||
}{ | ||
{ | ||
ErrorResponse{ | ||
Body: ErrorBody{ | ||
Fault: Fault{ | ||
Code: Code{ | ||
SubCode: SubCode{ | ||
Value: "b:AccessDenied", | ||
}, | ||
}, | ||
Reason: Reason{ | ||
Text: "The sender was not authorized to access the resource.", | ||
}, | ||
Detail: "", | ||
}, | ||
}, | ||
}, | ||
&AMTError{ | ||
SubCode: "b:AccessDenied", Message: "The sender was not authorized to access the resource.", Detail: "", | ||
}, | ||
}, { | ||
ErrorResponse{ | ||
Body: ErrorBody{ | ||
Fault: Fault{ | ||
Code: Code{ | ||
SubCode: SubCode{ | ||
Value: "e:DestinationUnreachable", | ||
}, | ||
}, | ||
Reason: Reason{ | ||
Text: "No route can be determined to reach the destination role defined by the WSAddressing To.", | ||
}, | ||
Detail: "", | ||
}, | ||
}, | ||
}, | ||
&AMTError{ | ||
SubCode: "e:DestinationUnreachable", Message: "No route can be determined to reach the destination role defined by the WSAddressing To.", Detail: "", | ||
}, | ||
}, { | ||
ErrorResponse{}, | ||
nil, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
result := DecodeAMTError(test.input) | ||
if result == nil { | ||
if test.expected != nil { | ||
t.Errorf("Expected %s, but got nil", test.expected) | ||
} | ||
} else { | ||
if result.Error() != test.expected.Error() { | ||
t.Errorf("Expected %s, but got %s", test.expected, result) | ||
} | ||
} | ||
} | ||
} |
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