You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by "Arsnael (via GitHub)" <gi...@apache.org> on 2023/01/27 07:20:32 UTC

[GitHub] [james-project] Arsnael commented on a diff in pull request #1409: Adds minimal pulsar authentication support to pulsar configuration

Arsnael commented on code in PR #1409:
URL: https://github.com/apache/james-project/pull/1409#discussion_r1088646670


##########
backends-common/pulsar/src/test/java/org/apache/james/backends/pulsar/PulsarConfigurationTest.java:
##########
@@ -155,8 +158,106 @@ void fromShouldReturnTheConfigurationWhenRequiredParametersAreGiven() {
 
         configuration.addProperty("namespace", namespace);
         assertThat(PulsarConfiguration.from(configuration))
-                .isEqualTo(new PulsarConfiguration(brokerUri, adminUri, new Namespace(namespace)));
+                .isEqualTo(new PulsarConfiguration(brokerUri, adminUri, new Namespace(namespace), Auth.noAuth()));
     }
+    @Test
+    void fromShouldThrowWithTokenAuthenticationWhenTokenIsMissing() {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        String brokerUri = "pulsar://localhost.test:6650/";
+        String adminUri = "http://localhost:8090";
+        String authenticationType = "token";
+
+        configuration.addProperty("broker.uri", brokerUri);
+        configuration.addProperty("admin.uri", adminUri);
+        configuration.addProperty("authentication.type", authenticationType);
+
+        String namespace = "namespace";
+
+        configuration.addProperty("namespace", namespace);
+        assertThatThrownBy(() -> PulsarConfiguration.from(configuration))
+                .isInstanceOf(IllegalStateException.class)
+                .hasMessage("You need to specify a non-empty value for " + PulsarConfiguration.AUTHENTICATION_TOKEN_PROPERTY_NAME());
+    }
+    @Test
+    void fromShouldReturnTheConfigurationWithTokenAuthenticationWhenRequiredParametersAreGiven() {

Review Comment:
   Confused with the name of the test, as it seems it's basic auth and not token auth that is being tested here 
   
   Also a blank line between each test would help visibility :)



##########
backends-common/pulsar/src/test/java/org/apache/james/backends/pulsar/PulsarConfigurationTest.java:
##########
@@ -155,8 +158,106 @@ void fromShouldReturnTheConfigurationWhenRequiredParametersAreGiven() {
 
         configuration.addProperty("namespace", namespace);
         assertThat(PulsarConfiguration.from(configuration))
-                .isEqualTo(new PulsarConfiguration(brokerUri, adminUri, new Namespace(namespace)));
+                .isEqualTo(new PulsarConfiguration(brokerUri, adminUri, new Namespace(namespace), Auth.noAuth()));
     }
+    @Test
+    void fromShouldThrowWithTokenAuthenticationWhenTokenIsMissing() {

Review Comment:
   I don't see the test that it returns successfully the conf if token auth params are valid



-- 
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: notifications-unsubscribe@james.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org