File tree Expand file tree Collapse file tree
src/test/java/io/github/easy4j/hermes Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -131,4 +131,31 @@ void sessionDisconnectDoesNotReplayOriginalPost() throws Exception {
131131 }
132132 }
133133 }
134+
135+ @ Test
136+ void runIdentifierIsEncodedAsOneSsePathSegment () throws Exception {
137+ try (MockWebServer server = new MockWebServer ()) {
138+ server .enqueue (new MockResponse ()
139+ .setResponseCode (200 )
140+ .setHeader ("Content-Type" , "text/event-stream" )
141+ .setBody ("data: [DONE]\\ n\\ n" ));
142+ server .start ();
143+
144+ HermesHttpClientConfig config = new HermesHttpClientConfig ()
145+ .setEndpointPolicy (io .github .easy4j .hermes .security .EndpointPolicy
146+ .trustedLocal ("127.0.0.1" , server .getPort ()))
147+ .setBaseUrl ("http://127.0.0.1:" + server .getPort ());
148+
149+ try (HermesSseClient sse = new HermesSseClient (config , null , null )) {
150+ SseSubscription subscription =
151+ sse .subscribeRunEvents ("run/alpha?x=1" , ignored -> { });
152+ okhttp3 .mockwebserver .RecordedRequest request =
153+ server .takeRequest (3 , TimeUnit .SECONDS );
154+ assertNotNull (request );
155+ assertEquals ("/v1/runs/run%2Falpha%3Fx%3D1/events" , request .getPath ());
156+ subscription .cancel ();
157+ }
158+ }
159+ }
160+
134161}
Original file line number Diff line number Diff line change 11package io .github .easy4j .hermes .security ;
22
3+ import io .github .easy4j .hermes .HermesClient ;
4+ import io .github .easy4j .hermes .HermesCliConfig ;
35import io .github .easy4j .hermes .HermesHttpClientConfig ;
46import io .github .easy4j .hermes .api .HermesHttpClient ;
57import io .github .easy4j .hermes .exception .HermesHttpException ;
@@ -143,4 +145,23 @@ void testEp003S2EncodesReservedRunIdentifierAsOnePathSegment() throws Exception
143145 }
144146 }
145147
148+
149+ @ Test
150+ void trustedLocalPolicySurvivesHermesClientConfigSnapshot () throws Exception {
151+ try (MockWebServer server = new MockWebServer ()) {
152+ server .start ();
153+ HermesHttpClientConfig config = new HermesHttpClientConfig ()
154+ .setEndpointPolicy (EndpointPolicy .trustedLocal ("127.0.0.1" , server .getPort ()))
155+ .setBaseUrl ("http://127.0.0.1:" + server .getPort ());
156+ HermesCliConfig cliConfig = new HermesCliConfig ();
157+ cliConfig .setEnabled (false );
158+
159+ assertDoesNotThrow (() -> {
160+ try (HermesClient ignored = new HermesClient (config , cliConfig )) {
161+ // Construction is the contract: the copied config must retain the policy.
162+ }
163+ });
164+ }
165+ }
166+
146167}
You can’t perform that action at this time.
0 commit comments