Replies: 1 comment
-
I had indeed forgotten this section of the docs. Adding these env vars, tc_pulsar.WithPulsarEnv("brokerClientAuthenticationPlugin", "org.apache.pulsar.client.impl.auth.AuthenticationToken"),
tc_pulsar.WithPulsarEnv("brokerClientAuthenticationParameters", fmt.Sprintf(`{"token": "%s"}`, testToken)) the standalone service comes up flawlessly. The testcontainers-go waitstrategy had also to be updated -- it worked fine with this: tc, err := tc_pulsar.RunContainer(ctx,
append(cs,
tc_pulsar.WithPulsarEnv("authenticationEnabled", "true"),
tc_pulsar.WithPulsarEnv("authorizationEnabled", "true"),
tc_pulsar.WithPulsarEnv("tokenSecretKey", testSecretKey),
tc_pulsar.WithPulsarEnv("authenticationProviders", "org.apache.pulsar.broker.authentication.AuthenticationProviderToken"),
tc_pulsar.WithPulsarEnv("brokerClientAuthenticationPlugin", "org.apache.pulsar.client.impl.auth.AuthenticationToken"),
tc_pulsar.WithPulsarEnv("brokerClientAuthenticationParameters", fmt.Sprintf(`{"token": "%s"}`, testToken)),
tc_pulsar.WithPulsarEnv("superUserRoles", "admin"),
testcontainers.WithImage("docker.io/apachepulsar/pulsar:3.2.2"),
testcontainers.WithWaitStrategy(
wait.ForHTTP("/admin/v2/clusters").
WithHeaders(map[string]string{
"Authorization": "Bearer " + testToken,
}).
WithPort("8080/tcp").
WithStatusCodeMatcher(func(status int) bool { return status == 200 }).
WithResponseMatcher(func(r io.Reader) bool {
respBytes, _ := io.ReadAll(r)
resp := string(respBytes)
return resp == `["standalone"]`
}),
),
)...)
if err != nil {
t.Fatalf("could not start pulsar: %s", err)
}
in a running apache/pulsar container. Thanks to @alpreu for helping be get unblocked 🙌 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using testcontainers-go's pulsar module to start a Pulsar instance in integration tests. It's all hunky dory until I've added some environment variables to enable authentication and authorization:
The WithPulsarEnv function will prepend PULSAR_PREFIX_ to the key and set the env var for the container. It does what it's supposed to do -- I can connect to the broker afterwards with that token, but during standalone startup, it fails to create the cluster/tenant/namespace -- So I cannot use that from my tests like I could without authentication/authorization. Am I missing something? Is this the wrong method to set up authn/authz? Thanks!
More details
These are the first few lines of container logs:
not more -- so I could have forgotten to update something else. Have I?
The first failure-ish thing I see in the logs is this:
Where the
cipot
topic suggests that it's from my test code, which tries to publish a message on that topic.However, I suspect that this is just running too early -- I can fix that. Further down in the logs, I find this:
In my reading, this means the StandaloneStarter can't create the tenant/namespace because it itself is lacking authentication. How can I configure the StandaloneStarter to use the token for authn?
Beta Was this translation helpful? Give feedback.
All reactions