gnodet commented on code in PR #26214:
URL: https://github.com/apache/camel/pull/26214#discussion_r3960474478


##########
components/camel-salesforce/camel-salesforce-maven-plugin/src/test/java/org/apache/camel/maven/AbstractSalesforceMojoTest.java:
##########
@@ -147,4 +80,26 @@ static void setupJwt(final AbstractSalesforceMojo mojo) 
throws IOException {
             throw exception;
         }
     }
+
+    static void setupClientCredentials(final AbstractSalesforceMojo mojo) 
throws IOException {
+        // load test-salesforce-login properties
+        try (final InputStream stream = new 
FileInputStream(TEST_LOGIN_PROPERTIES)) {
+            final Properties properties = new Properties();
+            properties.load(stream);
+            mojo.clientId = properties.getProperty("salesforce.client.id");
+            mojo.clientSecret = 
properties.getProperty("salesforce.client.secret");
+            mojo.authenticationType = AuthenticationType.CLIENT_CREDENTIALS;
+            mojo.loginUrl = properties.getProperty("salesforce.login.url");
+            mojo.version = SalesforceEndpointConfig.DEFAULT_VERSION;
+        } catch (final FileNotFoundException e) {
+            final FileNotFoundException exception
+                    = new FileNotFoundException(
+                            "Create a properties file named " + 
TEST_LOGIN_PROPERTIES
+                                                + " with clientId, 
clientSecret"
+                                                + " for a Salesforce connected 
app configured for Client Credentials flow.");
+            exception.initCause(e);
+
+            throw exception;
+        }
+    }

Review Comment:
   **Low:** `setupClientCredentials` throws `FileNotFoundException` when the 
properties file is absent, while `setupUsernamePassword` skips gracefully via 
`assumeTrue` when `password` is missing. If the properties file isn't there, 
the manual IT fails hard instead of skipping. For parity:
   
   ```suggestion
       static void setupClientCredentials(final AbstractSalesforceMojo mojo) 
throws IOException {
           // load test-salesforce-login properties
           try (final InputStream stream = new 
FileInputStream(TEST_LOGIN_PROPERTIES)) {
               final Properties properties = new Properties();
               properties.load(stream);
               mojo.clientId = properties.getProperty("salesforce.client.id");
               mojo.clientSecret = 
properties.getProperty("salesforce.client.secret");
               assumeTrue(mojo.clientSecret != null && 
!mojo.clientSecret.isEmpty(),
                       "Property 'salesforce.client.secret' must be set in " + 
TEST_LOGIN_PROPERTIES
                               + " for CLIENT_CREDENTIALS authentication test");
               mojo.authenticationType = AuthenticationType.CLIENT_CREDENTIALS;
               mojo.loginUrl = properties.getProperty("salesforce.login.url");
               mojo.version = SalesforceEndpointConfig.DEFAULT_VERSION;
           } catch (final FileNotFoundException e) {
               assumeTrue(false, "Properties file " + TEST_LOGIN_PROPERTIES
                       + " not found — skipping CLIENT_CREDENTIALS test");
           }
       }
   ```



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