Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Containeracl #422

Merged
merged 34 commits into from
Nov 8, 2016
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0bfe6be
beginning of blob lease functionality
kpfaulkner Oct 6, 2016
daf1095
breaklease with and without break period working
kpfaulkner Oct 14, 2016
5161cd3
change lease working
kpfaulkner Oct 14, 2016
15e14b1
renew lease working
kpfaulkner Oct 14, 2016
4a35137
refactor common code into leaseCommonPut
kpfaulkner Oct 15, 2016
ab94ed9
all unit tests passing
kpfaulkner Oct 16, 2016
080d2ef
tweak of godoc
kpfaulkner Oct 16, 2016
db88e32
Set container ACL initial code
kpfaulkner Oct 18, 2016
473d57d
change so param is struct and can handle optional properties
kpfaulkner Oct 18, 2016
5b3af80
adding in SAS part of permissions
kpfaulkner Oct 18, 2016
63cb499
Generate XML payload for setting permissions
kpfaulkner Oct 18, 2016
309d477
permissions working unsure about access policy:
kpfaulkner Oct 19, 2016
f9a0fd1
working on XML deserialization, WIP
kpfaulkner Oct 20, 2016
4184e8d
GetContainerPermission returning permissions correctly. Check for ref…
kpfaulkner Oct 20, 2016
cce5bd0
merged master
kpfaulkner Oct 20, 2016
907bd6c
containerACL tests in progress
kpfaulkner Oct 20, 2016
6083a83
upstream merge
kpfaulkner Oct 20, 2016
ac366db
Merge branch 'master' into containeracl
kpfaulkner Oct 20, 2016
362ef1d
SetContainerPermission and GetContainerPermission tests
kpfaulkner Oct 21, 2016
5bf4861
removing some debugging
kpfaulkner Oct 21, 2016
831ca62
formatting fix causing lint error
kpfaulkner Oct 21, 2016
522dfdc
changes based on Mcardosos' feedback.
kpfaulkner Oct 26, 2016
f22ad3d
marshalling working
kpfaulkner Oct 28, 2016
bb22d80
fixing test
kpfaulkner Oct 28, 2016
21f854e
test tweak
kpfaulkner Oct 28, 2016
7287de8
debugging tests working fine locally
kpfaulkner Oct 28, 2016
84c0f6c
rounding of access policy times
kpfaulkner Oct 28, 2016
0df936c
force rounding of dates for policy
kpfaulkner Oct 28, 2016
24913ed
changes based on review
kpfaulkner Oct 31, 2016
6a9edd1
capturing potential error from closing body
kpfaulkner Nov 2, 2016
3218bf1
change accesspolicy to convert to UTC
kpfaulkner Nov 4, 2016
5b8d080
reverting to rounding to second.
kpfaulkner Nov 4, 2016
ded4c38
rounding times for tests so test reflects reality
kpfaulkner Nov 4, 2016
c47bff4
typo
kpfaulkner Nov 4, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
all unit tests passing
kpfaulkner committed Oct 16, 2016
commit ab94ed9032349d2de370dbc6de17a00f939c1ca6
2 changes: 0 additions & 2 deletions storage/blob.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"log"
"net/http"
"net/url"
"strconv"
@@ -649,7 +648,6 @@ func (b BlobStorageClient) breakLeaseCommon(container string, name string, heade
}

for k, v := range respHeaders {
log.Println(k, v)

k = strings.ToLower(k)
if !strings.HasPrefix(k, strings.ToLower(leaseTime)) {
168 changes: 168 additions & 0 deletions storage/blob_test.go
Original file line number Diff line number Diff line change
@@ -678,6 +678,174 @@ func (s *StorageBlobSuite) TestSetBlobProperties(c *chk.C) {
c.Check(mPut.ContentLanguage, chk.Equals, props.ContentLanguage)
}

func (s *StorageBlobSuite) TestAcquireLeaseWithNoProposedLeaseID(c *chk.C) {
cli := getBlobClient(c)
cnt := randContainer()

c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil)
defer cli.deleteContainer(cnt)

blob := randName(5)
c.Assert(cli.putSingleBlockBlob(cnt, blob, []byte{}), chk.IsNil)

_, err := cli.AcquireLease(cnt, blob, 30, "")
c.Assert(err, chk.NotNil)

}

func (s *StorageBlobSuite) TestAcquireLeaseWithProposedLeaseID(c *chk.C) {
cli := getBlobClient(c)
cnt := randContainer()

c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil)
defer cli.deleteContainer(cnt)

blob := randName(5)
c.Assert(cli.putSingleBlockBlob(cnt, blob, []byte{}), chk.IsNil)

proposedLeaseID := "dfe6dde8-68d5-4910-9248-c97c61768fea"
leaseID, err := cli.AcquireLease(cnt, blob, 30, proposedLeaseID)
c.Assert(err, chk.IsNil)
c.Assert(leaseID, chk.Equals, proposedLeaseID)
}

func (s *StorageBlobSuite) TestAcquireLeaseWithBadProposedLeaseID(c *chk.C) {
cli := getBlobClient(c)
cnt := randContainer()

c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil)
defer cli.deleteContainer(cnt)

blob := randName(5)
c.Assert(cli.putSingleBlockBlob(cnt, blob, []byte{}), chk.IsNil)

