gnodet-bot commented on code in PR #31263:
URL: https://github.com/apache/camel/pull/31263#discussion_r4773318761


##########
components/camel-azure/camel-azure-key-vault/src/test/java/org/apache/camel/component/azure/key/vault/AzureKeyVaultManagerDevConsoleTest.java:
##########
@@ -42,4 +43,42 @@ public void testAzureSecretsConsoleNoPropertiesFunction() {
         assertNotNull(out);
         assertTrue(out.isEmpty());
     }
+
+    @Test
+    void testLoginMethodClientIdClientSecret() {
+        AzureVaultConfiguration azure = 
context.getVaultConfiguration().azure();
+        azure.setClientId("my-client-id");
+        azure.setClientSecret("my-client-secret");
+        azure.setTenantId("my-tenant-id");
+        // azureIdentityEnabled defaults to false
+
+        AzureKeyVaultManagerDevConsole con = new 
AzureKeyVaultManagerDevConsole();
+        con.setCamelContext(context);
+
+        // No properties function active — login should not appear yet
+        // (propertiesFunction is null); verify the helper method directly
+        // by asserting the config flag is false
+        assertEquals(false, azure.isAzureIdentityEnabled());
+    }
+
+    @Test
+    void testLoginMethodAzureIdentityEnabled() {
+        AzureVaultConfiguration azure = 
context.getVaultConfiguration().azure();
+        azure.setAzureIdentityEnabled(true);
+
+        assertEquals(true, azure.isAzureIdentityEnabled());
+
+        // Verify the login string derivation logic (same as in the console)
+        String loginMethod = azure.isAzureIdentityEnabled() ? "Azure Identity" 
: "Client Id/Client Secret";
+        assertEquals("Azure Identity", loginMethod);
+    }
+
+    @Test
+    void testLoginMethodClientIdWhenAzureIdentityDisabled() {
+        AzureVaultConfiguration azure = 
context.getVaultConfiguration().azure();
+        azure.setAzureIdentityEnabled(false);
+
+        String loginMethod = azure.isAzureIdentityEnabled() ? "Azure Identity" 
: "Client Id/Client Secret";
+        assertEquals("Client Id/Client Secret", loginMethod);
+    }

Review Comment:
   **[medium]** These three tests don't exercise the fix. They set a flag on 
`AzureVaultConfiguration` and either assert the flag itself, or manually apply 
the same ternary expression that the console uses — both patterns are 
tautological. They pass with or without the fix because they never call 
`doCallText()` or `doCallJson()`.
   
   To actually validate the fix, the test must call the console method and 
assert its output:
   
   ```suggestion
       @Test
       void testLoginMethodClientIdClientSecret() {
           AzureVaultConfiguration azure = 
context.getVaultConfiguration().azure();
           azure.setClientId("my-client-id");
           azure.setClientSecret("my-client-secret");
           azure.setTenantId("my-tenant-id");
           azure.setVaultName("my-vault");
           // azureIdentityEnabled defaults to false
   
           DevConsole con = 
PluginHelper.getDevConsoleResolver(context).resolveDevConsole("azure-secrets");
           assertNotNull(con);
           JsonObject out = (JsonObject) con.call(DevConsole.MediaType.JSON);
           assertNotNull(out);
           assertEquals("Client Id/Client Secret", out.getString("login"));
       }
   
       @Test
       void testLoginMethodAzureIdentityEnabled() {
           AzureVaultConfiguration azure = 
context.getVaultConfiguration().azure();
           azure.setAzureIdentityEnabled(true);
           azure.setVaultName("my-vault");
   
           DevConsole con = 
PluginHelper.getDevConsoleResolver(context).resolveDevConsole("azure-secrets");
           assertNotNull(con);
           JsonObject out = (JsonObject) con.call(DevConsole.MediaType.JSON);
           assertNotNull(out);
           assertEquals("Azure Identity", out.getString("login"));
       }
   
       @Test
       void testLoginMethodClientIdWhenAzureIdentityDisabled() {
           AzureVaultConfiguration azure = 
context.getVaultConfiguration().azure();
           azure.setAzureIdentityEnabled(false);
           azure.setVaultName("my-vault");
   
           DevConsole con = 
PluginHelper.getDevConsoleResolver(context).resolveDevConsole("azure-secrets");
           assertNotNull(con);
           JsonObject out = (JsonObject) con.call(DevConsole.MediaType.JSON);
           assertNotNull(out);
           assertEquals("Client Id/Client Secret", out.getString("login"));
       }
   ```
   
   Note: `con.call(DevConsole.MediaType.JSON)` may return an empty map if no 
properties function is registered (see the existing 
`testAzureSecretsConsoleNoPropertiesFunction` test). You may need to register a 
`KeyVaultPropertiesFunction` to get the console to render. Check the console's 
`doCallJson()` guard for `propertiesFunction == null`.



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

Reply via email to