-
Notifications
You must be signed in to change notification settings - Fork 849
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
Containeracl #422
Changes from all commits
0bfe6be
daf1095
5161cd3
15e14b1
4a35137
ab94ed9
080d2ef
db88e32
473d57d
5b3af80
63cb499
309d477
f9a0fd1
4184e8d
cce5bd0
907bd6c
6083a83
ac366db
362ef1d
5bf4861
831ca62
522dfdc
f22ad3d
bb22d80
21f854e
7287de8
84c0f6c
0df936c
24913ed
6a9edd1
3218bf1
5b8d080
ded4c38
c47bff4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -678,6 +678,117 @@ func (s *StorageBlobSuite) TestSetBlobProperties(c *chk.C) { | |
c.Check(mPut.ContentLanguage, chk.Equals, props.ContentLanguage) | ||
} | ||
|
||
func (s *StorageBlobSuite) createContainerPermissions(accessType ContainerAccessType, | ||
timeout int, leaseID string, ID string, canRead bool, | ||
canWrite bool, canDelete bool) ContainerPermissions { | ||
perms := ContainerPermissions{} | ||
perms.AccessOptions.ContainerAccess = accessType | ||
perms.AccessOptions.Timeout = timeout | ||
perms.AccessOptions.LeaseID = leaseID | ||
|
||
if ID != "" { | ||
perms.AccessPolicy.ID = ID | ||
perms.AccessPolicy.StartTime = time.Now() | ||
perms.AccessPolicy.ExpiryTime = time.Now().Add(time.Hour * 10) | ||
perms.AccessPolicy.CanRead = canRead | ||
perms.AccessPolicy.CanWrite = canWrite | ||
perms.AccessPolicy.CanDelete = canDelete | ||
} | ||
|
||
return perms | ||
} | ||
|
||
func (s *StorageBlobSuite) TestSetContainerPermissionsWithTimeoutSuccessfully(c *chk.C) { | ||
cli := getBlobClient(c) | ||
cnt := randContainer() | ||
|
||
c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil) | ||
defer cli.deleteContainer(cnt) | ||
|
||
perms := s.createContainerPermissions(ContainerAccessTypeBlob, 30, "", "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTa=", true, true, true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a question, where does the ID come from? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just made it up (well stole from a previous test). Just needed to be a unique string... and that's pretty unique :) |
||
|
||
err := cli.SetContainerPermissions(cnt, perms) | ||
c.Assert(err, chk.IsNil) | ||
} | ||
|
||
func (s *StorageBlobSuite) TestSetContainerPermissionsSuccessfully(c *chk.C) { | ||
cli := getBlobClient(c) | ||
cnt := randContainer() | ||
|
||
c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil) | ||
defer cli.deleteContainer(cnt) | ||
|
||
perms := s.createContainerPermissions(ContainerAccessTypeBlob, 0, "", "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTa=", true, true, true) | ||
|
||
err := cli.SetContainerPermissions(cnt, perms) | ||
c.Assert(err, chk.IsNil) | ||
} | ||
|
||
func (s *StorageBlobSuite) TestSetThenGetContainerPermissionsSuccessfully(c *chk.C) { | ||
cli := getBlobClient(c) | ||
cnt := randContainer() | ||
|
||
c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil) | ||
defer cli.deleteContainer(cnt) | ||
|
||
perms := s.createContainerPermissions(ContainerAccessTypeBlob, 0, "", "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTa=", true, true, true) | ||
|
||
err := cli.SetContainerPermissions(cnt, perms) | ||
c.Assert(err, chk.IsNil) | ||
|
||
returnedPerms, err := cli.GetContainerPermissions(cnt, 0, "") | ||
c.Assert(err, chk.IsNil) | ||
|
||
// check container permissions itself. | ||
c.Assert(returnedPerms.ContainerAccess, chk.Equals, perms.AccessOptions.ContainerAccess) | ||
|
||
// now check policy set. | ||
c.Assert(returnedPerms.AccessPolicy.SignedIdentifiers, chk.HasLen, 1) | ||
c.Assert(returnedPerms.AccessPolicy.SignedIdentifiers[0].ID, chk.Equals, perms.AccessPolicy.ID) | ||
|
||
// test timestamps down the second | ||
// rounding start/expiry time original perms since the returned perms would have been rounded. | ||
// so need rounded vs rounded. | ||
c.Assert(returnedPerms.AccessPolicy.SignedIdentifiers[0].AccessPolicy.StartTime.Round(time.Second).Format(time.RFC1123), chk.Equals, perms.AccessPolicy.StartTime.Round(time.Second).Format(time.RFC1123)) | ||
c.Assert(returnedPerms.AccessPolicy.SignedIdentifiers[0].AccessPolicy.ExpiryTime.Round(time.Second).Format(time.RFC1123), chk.Equals, perms.AccessPolicy.ExpiryTime.Round(time.Second).Format(time.RFC1123)) | ||
c.Assert(returnedPerms.AccessPolicy.SignedIdentifiers[0].AccessPolicy.Permission, chk.Equals, "rwd") | ||
} | ||
|
||
func (s *StorageBlobSuite) TestSetContainerPermissionsOnlySuccessfully(c *chk.C) { | ||
cli := getBlobClient(c) | ||
cnt := randContainer() | ||
|
||
c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil) | ||
defer cli.deleteContainer(cnt) | ||
|
||
perms := s.createContainerPermissions(ContainerAccessTypeBlob, 0, "", "", true, true, true) | ||
|
||
err := cli.SetContainerPermissions(cnt, perms) | ||
c.Assert(err, chk.IsNil) | ||
} | ||
|
||
func (s *StorageBlobSuite) TestSetThenGetContainerPermissionsOnlySuccessfully(c *chk.C) { | ||
cli := getBlobClient(c) | ||
cnt := randContainer() | ||
|
||
c.Assert(cli.CreateContainer(cnt, ContainerAccessTypePrivate), chk.IsNil) | ||
defer cli.deleteContainer(cnt) | ||
|
||
perms := s.createContainerPermissions(ContainerAccessTypeBlob, 0, "", "", true, true, true) | ||
|
||
err := cli.SetContainerPermissions(cnt, perms) | ||
c.Assert(err, chk.IsNil) | ||
|
||
returnedPerms, err := cli.GetContainerPermissions(cnt, 0, "") | ||
c.Assert(err, chk.IsNil) | ||
|
||
// check container permissions itself. | ||
c.Assert(returnedPerms.ContainerAccess, chk.Equals, perms.AccessOptions.ContainerAccess) | ||
|
||
// now check there are NO policies set | ||
c.Assert(returnedPerms.AccessPolicy.SignedIdentifiers, chk.HasLen, 0) | ||
} | ||
|
||
func (s *StorageBlobSuite) TestAcquireLeaseWithNoProposedLeaseID(c *chk.C) { | ||
cli := getBlobClient(c) | ||
cnt := randContainer() | ||
|
@@ -690,6 +801,7 @@ func (s *StorageBlobSuite) TestAcquireLeaseWithNoProposedLeaseID(c *chk.C) { | |
|
||
_, err := cli.AcquireLease(cnt, blob, 30, "") | ||
c.Assert(err, chk.NotNil) | ||
|
||
} | ||
|
||
func (s *StorageBlobSuite) TestAcquireLeaseWithProposedLeaseID(c *chk.C) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line for readability