allow request signatures to cover options

URL-only signatures are still accepted, though no longer recommended.

Fixes #145
This commit is contained in:
Will Norris 2019-03-27 20:57:15 +00:00
parent ae2a31cc01
commit 38d3bcc7fe
3 changed files with 93 additions and 12 deletions

View file

@ -228,6 +228,10 @@ func TestValidSignature(t *testing.T) {
{"http://test/image", Options{Signature: "NDx5zZHx7QfE8E-ijowRreq6CJJBZjwiRfOVk_mkfQQ="}, true},
{"http://test/image", Options{Signature: "NDx5zZHx7QfE8E-ijowRreq6CJJBZjwiRfOVk_mkfQQ"}, true},
{"http://test/image", emptyOptions, false},
// url-only signature with options
{"http://test/image", Options{Signature: "NDx5zZHx7QfE8E-ijowRreq6CJJBZjwiRfOVk_mkfQQ", Rotate: 90}, true},
// signature calculated from url plus options
{"http://test/image", Options{Signature: "ZGTzEm32o4iZ7qcChls3EVYaWyrDd9u0etySo0-WkF8=", Rotate: 90}, true},
}
for _, tt := range tests {
@ -237,7 +241,7 @@ func TestValidSignature(t *testing.T) {
}
req := &Request{u, tt.options, &http.Request{}}
if got, want := validSignature(key, req), tt.valid; got != want {
t.Errorf("validSignature(%v, %q) returned %v, want %v", key, u, got, want)
t.Errorf("validSignature(%v, %v) returned %v, want %v", key, req, got, want)
}
}
}