-
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: fixes e2e pkg. * fix: setHTTPSchemeIfMissing Co-Authored-By: Matteo Pace <matteo@tetrate.io> * tests: adds test for setHTTPSchemeIfMissing. * chore: fixes license. * chore: attempt to fix it. * tests: ignores tinygo for http e2e. * tests: adds test for setHTTPSchemeIfMissing. * chore: fixes license. * tests: ignores tinygo for cmd http e2e. --------- Co-authored-by: Matteo Pace <pace.matteo96@gmail.com> Co-authored-by: Matteo Pace <matteo@tetrate.io>
- Loading branch information
1 parent
a838547
commit e20a5b4
Showing
5 changed files
with
51 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2023 Juan Pablo Tosso and the OWASP Coraza contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build !tinygo | ||
// +build !tinygo | ||
|
||
package e2e | ||
|
||
import "testing" | ||
|
||
func TestSetHTTPSchemeIfMissing(t *testing.T) { | ||
tests := map[string]struct { | ||
rawURL string | ||
expectedURL string | ||
}{ | ||
"empty": {rawURL: "", expectedURL: ""}, | ||
"path": {rawURL: "abc", expectedURL: "http://abc"}, | ||
"path and port": {rawURL: "abc:123", expectedURL: "http://abc:123"}, | ||
"no schema": {rawURL: "://localhost:123/", expectedURL: "://localhost:123/"}, | ||
"with schema": {rawURL: "http://1.2.3.4:8080/abc", expectedURL: "http://1.2.3.4:8080/abc"}, | ||
} | ||
|
||
for name, test := range tests { | ||
t.Run(name, func(t *testing.T) { | ||
url := setHTTPSchemeIfMissing(test.rawURL) | ||
if want, have := test.expectedURL, url; want != have { | ||
t.Errorf("unexpected URL, want %q, have %q", want, have) | ||
} | ||
}) | ||
} | ||
} |
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