-
Notifications
You must be signed in to change notification settings - Fork 4
DATAGO-116001: event-management-agent: Configure JCSMP to use default JDK truststore for Event Portal connections #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
513803d
7db131c
5ce4699
0a337d0
4bd47ce
6bb8041
01b42a3
8559ebe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,9 +1,8 @@ | ||||||
| package com.solace.maas.ep.event.management.agent.webProxy; | ||||||
| package com.solace.maas.ep.event.management.agent.plugin.config; | ||||||
|
|
||||||
| import com.solace.maas.ep.event.management.agent.plugin.config.VMRProperties; | ||||||
| import com.solace.maas.ep.event.management.agent.plugin.config.eventPortal.EventPortalPluginProperties; | ||||||
| import com.solace.maas.ep.event.management.agent.plugin.config.eventPortal.GatewayProperties; | ||||||
| import com.solace.maas.ep.event.management.agent.plugin.config.eventPortal.GatewayMessagingProperties; | ||||||
| import com.solace.maas.ep.event.management.agent.plugin.config.eventPortal.GatewayProperties; | ||||||
| import com.solace.maas.ep.event.management.agent.plugin.messagingService.MessagingServiceConnectionProperties; | ||||||
| import com.solace.maas.ep.event.management.agent.plugin.messagingService.MessagingServiceUsersProperties; | ||||||
| import lombok.SneakyThrows; | ||||||
|
|
@@ -22,6 +21,11 @@ | |||||
|
|
||||||
| import static org.assertj.core.api.Assertions.assertThat; | ||||||
| import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||||||
| import static org.mockito.ArgumentMatchers.any; | ||||||
| import static org.mockito.Mockito.doNothing; | ||||||
| import static org.mockito.Mockito.never; | ||||||
| import static org.mockito.Mockito.spy; | ||||||
| import static org.mockito.Mockito.verify; | ||||||
| import static org.mockito.Mockito.when; | ||||||
|
|
||||||
| @ActiveProfiles("TEST") | ||||||
|
|
@@ -256,4 +260,38 @@ void testNoGatewayConnectionProperties() { | |||||
| .hasCauseExactlyInstanceOf(NoSuchElementException.class) | ||||||
| .hasRootCauseMessage("Event Portal gateway connection properties not found."); | ||||||
| } | ||||||
|
|
||||||
| @Test | ||||||
| @SneakyThrows | ||||||
| void testSetDefaultTrustStoreCalledWhenCustomCaCertsPresent() { | ||||||
| // Spy on vmrProperties to mock getCustomCaCertsPresentEnv and verify setDefaultTrustStore is called | ||||||
| VMRProperties spyVmrProperties = spy(vmrProperties); | ||||||
| when(spyVmrProperties.isCustomCACertConfigured()).thenReturn(true); | ||||||
| doNothing().when(spyVmrProperties).setDefaultTrustStore(any(Properties.class)); | ||||||
|
|
||||||
| MessagingServiceConnectionProperties connectionProps = createConnectionProperties(false, null, null, null, null, null); | ||||||
| when(gatewayMessagingProperties.getConnections()).thenReturn(Collections.singletonList(connectionProps)); | ||||||
|
|
||||||
| spyVmrProperties.getVmrProperties(); | ||||||
|
|
||||||
| // Verify setDefaultTrustStore was called | ||||||
| verify(spyVmrProperties).setDefaultTrustStore(any(Properties.class)); | ||||||
| } | ||||||
|
|
||||||
| @Test | ||||||
| @SneakyThrows | ||||||
| void testSetDefaultTrustStoreNotCalledWhenCustomCaCertsNotPresent() { | ||||||
| // Spy on vmrProperties to mock getCustomCaCertsPresentEnv and verify setDefaultTrustStore is NOT called | ||||||
|
||||||
| // Spy on vmrProperties to mock getCustomCaCertsPresentEnv and verify setDefaultTrustStore is NOT called | |
| // Spy on vmrProperties to mock isCustomCACertConfigured and verify setDefaultTrustStore is NOT called |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,8 +16,11 @@ | |||||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||||||
| import org.springframework.context.annotation.Configuration; | ||||||
|
|
||||||
| import java.io.File; | ||||||
| import java.net.InetAddress; | ||||||
| import java.net.UnknownHostException; | ||||||
| import java.nio.file.Path; | ||||||
| import java.nio.file.Paths; | ||||||
| import java.util.ArrayList; | ||||||
| import java.util.List; | ||||||
| import java.util.NoSuchElementException; | ||||||
|
|
@@ -122,9 +125,51 @@ public Properties getVmrProperties() { | |||||
| properties.setProperty(SolaceProperties.AuthenticationProperties.SCHEME_BASIC_PASSWORD, password); | ||||||
| properties.setProperty(SolaceProperties.ClientProperties.NAME, clientName); | ||||||
|
|
||||||
| //We will always use the default jks truststore for connecting to the EVMR | ||||||
|
||||||
| //We will always use the default jks truststore for connecting to the EVMR | |
| // Explicitly configure the default JKS truststore for connecting to the EVMR only when custom CA certificates are present |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this comment 👍
moodiRealist marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Package private to aid in testing
Outdated
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method name isCustomCACertConfigured is misleading - it checks whether custom CA certs are present, not whether they are configured. Consider renaming to hasCustomCACerts or isCustomCACertPresent to better reflect what it checks.
moodiRealist marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package private to help in testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment references a non-existent method
getCustomCaCertsPresentEnv. It should referenceisCustomCACertConfiguredinstead to match the actual method being mocked.