mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-02 08:19:23 +02:00
proxy: fix forward auth, request signing
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
parent
ec9607d1d5
commit
6775e86e24
32 changed files with 928 additions and 522 deletions
|
@ -108,48 +108,6 @@ func TestValidateURL(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSignedRedirectURL(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
mockedTime int64
|
||||
key string
|
||||
destination *url.URL
|
||||
urlToSign *url.URL
|
||||
want *url.URL
|
||||
}{
|
||||
{"good", 2, "hunter42", &url.URL{Host: "pomerium.io", Scheme: "https://"}, &url.URL{Host: "pomerium.io", Scheme: "https://", Path: "/ok"}, &url.URL{Host: "pomerium.io", Scheme: "https://", RawQuery: "redirect_uri=https%3A%2F%2F%3A%2F%2Fpomerium.io%2Fok&sig=7jdo1XFcmuhjBHnpfVhll5cXflYByeMnbp5kRz87CVQ%3D&ts=2"}},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
mockNow.setNow(tt.mockedTime)
|
||||
got := SignedRedirectURL(tt.key, tt.destination, tt.urlToSign)
|
||||
if diff := cmp.Diff(got, tt.want); diff != "" {
|
||||
t.Errorf("SignedRedirectURL() = diff %v", diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_timestamp(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
dontWant int64
|
||||
}{
|
||||
{"if unset should never return", 0},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
mockNow.setNow(tt.dontWant)
|
||||
if got := timestamp(); got == tt.dontWant {
|
||||
t.Errorf("timestamp() = %v, dontWant %v", got, tt.dontWant)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func parseURLHelper(s string) *url.URL {
|
||||
u, _ := url.Parse(s)
|
||||
return u
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue