309
310
"http://"+url.QueryEscape(account)+".blob.example.com")
312
func (*TestStorageContext) TestGetAccountURLDefaultsToInternationalEndpoint(c *C) {
313
func (*TestStorageContext) TestGetAccountURLRequiresEndpoint(c *C) {
313
314
context := StorageContext{Account: "myaccount"}
315
context.getAccountURL(),
317
"https://myaccount.blob.core.windows.net/")
316
context.getAccountURL,
318
errors.New("no Azure blob storage endpoint specified"))
320
func (suite *TestStorageContext) TestGetContainerURL(c *C) {
321
func (suite *TestStorageContext) TestGetContainerURLAddsContainer(c *C) {
321
322
account := makeNastyURLUnfriendlyString()
322
323
container := makeNastyURLUnfriendlyString()
323
context := StorageContext{Account: account}
324
context := StorageContext{
326
AzureEndpoint: "http://example.com/",
325
329
context.getContainerURL(container),
327
"https://"+url.QueryEscape(account)+".blob.core.windows.net/"+url.QueryEscape(container))
331
"http://"+url.QueryEscape(account)+".blob.example.com/"+url.QueryEscape(container))
334
func (suite *TestStorageContext) TestGetContainerURLAddsSlashIfNeeded(c *C) {
335
context := StorageContext{
337
AzureEndpoint: "http://example.com",
340
context.getContainerURL("container"),
342
"http://account.blob.example.com/container")
330
345
func (suite *TestStorageContext) TestGetFileURL(c *C) {
331
346
account := makeNastyURLUnfriendlyString()
332
347
container := makeNastyURLUnfriendlyString()
333
348
file := makeNastyURLUnfriendlyString()
334
context := StorageContext{Account: account}
349
context := StorageContext{
351
AzureEndpoint: "http://example.com/",
336
354
context.GetFileURL(container, file),
338
"https://"+url.QueryEscape(account)+".blob.core.windows.net/"+url.QueryEscape(container)+"/"+url.QueryEscape(file))
356
"http://"+url.QueryEscape(account)+".blob.example.com/"+url.QueryEscape(container)+"/"+url.QueryEscape(file))
341
359
func (suite *TestStorageContext) TestGetSignedFileURL(c *C) {
343
361
container := "container"
344
362
file := "/a/file"
345
363
key := base64.StdEncoding.EncodeToString([]byte("dummykey"))
346
context := StorageContext{Account: account, Key: key}
364
context := StorageContext{
367
AzureEndpoint: "http://example.com/",
347
369
expires := time.Now()
349
371
signedURL := context.GetAnonymousFileURL(container, file, expires)
408
430
response := makeHttpResponse(http.StatusOK, responseBody)
409
431
transport := &TestTransport{Response: response}
410
432
context := makeStorageContext(transport)
433
context.AzureEndpoint = "http://example.com/"
411
434
request := &ListContainersRequest{Marker: ""}
412
435
results, err := context.ListContainers(request)
413
436
c.Assert(err, IsNil)
414
437
c.Check(transport.Request.URL.String(), Equals, fmt.Sprintf(
415
"https://%s.blob.core.windows.net/?comp=list", context.Account))
438
"http://%s.blob.example.com/?comp=list", context.Account))
416
439
c.Check(transport.Request.Header.Get("Authorization"), Not(Equals), "")
417
440
c.Assert(results, NotNil)
418
441
c.Assert(results.Containers[0].Name, Equals, "name-value")
666
689
response := makeHttpResponse(http.StatusCreated, "")
667
690
transport := &TestTransport{Response: response}
668
691
context := makeStorageContext(transport)
692
context.AzureEndpoint = "http://example.com/"
669
693
containerName := MakeRandomString(10)
670
694
err := context.CreateContainer(containerName)
671
695
c.Assert(err, IsNil)
672
696
c.Check(transport.Request.URL.String(), Equals, fmt.Sprintf(
673
"https://%s.blob.core.windows.net/%s?restype=container",
697
"http://%s.blob.example.com/%s?restype=container",
674
698
context.Account, containerName))
675
699
c.Check(transport.Request.Header.Get("Authorization"), Not(Equals), "")
720
744
response := makeHttpResponse(http.StatusAccepted, "")
721
745
transport := &TestTransport{Response: response}
722
746
context := makeStorageContext(transport)
747
context.AzureEndpoint = "http://example.com/"
723
748
containerName := MakeRandomString(10)
724
749
err := context.DeleteContainer(containerName)
725
750
c.Assert(err, IsNil)
726
751
c.Check(transport.Request.URL.String(), Equals, fmt.Sprintf(
727
"https://%s.blob.core.windows.net/%s?restype=container",
752
"http://%s.blob.example.com/%s?restype=container",
728
753
context.Account, containerName))
729
754
c.Check(transport.Request.Method, Equals, "DELETE")
730
755
c.Check(transport.Request.Header.Get("Authorization"), Not(Equals), "")
787
812
transport := &TestTransport{Response: response}
788
813
context := makeStorageContext(transport)
814
context.AzureEndpoint = "http://example.com/"
789
815
containerName := MakeRandomString(10)
790
816
props, err := context.GetContainerProperties(containerName)
791
817
c.Assert(err, IsNil)
792
818
c.Check(transport.Request.URL.String(), Equals, fmt.Sprintf(
793
"https://%s.blob.core.windows.net/%s?restype=container",
819
"http://%s.blob.example.com/%s?restype=container",
794
820
context.Account, containerName))
795
821
c.Check(transport.Request.Method, Equals, "GET")
796
822
c.Check(transport.Request.Header.Get("Authorization"), Not(Equals), "")
1099
1125
response := makeHttpResponse(http.StatusCreated, "")
1100
1126
transport := &TestTransport{Response: response}
1101
1127
context := makeStorageContext(transport)
1128
context.AzureEndpoint = "http://example.com/"
1102
1129
blocklist := &BlockList{}
1103
1130
blocklist.Add(BlockListLatest, "b1")
1104
1131
blocklist.Add(BlockListLatest, "b2")
1108
1135
c.Check(transport.Request.Method, Equals, "PUT")
1109
1136
c.Check(transport.Request.URL.String(), Equals, fmt.Sprintf(
1110
"https://%s.blob.core.windows.net/container/blobname?comp=blocklist",
1137
"http://%s.blob.example.com/container/blobname?comp=blocklist",
1111
1138
context.Account))
1112
1139
c.Check(transport.Request.Header.Get("Authorization"), Not(Equals), "")
1340
1367
response := makeHttpResponse(http.StatusOK, "")
1341
1368
transport := &TestTransport{Response: response}
1342
1369
context := makeStorageContext(transport)
1370
context.AzureEndpoint = "http://example.com/"
1343
1371
err := context.SetContainerACL(&SetContainerACLRequest{
1344
1372
Container: "mycontainer", Access: "container"})
1347
1375
c.Check(transport.Request.Method, Equals, "PUT")
1348
1376
c.Check(transport.Request.URL.String(), Matches,
1350
"https://%s.blob.core.windows.net/mycontainer?.*", context.Account))
1378
"http://%s.blob.example.com/mycontainer?.*", context.Account))
1351
1379
c.Check(transport.Request.URL.Query(), DeepEquals, url.Values{
1352
1380
"comp": {"acl"},
1353
1381
"restype": {"container"},