Skip to content

Commit

Permalink
fix: update PAP to use inherited instead of unspecified (#1051)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWhitehead committed Sep 28, 2021
1 parent 2e7f041 commit 6d73e46
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Expand Up @@ -113,13 +113,19 @@ public com.google.api.services.storage.model.Bucket apply(BucketInfo bucketInfo)
*/
public enum PublicAccessPrevention {
ENFORCED("enforced"),
/** Default value for Public Access Prevention */
UNSPECIFIED("unspecified"),
/**
* Default value for Public Access Prevention
*
* @deprecated use {@link #INHERITED}
*/
@Deprecated
UNSPECIFIED("inherited"),
/**
* If the api returns a value that isn't defined in {@link PublicAccessPrevention} this value
* will be returned.
*/
UNKNOWN(null);
UNKNOWN(null),
INHERITED("inherited");

private final String value;

Expand All @@ -133,10 +139,14 @@ public String getValue() {

public static PublicAccessPrevention parse(String value) {
String upper = value.toUpperCase();
try {
return valueOf(upper);
} catch (IllegalArgumentException ignore) {
return UNKNOWN;
switch (upper) {
case "ENFORCED":
return ENFORCED;
case "UNSPECIFIED":
case "INHERITED":
return INHERITED;
default:
return UNKNOWN;
}
}
}
Expand Down Expand Up @@ -300,7 +310,7 @@ Builder setUniformBucketLevelAccessLockedTime(Long uniformBucketLevelAccessLocke

/**
* Sets the bucket's Public Access Prevention configuration. Currently supported options are
* {@link PublicAccessPrevention#UNSPECIFIED} or {@link PublicAccessPrevention#ENFORCED}
* {@link PublicAccessPrevention#INHERITED} or {@link PublicAccessPrevention#ENFORCED}
*
* @see <a
* href="https://cloud.google.com/storage/docs/public-access-prevention">public-access-prevention</a>
Expand Down
Expand Up @@ -3296,7 +3296,7 @@ private Bucket generatePublicAccessPreventionBucket(String bucketName, boolean e
.setPublicAccessPrevention(
enforced
? BucketInfo.PublicAccessPrevention.ENFORCED
: BucketInfo.PublicAccessPrevention.UNSPECIFIED)
: BucketInfo.PublicAccessPrevention.INHERITED)
.build())
.build());
}
Expand Down Expand Up @@ -3389,7 +3389,7 @@ public void testUBLAWithPublicAccessPreventionOnBucket() throws Exception {
Bucket bucket = generatePublicAccessPreventionBucket(papBucket, false);
assertEquals(
bucket.getIamConfiguration().getPublicAccessPrevention(),
BucketInfo.PublicAccessPrevention.UNSPECIFIED);
BucketInfo.PublicAccessPrevention.INHERITED);
assertFalse(bucket.getIamConfiguration().isUniformBucketLevelAccessEnabled());
assertFalse(bucket.getIamConfiguration().isBucketPolicyOnlyEnabled());

Expand Down

0 comments on commit 6d73e46

Please sign in to comment.