onobc opened a new pull request, #18358: URL: https://github.com/apache/pulsar/pull/18358
### Motivation Authentication for the admin client can not be specified on the `PulsarAdminBuilder` using configuration properties only. The `PulsarClientBuilder::authentication` method must be called to set the authentication, currently. This is inconsistent w/ the regular PulsarClient which does in fact check for the auth properties [here](https://github.com/apache/pulsar/blob/a2c15340d3a73401b57574a4032ca375bde502bc/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java#L192). #### Example This works ```java AuthenticationBasic auth = new AuthenticationBasic(); auth.configure("{\"userId\":\"foo\", \"password\":\"bar\"}"); PulsarAdmin adminWithAuth = PulsarAdmin.builder() .serviceHttpUrl("...") .authentication(auth) .build(); ``` This does not work ```java Map<String, Object> config = new HashMap<>(); config.put("authPluginClassName", "org.apache.pulsar.client.impl.auth.AuthenticationBasic"); config.put("authParams", "{\"userId\":\"foo\", \"password\":\"bar\"}"); PulsarAdmin adminWithoutAuth = PulsarAdmin.builder() .serviceHttpUrl("...") .loadConf(config) .build(); ``` ### Modifications The `ClientBuilderImpl::loadConf` and `PusarAdminBuilderImpl::loadConf` now use `authPluginClassName` and one of `authParams` or `authParamsMap` to set authentication. Since the authentication is correctly set by `ClientBuilderImpl`, the code to set the authentication can be removed from `PulsarClientImpl::new` This change also adds a new unit test class for this functionality. ### Verifying this change - [ ] Make sure that the change passes the CI checks. This change added tests and can be verified as follows: - Run `PulsarClientImplTest::*` - Run `PulsarAdminImplTest::*` ### Documentation - [ ] `doc` <!-- Your PR contains doc changes --> - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later --> - [x] `doc-not-needed` <!-- Your PR changes do not impact docs --> - [ ] `doc-complete` <!-- Docs have been already added --> ### Matching PR in forked repository PR in forked repository: https://github.com/onobc/pulsar/pull/1 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
