diff --git a/api/client/src/test/java/org/projectnessie/client/auth/oauth2/TestOAuth2ClientConfig.java b/api/client/src/test/java/org/projectnessie/client/auth/oauth2/TestOAuth2ClientConfig.java index 7e803b4776c..4e363cc6581 100644 --- a/api/client/src/test/java/org/projectnessie/client/auth/oauth2/TestOAuth2ClientConfig.java +++ b/api/client/src/test/java/org/projectnessie/client/auth/oauth2/TestOAuth2ClientConfig.java @@ -54,6 +54,7 @@ import static org.projectnessie.client.NessieConfigConstants.CONF_NESSIE_OAUTH2_USERNAME; import static org.projectnessie.client.auth.oauth2.TokenExchangeConfig.CURRENT_ACCESS_TOKEN; import static org.projectnessie.client.auth.oauth2.TokenExchangeConfig.CURRENT_REFRESH_TOKEN; +import static org.projectnessie.client.auth.oauth2.TokenExchangeConfig.NO_TOKEN; import com.google.common.collect.ImmutableMap; import java.net.URI; @@ -465,4 +466,35 @@ void testTokenExchangeDynamicTokens() { assertThat(actorToken.getPayload()).isEqualTo("dynamic-refresh"); assertThat(actorToken.getTokenType()).isEqualTo(TypedToken.URN_REFRESH_TOKEN); } + + @Test + void testTokenExchangeNoActorToken() { + ImmutableMap map = + ImmutableMap.builder() + .put(CONF_NESSIE_OAUTH2_TOKEN_EXCHANGE_ENABLED, "true") + .put(CONF_NESSIE_OAUTH2_TOKEN_EXCHANGE_ACTOR_TOKEN, NO_TOKEN) + .build(); + OAuth2ClientConfig config = + OAuth2ClientConfig.builder() + .issuerUrl(URI.create("https://example.com/")) + .clientId("Client") + .clientSecret("w00t") + .tokenExchangeConfig(TokenExchangeConfig.fromConfigSupplier(map::get)) + .build(); + TypedToken subjectToken = + config + .getTokenExchangeConfig() + .getSubjectTokenProvider() + .apply(AccessToken.of("dynamic-access", "Bearer", null), null); + assertThat(subjectToken.getPayload()).isEqualTo("dynamic-access"); + assertThat(subjectToken.getTokenType()).isEqualTo(TypedToken.URN_ACCESS_TOKEN); + TypedToken actorToken = + config + .getTokenExchangeConfig() + .getActorTokenProvider() + .apply( + AccessToken.of("dynamic-access", "Bearer", null), + RefreshToken.of("dynamic-refresh", null)); + assertThat(actorToken).isNull(); + } }