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

feat: add URIs to schema #19

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 25 additions & 0 deletions test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
push:
branches: [main]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Set up Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: ^1.21
cache: true

- name: Run Go Tests
run: go test -coverprofile coverage.out ./...
13 changes: 11 additions & 2 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,18 @@ type Input struct {
// URI allows you to declare the URI the test should use as part of the request line.
// examples:
// - name: URI
// value: "\"/get?hello=world\""
// value: '/get?hello=world"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// value: '/get?hello=world"
// value: '/get?hello=world'

URI *string `yaml:"uri,omitempty" json:"uri,omitempty" koanf:"uri,omitempty"`

// description: |
// URIs is a list of URIs that the test should use as part of the request line.
// If URIs is set, URI will be ignored. URIs is useful for tests that need to send multiple requests.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// If URIs is set, URI will be ignored. URIs is useful for tests that need to send multiple requests.
// If URIs is set, URI will be ignored. URIs is useful for running the same test against multiple URIs, e.g., when
// matching on URI paths.

// Caveat: you cannot change the method or headers between requests.
// examples:
// - name: URIs
// value: ['/get?hello=world', '/request/this?var=value']
URIs []string `yaml:"uris,omitempty" json:"uris,omitempty" koanf:"uris,omitempty"`

// description: |
// FollowRedirect will expect the previous stage of the same test to have received a
// redirect response, it will fail the test otherwise. The redirect location will be used
Expand Down Expand Up @@ -336,7 +345,7 @@ type Response struct {

// description: |
// LogMessage specifies a message to be printed in the log of the backend server that sends the response.
// This can be helpful when debugging, to match resopnses sent by the backend to test executions.
// This can be helpful when debugging, to match responses sent by the backend to test executions.
// examples:
// - name: LogMessage
// value: "\"Response splitting test 1\""
Expand Down
5 changes: 5 additions & 0 deletions types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ tests:
Accept: "*/*"
encoded_request: "TXkgRGF0YQo="
uri: "/test"
uris: ["/test", "/multiple", "/uris"]
protocol: "http"
autocomplete_headers: false
stop_magic: true
Expand Down Expand Up @@ -84,6 +85,8 @@ var ftwTest = &FTWTest{
Input: Input{
DestAddr: helpers.StrPtr("127.0.0.1"),
Port: helpers.IntPtr(80),
URI: helpers.StrPtr("/test"),
URIs: []string{"/test", "/multiple", "/uris"},
Method: helpers.StrPtr("OPTIONS"),
Headers: map[string]string{
"User-Agent": "FTW Schema Tests",
Expand Down Expand Up @@ -124,6 +127,8 @@ func TestUnmarshalFTWTest(t *testing.T) {
expectedStage := expectedTest.Stages[j]
assertions.Equal(expectedStage.Input.DestAddr, stage.Input.DestAddr)
assertions.Equal(expectedStage.Input.Port, stage.Input.Port)
assertions.Equal(expectedStage.Input.URI, stage.Input.URI)
assertions.Equal(expectedStage.Input.URIs, stage.Input.URIs)
assertions.Equal(expectedStage.Input.Method, stage.Input.Method)
assertions.Len(stage.Input.Headers, len(expectedStage.Input.Headers))

Expand Down
Loading