mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-04-26 13:26:23 +02:00
add imageproxy-sign tool for calculating signatures
it's a little bit rough, but seems to work pretty well. Ref #145
This commit is contained in:
parent
38d3bcc7fe
commit
e1558d5626
3 changed files with 120 additions and 0 deletions
34
cmd/imageproxy-sign/main_test.go
Normal file
34
cmd/imageproxy-sign/main_test.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseURL(t *testing.T) {
|
||||
tests := []struct {
|
||||
input, output string
|
||||
}{
|
||||
{"/", "/#0x0"},
|
||||
|
||||
// imageproxy URLs
|
||||
{"http://localhost:8080//http://example.com/", "http://example.com/#0x0"},
|
||||
{"http://localhost:8080/10,r90,jpeg/http://example.com/", "http://example.com/#10x10,jpeg,r90"},
|
||||
|
||||
// remote URLs, with and without options
|
||||
{"http://example.com/", "http://example.com/#0x0"},
|
||||
{"http://example.com/#r90,jpeg", "http://example.com/#0x0,jpeg,r90"},
|
||||
|
||||
// ensure signature values are stripped
|
||||
{"http://localhost:8080/sc0ffee/http://example.com/", "http://example.com/#0x0"},
|
||||
{"http://example.com/#sc0ffee", "http://example.com/#0x0"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
want, _ := url.Parse(tt.output)
|
||||
got := parseURL(tt.input)
|
||||
if got.String() != want.String() {
|
||||
t.Errorf("parseURL(%q) returned %q, want %q", tt.input, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue