[improve][test] Setup broker client for TokenOauth2AuthenticatedProducerConsumerTest
@@ -35,6 +35,7 @@ import org.apache.pulsar.broker.authentication.AuthenticationProviderToken;
import org.apache.pulsar.client.admin.PulsarAdmin;
import org.apache.pulsar.client.impl.ProducerImpl;
import org.apache.pulsar.client.impl.auth.oauth2.AuthenticationFactoryOAuth2;
+import org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2;
import org.apache.pulsar.common.policies.data.ClusterData;
import org.apache.pulsar.common.policies.data.TenantInfoImpl;
import org.awaitility.Awaitility;
@@ -61,6 +62,8 @@ public class TokenOauth2AuthenticatedProducerConsumerTest extends ProducerConsum
// Credentials File, which contains "client_id" and "client_secret"
private final String CREDENTIALS_FILE = "./src/test/resources/authentication/token/credentials_file.json";
+ private final String ISSUER_URL = "https://dev-kt-aa9ne.us.auth0.com";
+ private final String AUDIENCE = "https://dev-kt-aa9ne.us.auth0.com/api/v2/";
@BeforeMethod(alwaysRun = true)
@Override
@@ -77,6 +80,13 @@ public class TokenOauth2AuthenticatedProducerConsumerTest extends ProducerConsum
providers.add(AuthenticationProviderToken.class.getName());
conf.setAuthenticationProviders(providers);
+ conf.setBrokerClientAuthenticationPlugin(AuthenticationOAuth2.class.getName());
+ conf.setBrokerClientAuthenticationParameters("{\n"
+ + " \"privateKey\": \"" + CREDENTIALS_FILE + "\",\n"
+ + " \"issuerUrl\": \"" + ISSUER_URL + "\",\n"
+ + " \"audience\": \"" + AUDIENCE + "\",\n"
+ + "}\n");
+
conf.setClusterName("test");
// Set provider domain name
@@ -94,9 +104,9 @@ public class TokenOauth2AuthenticatedProducerConsumerTest extends ProducerConsum
// AuthenticationOAuth2
Authentication authentication = AuthenticationFactoryOAuth2.clientCredentials(
- new URL("https://dev-kt-aa9ne.us.auth0.com"),
+ new URL(ISSUER_URL),
path.toUri().toURL(), // key file path
- "https://dev-kt-aa9ne.us.auth0.com/api/v2/"
+ AUDIENCE
);
admin = spy(PulsarAdmin.builder().serviceHttpUrl(brokerUrl.toString())