proposedLeaseID := "badbadbad"
_, err := cli.AcquireLease(cnt, blob, 30, proposedLeaseID)
c.Assert(err, chk.NotNil)
}

func (s *StorageBlobSuite) TestRenewLeaseSuccessful(c *chk.C) {
cli := getBlobClient(c)
cnt := randContainer()

c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil)
defer cli.deleteContainer(cnt)

blob := randName(5)
c.Assert(cli.putSingleBlockBlob(cnt, blob, []byte{}), chk.IsNil)

proposedLeaseID := "dfe6dde8-68d5-4910-9248-c97c61768fea"
leaseID, err := cli.AcquireLease(cnt, blob, 30, proposedLeaseID)
c.Assert(err, chk.IsNil)

err = cli.RenewLease(cnt, blob, leaseID)
c.Assert(err, chk.IsNil)
}

func (s *StorageBlobSuite) TestRenewLeaseAgainstNoCurrentLease(c *chk.C) {
cli := getBlobClient(c)
cnt := randContainer()

c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil)
defer cli.deleteContainer(cnt)

blob := randName(5)
c.Assert(cli.putSingleBlockBlob(cnt, blob, []byte{}), chk.IsNil)

badLeaseID := "1f812371-a41d-49e6-b123-f4b542e85144"
err := cli.RenewLease(cnt, blob, badLeaseID)
c.Assert(err, chk.NotNil)
}

func (s *StorageBlobSuite) TestChangeLeaseSuccessful(c *chk.C) {
cli := getBlobClient(c)
cnt := randContainer()

c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil)
defer cli.deleteContainer(cnt)

blob := randName(5)
c.Assert(cli.putSingleBlockBlob(cnt, blob, []byte{}), chk.IsNil)
proposedLeaseID := "dfe6dde8-68d5-4910-9248-c97c61768fea"
leaseID, err := cli.AcquireLease(cnt, blob, 30, proposedLeaseID)
c.Assert(err, chk.IsNil)

newProposedLeaseID := "dfe6dde8-68d5-4910-9248-c97c61768fbb"
newLeaseID, err := cli.ChangeLease(cnt, blob, leaseID, newProposedLeaseID)
c.Assert(err, chk.IsNil)
c.Assert(newLeaseID, chk.Equals, newProposedLeaseID)
}

func (s *StorageBlobSuite) TestChangeLeaseNotSuccessfulbadProposedLeaseID(c *chk.C) {
cli := getBlobClient(c)
cnt := randContainer()

c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil)
defer cli.deleteContainer(cnt)

blob := randName(5)
c.Assert(cli.putSingleBlockBlob(cnt, blob, []byte{}), chk.IsNil)
proposedLeaseID := "dfe6dde8-68d5-4910-9248-c97c61768fea"
leaseID, err := cli.AcquireLease(cnt, blob, 30, proposedLeaseID)
c.Assert(err, chk.IsNil)

newProposedLeaseID := "1f812371-a41d-49e6-b123-f4b542e"
_, err = cli.ChangeLease(cnt, blob, leaseID, newProposedLeaseID)
c.Assert(err, chk.NotNil)
}

func (s *StorageBlobSuite) TestReleaseLeaseSuccessful(c *chk.C) {
cli := getBlobClient(c)
cnt := randContainer()

c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil)
defer cli.deleteContainer(cnt)

blob := randName(5)
c.Assert(cli.putSingleBlockBlob(cnt, blob, []byte{}), chk.IsNil)
proposedLeaseID := "dfe6dde8-68d5-4910-9248-c97c61768fea"
leaseID, err := cli.AcquireLease(cnt, blob, 30, proposedLeaseID)
c.Assert(err, chk.IsNil)

err = cli.ReleaseLease(cnt, blob, leaseID)
c.Assert(err, chk.IsNil)
}

func (s *StorageBlobSuite) TestReleaseLeaseNotSuccessfulBadLeaseID(c *chk.C) {
cli := getBlobClient(c)
cnt := randContainer()

c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil)
defer cli.deleteContainer(cnt)

blob := randName(5)
c.Assert(cli.putSingleBlockBlob(cnt, blob, []byte{}), chk.IsNil)
proposedLeaseID := "dfe6dde8-68d5-4910-9248-c97c61768fea"
_, err := cli.AcquireLease(cnt, blob, 30, proposedLeaseID)
c.Assert(err, chk.IsNil)

err = cli.ReleaseLease(cnt, blob, "badleaseid")
c.Assert(err, chk.NotNil)
}

func (s *StorageBlobSuite) TestBreakLeaseSuccessful(c *chk.C) {
cli := getBlobClient(c)
cnt := randContainer()

c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil)
defer cli.deleteContainer(cnt)

blob := randName(5)
c.Assert(cli.putSingleBlockBlob(cnt, blob, []byte{}), chk.IsNil)

proposedLeaseID := "dfe6dde8-68d5-4910-9248-c97c61768fea"
_, err := cli.AcquireLease(cnt, blob, 30, proposedLeaseID)
c.Assert(err, chk.IsNil)

_, err = cli.BreakLease(cnt, blob)
c.Assert(err, chk.IsNil)
}

func (s *StorageBlobSuite) TestPutEmptyBlockBlob(c *chk.C) {
cli := getBlobClient(c)
cnt := randContainer()