Dhairya-007 opened a new pull request, #29674:
URL: https://github.com/apache/camel/pull/29674

   ## Problem
   
   `MiloServerComponent.createEndpointConfigs` builds the server's endpoint 
list with an `if`/`else if` chain whose **last two branches test the same 
condition**:
   
   ```java
   } else if (securityPolicies.contains(SecurityPolicy.Basic256Sha256)) {
       // TCP Basic256Sha256 / SignAndEncrypt
       endpointConfigs.add(buildTcpEndpoint(...));
   } else if (securityPolicies.contains(SecurityPolicy.Basic256Sha256)) {
       // HTTPS Basic256Sha256 / Sign (SignAndEncrypt not allowed for HTTPS)
       endpointConfigs.add(buildHttpsEndpoint(...));
   }
   ```
   
   The second branch is unreachable. A server configured with `Basic256Sha256` 
therefore gets only the TCP endpoint; the HTTPS endpoint the second branch is 
there to add is never created. The `None` branch directly above registers both 
transports, which is what makes the intent clear.
   
   A second consequence of the same chain: `securityPolicies` is a `Set`, but 
the branches are mutually exclusive, so configuring `None,Basic256Sha256` 
together yields only the unsecured endpoints.
   
   ## Fix
   
   - Merge the two duplicate branches into one that adds both the TCP and the 
HTTPS endpoint, with the security modes the comments already describe.
   - Make the `None` and `Basic256Sha256` blocks independent `if`s, so each 
policy in the set gets its endpoints. A configuration naming a single policy 
behaves exactly as before.
   
   ## Tests
   
   `ServerSetSecurityPoliciesTest` gains two cases that assert over the 
produced `EndpointConfig` set (`createEndpointConfigs` is now package-private 
so the test in the same package can call it, and the discovery endpoints — 
always unsecured — are filtered out):
   
   - `testBasic256Sha256HasBothATcpAndAnHttpsEndpoint` — TCP 
`Basic256Sha256`/`SignAndEncrypt` **and** HTTPS `Basic256Sha256`/`Sign`. Fails 
on `main` on the HTTPS assertion.
   - `testNoneAndBasic256Sha256HaveEndpointsForBothPolicies` — all four 
endpoints. Fails on `main` on both `Basic256Sha256` assertions.


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