| 1 | package auth |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | ) |
| 6 | |
| 7 | func TestBuildCanonicalizedStringForSharedKeyLite(t *testing.T) { |
| 8 | testData := []struct { |
| 9 | name string |
| 10 | headers map[string][]string |
| 11 | canonicalizedHeaders string |
| 12 | canonicalizedResource string |
| 13 | verb string |
| 14 | expected string |
| 15 | }{ |
| 16 | { |
| 17 | name: "completed", |
| 18 | verb: "NOM", |
| 19 | headers: map[string][]string{ |
| 20 | "Content-MD5": {"abc123"}, |
| 21 | "Content-Type": {"vnd/panda-pops+v1"}, |
| 22 | }, |
| 23 | canonicalizedHeaders: "all-the-headers", |
| 24 | canonicalizedResource: "all-the-resources", |
| 25 | expected: "NOM\n\nvnd/panda-pops+v1\n\nall-the-headers\nall-the-resources", |
| 26 | }, |
| 27 | } |
| 28 | |
| 29 | for _, test := range testData { |
| 30 | t.Logf("Test: %q", test.name) |
| 31 | actual := buildCanonicalizedStringForSharedKeyLite(test.verb, test.headers, test.canonicalizedHeaders, test.canonicalizedResource) |
| 32 | if actual != test.expected { |
| 33 | t.Fatalf("Expected %q but got %q", test.expected, actual) |
| 34 | } |
| 35 | } |
| 36 | } |