Skip to content

Commit

Permalink
review: support old true value for access delegation mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dimas-b committed Aug 27, 2024
1 parent 35e0f26 commit f61ff40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.common.base.Functions;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -49,6 +50,14 @@ public static EnumSet<AccessDelegationMode> fromProtocolValuesList(String protoc
return EnumSet.noneOf(AccessDelegationMode.class);
}

// Backward-compatibility case for old clients that still use the unofficial value of `true` to
// request credential vending. Note that if the client requests `true` among other values it
// will be parsed as `UNKNOWN` (by the code below this `if`) since the client submitting
// multiple access modes is expected to be aware of the Iceberg REST API spec.
if (protocolValues.trim().toLowerCase(Locale.ROOT).equals("true")) {
return EnumSet.of(VENDED_CREDENTIALS);
}

EnumSet<AccessDelegationMode> set = EnumSet.noneOf(AccessDelegationMode.class);
Arrays.stream(protocolValues.split(",")) // per Iceberg REST Catalog spec
.map(String::trim)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,11 @@ void testUnknown() {
assertThat(fromProtocolValuesList("abc,remote-signing"))
.isEqualTo(EnumSet.of(REMOTE_SIGNING, UNKNOWN));
}

@Test
void testLegacy() {
assertThat(fromProtocolValuesList("true")).isEqualTo(EnumSet.of(VENDED_CREDENTIALS));
assertThat(fromProtocolValuesList("true, vended-credentials"))
.isEqualTo(EnumSet.of(UNKNOWN, VENDED_CREDENTIALS));
}
}

0 comments on commit f61ff40

Please sign in to comment.