(t *testing.T)
| 226 | } |
| 227 | |
| 228 | func TestValidSignature(t *testing.T) { |
| 229 | key := []byte("c0ffee") |
| 230 | |
| 231 | tests := []struct { |
| 232 | url string |
| 233 | options Options |
| 234 | valid bool |
| 235 | }{ |
| 236 | {"http://test/image", Options{Signature: "NDx5zZHx7QfE8E-ijowRreq6CJJBZjwiRfOVk_mkfQQ="}, true}, |
| 237 | {"http://test/image", Options{Signature: "NDx5zZHx7QfE8E-ijowRreq6CJJBZjwiRfOVk_mkfQQ"}, true}, |
| 238 | {"http://test/image", emptyOptions, false}, |
| 239 | // url-only signature with options |
| 240 | {"http://test/image", Options{Signature: "NDx5zZHx7QfE8E-ijowRreq6CJJBZjwiRfOVk_mkfQQ", Rotate: 90}, true}, |
| 241 | // signature calculated from url plus options |
| 242 | {"http://test/image", Options{Signature: "ZGTzEm32o4iZ7qcChls3EVYaWyrDd9u0etySo0-WkF8=", Rotate: 90}, true}, |
| 243 | // invalid base64 encoded signature |
| 244 | {"http://test/image", Options{Signature: "!!"}, false}, |
| 245 | } |
| 246 | |
| 247 | for _, tt := range tests { |
| 248 | u, err := url.Parse(tt.url) |
| 249 | if err != nil { |
| 250 | t.Errorf("error parsing url %q: %v", tt.url, err) |
| 251 | } |
| 252 | req := &Request{u, tt.options, &http.Request{}} |
| 253 | if got, want := validSignature(key, req), tt.valid; got != want { |
| 254 | t.Errorf("validSignature(%v, %v) returned %v, want %v", key, req, got, want) |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | func TestShould304(t *testing.T) { |
| 260 | tests := []struct { |
nothing calls this directly
no test coverage detected