You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/02/03 06:30:55 UTC

[GitHub] [kafka] kkonstantine commented on a change in pull request #9987: KAFKA-10895: Gracefully handle invalid JAAS configs

kkonstantine commented on a change in pull request #9987:
URL: https://github.com/apache/kafka/pull/9987#discussion_r569160025



##########
File path: connect/basic-auth-extension/src/test/java/org/apache/kafka/connect/rest/basic/auth/extension/BasicAuthSecurityRestExtensionTest.java
##########
@@ -63,4 +69,25 @@ public void testJaasConfigurationNotOverwritten() {
         assertNotEquals(overwrittenConfiguration, jaasFilter.getValue().configuration,
             "Overwritten JAAS configuration should not be used by basic auth REST extension");
     }
+
+    @Test
+    public void testBadJaasConfiguration() {
+        SecurityException jaasConfigurationException = new SecurityException(new IOException("Bad JAAS config is bad"));
+        Supplier<Configuration> configuration = BasicAuthSecurityRestExtension.initializeConfiguration(() -> {
+            throw jaasConfigurationException;
+        });
+
+        ConnectException thrownException = assertThrows(ConnectException.class, configuration::get);
+        assertEquals(jaasConfigurationException, thrownException.getCause());
+    }
+
+    @Test
+    public void testGoodJaasConfiguration() {
+        Configuration mockConfiguration = EasyMock.mock(Configuration.class);

Review comment:
       Another way is to use a mocked supplier and verify that the methods you expect to be called are indeed called (obviously only `get` here) and return or throw as you expect. This test does that, but with an additional level for indirection with this boolean, which basically implements what Easymock does already. Probably fine here since it results in more condensed code. But in the general case you'd pass a mock to verify that methods on that mock are called, which I also assume is referred to as evaluation here.




----------------------------------------------------------------
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.

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