55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package testdata
|
|
|
|
import (
|
|
_ "embed"
|
|
"encoding/xml"
|
|
)
|
|
|
|
func Cases() ([]*TestCase, error) {
|
|
var tests TestCases
|
|
if err := xml.Unmarshal(testsXML, &tests); err != nil {
|
|
return nil, err
|
|
}
|
|
defaultCase := tests.Cases[0]
|
|
cases := make([]*TestCase, 0, len(tests.Cases[1:]))
|
|
for _, tc := range tests.Cases[1:] {
|
|
tc = &TestCase{
|
|
ID: tc.ID,
|
|
UserName: def(defaultCase.UserName, tc.UserName),
|
|
UserSecret: def(defaultCase.UserSecret, tc.UserSecret),
|
|
SiteName: def(defaultCase.SiteName, tc.SiteName),
|
|
ResultType: def(defaultCase.ResultType, tc.ResultType),
|
|
KeyCounter: def(defaultCase.KeyCounter, tc.KeyCounter),
|
|
KeyPurpose: def(defaultCase.KeyPurpose, tc.KeyPurpose),
|
|
Result: tc.Result,
|
|
}
|
|
cases = append(cases, tc)
|
|
}
|
|
return cases, nil
|
|
}
|
|
|
|
//go:embed spectre_tests.xml
|
|
var testsXML []byte
|
|
|
|
type TestCases struct {
|
|
Cases []*TestCase `xml:"case"`
|
|
}
|
|
|
|
type TestCase struct {
|
|
ID string `xml:"id,attr"`
|
|
UserName string `xml:"userName"`
|
|
UserSecret string `xml:"userSecret"`
|
|
SiteName string `xml:"siteName"`
|
|
ResultType string `xml:"resultType"`
|
|
KeyCounter string `xml:"keyCounter"`
|
|
KeyPurpose string `xml:"keyPurpose"`
|
|
Result string `xml:"result"`
|
|
}
|
|
|
|
func def(def, alt string) string {
|
|
if alt != "" {
|
|
return alt
|
|
}
|
|
return def
|
|
}
|