You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/07/26 02:26:19 UTC

[GitHub] [pulsar] Technoboy- commented on a diff in pull request #16781: [improve] [admin] [PIP-179] Dynamic configuration for check unknown request parameters

Technoboy- commented on code in PR #16781:
URL: https://github.com/apache/pulsar/pull/16781#discussion_r929467901


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminRestTest.java:
##########
@@ -60,15 +65,36 @@ public void testRejectUnknownEntityProperties() throws Exception{
         Response response = target.request(MediaType.APPLICATION_JSON_TYPE).buildPost(Entity.json(data)).invoke();
         Assert.assertTrue(response.getStatus() / 200 == 1);
         // Enabled feature, bad request response.
-        pulsar.getWebService().getSharedUnknownPropertyHandler().setSkipUnknownProperty(false);
+        admin.brokers().updateDynamicConfiguration("httpRequestsFailOnUnknownPropertiesEnabled", "true");
+        Awaitility.await().atMost(2, TimeUnit.SECONDS).until(
+                () -> !pulsar.getWebService().getSharedUnknownPropertyHandler().isSkipUnknownProperty()
+        );
         response = target.request(MediaType.APPLICATION_JSON_TYPE).buildPost(Entity.json(data)).invoke();
+        Assert.assertEquals(MediaType.valueOf(MediaType.TEXT_PLAIN), response.getMediaType());
+        String responseBody = parseResponseEntity(response.getEntity());
+        Assert.assertEquals(responseBody, "Unknown property retention_time_in_minutes, perhaps you want to use"
+                + " one of these: [retentionSizeInMB, retentionTimeInMinutes]");
         Assert.assertEquals(response.getStatus(), 400);
         // Disabled feature, response success.
-        pulsar.getWebService().getSharedUnknownPropertyHandler().setSkipUnknownProperty(true);
+        admin.brokers().updateDynamicConfiguration("httpRequestsFailOnUnknownPropertiesEnabled", "false");
+        Awaitility.await().atMost(2, TimeUnit.SECONDS).until(
+                () -> pulsar.getWebService().getSharedUnknownPropertyHandler().isSkipUnknownProperty()
+        );
         response = target.request(MediaType.APPLICATION_JSON_TYPE).buildPost(Entity.json(data)).invoke();
         Assert.assertTrue(response.getStatus() / 200 == 1);
     }
 
+    private String parseResponseEntity(Object entity) throws Exception {
+        InputStream in = (InputStream) entity;
+        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in));

Review Comment:
   Need to close the `bufferedReader`



-- 
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: commits-unsubscribe@pulsar.apache.org

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