(t *testing.T)
| 204 | } |
| 205 | |
| 206 | func TestReferrerMatches(t *testing.T) { |
| 207 | hosts := []string{"a.test"} |
| 208 | |
| 209 | tests := []struct { |
| 210 | referrer string |
| 211 | valid bool |
| 212 | }{ |
| 213 | {"", false}, |
| 214 | {"%", false}, |
| 215 | {"http://a.test/", true}, |
| 216 | {"http://b.test/", false}, |
| 217 | } |
| 218 | |
| 219 | for _, tt := range tests { |
| 220 | r, _ := http.NewRequest("GET", "/", nil) |
| 221 | r.Header.Set("Referer", tt.referrer) |
| 222 | if got, want := referrerMatches(hosts, r), tt.valid; got != want { |
| 223 | t.Errorf("referrerMatches(%v, %v) returned %v, want %v", hosts, r, got, want) |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | func TestValidSignature(t *testing.T) { |
| 229 | key := []byte("c0ffee") |
nothing calls this directly
no test coverage detected