Skip to content

Commit

Permalink
gocryptox509: bump schema, fix types
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodruff <[email protected]>
  • Loading branch information
woodruffw committed Sep 5, 2024
1 parent 1594e5e commit 2052cab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
31 changes: 14 additions & 17 deletions harness/gocryptox509/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,18 @@ import (
"github.com/pkg/errors"
)

type testcaseResult string
type actualResult string

const (
validationKindClient = "CLIENT"
validationKindServer = "SERVER"

resultFailure testcaseResult = "FAILURE"
resultSuccess testcaseResult = "SUCCESS"
resultSkipped testcaseResult = "SKIPPED"
resultFailure actualResult = "FAILURE"
resultSuccess actualResult = "SUCCESS"
resultSkipped actualResult = "SKIPPED"
)

type result struct {
ID string `json:"id"`
Result testcaseResult `json:"actual_result"`
Context string `json:"context"`
ID string `json:"id"`
Result actualResult `json:"actual_result"`
Context string `json:"context"`
}

type results struct {
Expand All @@ -58,7 +55,7 @@ func main() {
r, err := evaluateTestcase(tc)

var context string
if r != testcaseResult(tc.ExpectedResult.(string)) {
if string(r) != string(tc.ExpectedResult) {
if r != resultSkipped {
fmt.Fprintf(os.Stderr, "NON-CONFORMANT\n\terr=%s\n", err)
nonconform++
Expand Down Expand Up @@ -107,7 +104,7 @@ func concatPEMCerts(certs []string) []byte {
return buf.Bytes()
}

func evaluateTestcase(testcase Testcase) (testcaseResult, error) {
func evaluateTestcase(testcase Testcase) (actualResult, error) {
_ = spew.Dump

for _, feature := range testcase.Features {
Expand Down Expand Up @@ -169,9 +166,9 @@ func evaluateTestcase(testcase Testcase) (testcaseResult, error) {
}

switch testcase.ValidationKind {
case validationKindClient:
case ValidationKindCLIENT:
return resultSkipped, fmt.Errorf("unimplemented validationKindClient")
case validationKindServer:
case ValidationKindSERVER:
var dnsName string
if peerName, ok := testcase.ExpectedPeerName.(map[string]interface{}); ok {
if peerName["kind"] == "DNS" {
Expand Down Expand Up @@ -209,16 +206,16 @@ func evaluateTestcase(testcase Testcase) (testcaseResult, error) {
_ = chain

var (
expected = testcaseResult(testcase.ExpectedResult.(string))
actual testcaseResult
expected = testcase.ExpectedResult
actual actualResult
)
if err != nil {
actual = resultFailure
} else {
actual = resultSuccess
}

if expected != actual {
if string(expected) != string(actual) {
if err == nil {
err = errors.New("chain built")
}
Expand Down
8 changes: 4 additions & 4 deletions harness/gocryptox509/schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2052cab

Please sign in to comment.