-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for subpaths and skip ssl cert checks
- Loading branch information
1 parent
3029acc
commit 8acb233
Showing
3 changed files
with
83 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley | ||
// SPDX-License-Identifier: MIT | ||
|
||
package daemon | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestReconstructURL(t *testing.T){ | ||
protocol := "http" | ||
host := "localhost" | ||
port := "8000" | ||
// Making sure trailing slashes are accounted for correctly | ||
r, _ := http.NewRequest("GET", "http://localhost:1337/", nil) | ||
assert.Equal(t, "http://localhost:8000/", reconstructURL(r, protocol, host, port)) | ||
r, _ = http.NewRequest("GET", "http://localhost:1337", nil) | ||
assert.Equal(t, "http://localhost:8000", reconstructURL(r, protocol, host, port)) | ||
// Adding port correctly | ||
r, _ = http.NewRequest("GET", "http://localhost/", nil) | ||
assert.Equal(t, "http://localhost/", reconstructURL(r, protocol, host, "")) | ||
r, _ = http.NewRequest("GET", "http://localhost:8000", nil) | ||
assert.Equal(t, "http://localhost", reconstructURL(r, protocol, host, "")) | ||
// Adding paths correctly | ||
r, _ = http.NewRequest("POST", "http://localhost/dalek", nil) | ||
assert.Equal(t, "http://localhost:8000/dalek", reconstructURL(r, protocol, host, port)) | ||
r, _ = http.NewRequest("PUT", "http://localhost/dalek/1337", nil) | ||
assert.Equal(t, "http://localhost/dalek/1337", reconstructURL(r, protocol, host, "")) | ||
// Adding query params correctly | ||
r, _ = http.NewRequest("GET", "http://localhost?doctor=who", nil) | ||
assert.Equal(t, "http://localhost:8000?doctor=who", reconstructURL(r, protocol, host, port)) | ||
r, _ = http.NewRequest("GET", "http://localhost:1337?doctor=who", nil) | ||
assert.Equal(t, "http://localhost?doctor=who", reconstructURL(r, protocol, host, "")) | ||
} |