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

Implemented SAS for STG 73 #13244

Merged
merged 4 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public final class BlobContainerSasPermission {

private boolean listPermission;

private boolean tagsPermission;

/**
* Initializes an {@code BlobContainerSasPermission} object with all fields set to false.
*/
Expand All @@ -41,7 +43,7 @@ public BlobContainerSasPermission() {
*
* @param permString A {@code String} which represents the {@code BlobContainerSasPermission}.
* @return A {@code BlobContainerSasPermission} generated from the given {@code String}.
* @throws IllegalArgumentException If {@code permString} contains a character other than r, a, c, w, d, x or l.
* @throws IllegalArgumentException If {@code permString} contains a character other than r, a, c, w, d, x, l or t.
*/
public static BlobContainerSasPermission parse(String permString) {
BlobContainerSasPermission permissions = new BlobContainerSasPermission();
Expand Down Expand Up @@ -70,6 +72,9 @@ public static BlobContainerSasPermission parse(String permString) {
case 'l':
permissions.listPermission = true;
break;
case 't':
permissions.tagsPermission = true;
break;
default:
throw new IllegalArgumentException(
String.format(Locale.ROOT, Constants.ENUM_COULD_NOT_BE_PARSED_INVALID_VALUE,
Expand Down Expand Up @@ -205,6 +210,24 @@ public BlobContainerSasPermission setListPermission(boolean hasListPermission) {
return this;
}

/**
* @return the tags permission status.
*/
public boolean hasTagsPermission() {
return tagsPermission;
}

/**
* Sets the tags permission status.
*
* @param tagsPermission Permission status to set
* @return the updated BlobContainerSasPermission object.
*/
public BlobContainerSasPermission setTagsPermission(boolean tagsPermission) {
this.tagsPermission = tagsPermission;
return this;
}

/**
* Converts the given permissions to a {@code String}. Using this method will guarantee the permissions are in an
* order accepted by the service.
Expand Down Expand Up @@ -245,6 +268,10 @@ public String toString() {
builder.append('l');
}

if (this.tagsPermission) {
builder.append('t');
}

return builder.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public final class BlobSasPermission {

private boolean deleteVersionPermission;

private boolean tagsPermission;

/**
* Initializes a {@code BlobSasPermission} object with all fields set to false.
*/
Expand All @@ -39,7 +41,7 @@ public BlobSasPermission() {
*
* @param permString A {@code String} which represents the {@code BlobSasPermission}.
* @return A {@code BlobSasPermission} generated from the given {@code String}.
* @throws IllegalArgumentException If {@code permString} contains a character other than r, a, c, w, d or x.
* @throws IllegalArgumentException If {@code permString} contains a character other than r, a, c, w, d, x or t.
*/
public static BlobSasPermission parse(String permString) {
BlobSasPermission permissions = new BlobSasPermission();
Expand All @@ -65,6 +67,9 @@ public static BlobSasPermission parse(String permString) {
case 'x':
permissions.deleteVersionPermission = true;
break;
case 't':
permissions.tagsPermission = true;
break;
default:
throw new IllegalArgumentException(
String.format(Locale.ROOT, Constants.ENUM_COULD_NOT_BE_PARSED_INVALID_VALUE,
Expand Down Expand Up @@ -182,6 +187,24 @@ public BlobSasPermission setDeleteVersionPermission(boolean hasDeleteVersionPerm
return this;
}

/**
* @return the tags permission status.
*/
public boolean hasTagsPermission() {
return tagsPermission;
}

/**
* Sets the tags permission status.
*
* @param tagsPermission Permission status to set
* @return the updated BlobSasPermission object.
*/
public BlobSasPermission setTagsPermission(boolean tagsPermission) {
this.tagsPermission = tagsPermission;
return this;
}

/**
* Converts the given permissions to a {@code String}. Using this method will guarantee the permissions are in an
* order accepted by the service.
Expand Down Expand Up @@ -219,6 +242,10 @@ public String toString() {
builder.append('x');
}

if (this.tagsPermission) {
builder.append('t');
}

return builder.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,38 @@ class BlobAPITest extends APISpec {
bc.createSnapshotWithResponse(null, null, null, null).getStatusCode() == 201
}

def "getSnapshot"() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both of these moved from HelperTest

setup:
def data = "test".getBytes()
def blobName = generateBlobName()
def bu = cc.getBlobClient(blobName).getBlockBlobClient()
bu.upload(new ByteArrayInputStream(data), data.length)
def snapshotId = bu.createSnapshot().getSnapshotId()

when:
def snapshotBlob = cc.getBlobClient(blobName, snapshotId).getBlockBlobClient()

then:
snapshotBlob.getSnapshotId() == snapshotId
bu.getSnapshotId() == null
}

def "isSnapshot"() {
setup:
def data = "test".getBytes()
def blobName = generateBlobName()
def bu = cc.getBlobClient(blobName).getBlockBlobClient()
bu.upload(new ByteArrayInputStream(data), data.length)
def snapshotId = bu.createSnapshot().getSnapshotId()

when:
def snapshotBlob = cc.getBlobClient(blobName, snapshotId).getBlockBlobClient()

then:
snapshotBlob.isSnapshot()
!bu.isSnapshot()
}

@Unroll
def "Snapshot metadata"() {
setup:
Expand Down
Loading