Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema updated to current go-ftw (Adds AutocompleteHeaders, bools to pointers) #5

Merged
merged 2 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 30 additions & 17 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ func intPtr(i int) *int {
return &i
}

func boolPtr(b bool) *bool {
return &b
}

func strPtr(s string) *string {
return &s
}
Expand All @@ -29,24 +33,25 @@ var (
"Accept": "*/*",
}
exampleInput = Input{
DestAddr: strPtr("192.168.0.1"),
Port: intPtr(8080),
Protocol: strPtr("http"),
URI: strPtr("/test"),
Version: strPtr("HTTP/1.1"),
Headers: exampleHeaders,
Method: strPtr("REPORT"),
Data: nil,
EncodedRequest: "TXkgRGF0YQo=",
SaveCookie: false,
StopMagic: false,
DestAddr: strPtr("192.168.0.1"),
Port: intPtr(8080),
Protocol: strPtr("http"),
URI: strPtr("/test"),
Version: strPtr("HTTP/1.1"),
Headers: exampleHeaders,
Method: strPtr("REPORT"),
Data: nil,
EncodedRequest: "TXkgRGF0YQo=",
SaveCookie: boolPtr(false),
StopMagic: boolPtr(true),
AutocompleteHeaders: boolPtr(false),
}
exampleOutput = Output{
Status: []int{200},
ResponseContains: "",
LogContains: "nothing",
NoLogContains: "",
ExpectError: true,
ExpectError: boolPtr(true),
}
)

Expand Down Expand Up @@ -90,7 +95,7 @@ type Meta struct {
// examples:
// - name: Enabled
// value: false
Enabled bool `yaml:"enabled,omitempty"`
Enabled *bool `yaml:"enabled,omitempty"`

// description: |
// Name is the name of the tests contained in this file.
Expand Down Expand Up @@ -230,14 +235,22 @@ type Input struct {
// examples:
// - name: SaveCookie
// value: 80
SaveCookie bool `yaml:"save_cookie,omitempty" koanf:"save_cookie,omitempty"`
SaveCookie *bool `yaml:"save_cookie,omitempty" koanf:"save_cookie,omitempty"`

// description: |
// StopMagic is deprecated.
// examples:
// - name: StopMagic
// value: false
StopMagic *bool `yaml:"stop_magic" koanf:"stop_magic,omitempty"`

// description: |
// StopMagic blocks the test framework to automatically fill the request with Content-Type and Connection headers.
// AutocompleteHeaders allows the test framework to automatically fill the request with Content-Type and Connection headers.
// Defaults to true.
// examples:
// - name: StopMagic
// value: false
StopMagic bool `yaml:"stop_magic" koanf:"stop_magic,omitempty"`
AutocompleteHeaders *bool `yaml:"autocomplete_headers" koanf:"autocomplete_headers,omitempty"`

// description: |
// EncodedRequest will take a base64 encoded string that will be decoded and sent through as the request.
Expand Down Expand Up @@ -290,5 +303,5 @@ type Output struct {
// examples:
// - name: ExpectError
// value: false
ExpectError bool `yaml:"expect_error,omitempty"`
ExpectError *bool `yaml:"expect_error,omitempty"`
}
7 changes: 4 additions & 3 deletions types/types_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package types

import (
"github.com/goccy/go-yaml"
"testing"

"github.com/goccy/go-yaml"
)

var testInput = `---
Expand Down Expand Up @@ -60,7 +61,7 @@ var ftwTest = &FTWTest{
FileName: "testYaml.yaml",
Meta: Meta{
Author: "ftw-tests-schema",
Enabled: true,
Enabled: boolPtr(true),
Name: "testYaml",
Description: "Simple YAML to test that the schema is working.",
},
Expand Down Expand Up @@ -125,7 +126,7 @@ func TestUnmarshalFTWTest(t *testing.T) {
if ftw.Meta.Author != ftwTest.Meta.Author {
t.Errorf("Author: %v != %v", ftw.Meta.Author, ftwTest.Meta.Author)
}
if ftw.Meta.Enabled != ftwTest.Meta.Enabled {
if *ftw.Meta.Enabled != *ftwTest.Meta.Enabled {
t.Errorf("Enabled: %v != %v", ftw.Meta.Enabled, ftwTest.Meta.Enabled)
}
if ftw.Meta.Name != ftwTest.Meta.Name {
Expand Down