MCPcopy Index your code
hub / github.com/perkeep/perkeep / TestStringToSign

Function TestStringToSign

internal/azure/storage/auth_test.go:39–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

37}
38
39func TestStringToSign(t *testing.T) {
40 a := Auth{
41 Account: "johnsmith",
42 }
43 tests := []reqAndExpected{
44 {`GET /photos/puppy.jpg HTTP/1.1
45Host: johnsmith.blob.core.windows.net
46Date: Tue, 27 Mar 2007 19:36:42 +0000
47
48`,
49 "GET\n\n\n\n\n\nTue, 27 Mar 2007 19:36:42 +0000\n\n\n\n\n\n/johnsmith/photos/puppy.jpg"},
50 {`PUT /photos/puppy.jpg HTTP/1.1
51Content-Type: image/jpeg
52Content-Length: 94328
53Host: johnsmith.blob.core.windows.net
54Date: Tue, 27 Mar 2007 21:15:45 +0000
55
56`,
57 "PUT\n\n\n94328\n\nimage/jpeg\nTue, 27 Mar 2007 21:15:45 +0000\n\n\n\n\n\n/johnsmith/photos/puppy.jpg"},
58 {`GET /?prefix=photos&maxResults=50&marker=puppy HTTP/1.1
59User-Agent: Mozilla/5.0
60Host: johnsmith.blob.core.windows.net
61Date: Tue, 27 Mar 2007 19:42:41 +0000
62
63`,
64 "GET\n\n\n\n\n\nTue, 27 Mar 2007 19:42:41 +0000\n\n\n\n\n\n/johnsmith/\nmarker:puppy\nmaxresults:50\nprefix:photos"},
65 {`DELETE /photos/puppy.jpg HTTP/1.1
66User-Agent: dotnet
67Host: blob.core.windows.net
68Date: Tue, 27 Mar 2007 21:20:27 +0000
69x-ms-date: Tue, 27 Mar 2007 21:20:26 +0000
70
71`,
72 "DELETE\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:Tue, 27 Mar 2007 21:20:26 +0000\n/johnsmith/photos/puppy.jpg"},
73 }
74 for idx, test := range tests {
75 got := a.stringToSign(req(test.req))
76 if got != test.expected {
77 t.Errorf("test %d: expected %q", idx, test.expected)
78 t.Errorf("test %d: got %q", idx, got)
79 }
80 }
81}
82
83func TestSignRequest(t *testing.T) {
84 r := req("GET /foo HTTP/1.1\n\n")

Callers

nothing calls this directly

Calls 2

stringToSignMethod · 0.95
reqFunction · 0.85

Tested by

no test coverage detected