File tree Expand file tree Collapse file tree
core/http/client/src/test/java/org/eclipse/rdf4j/http/client Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,6 +77,57 @@ public void testCreateRepositoryExecutesPut(MockServerClient client) throws Exce
7777 );
7878 }
7979
80+ @ Test
81+ public void testCreateRepositoryFollowsRedirectOnPut (MockServerClient client ) throws Exception {
82+ // Simulate reverse-proxy forcing redirect on state-changing PUT
83+ String originalPath = "/rdf4j-server/repositories/test" ;
84+ String redirectedPath = "/https/rdf4j-server/repositories/test" ;
85+ String redirectLocation = "http://localhost:" + client .getPort () + redirectedPath ;
86+
87+ // First request responds with 301 and Location header
88+ client .when (
89+ request ()
90+ .withMethod ("PUT" )
91+ .withPath (originalPath ),
92+ Times .once ()
93+ )
94+ .respond (
95+ response ()
96+ .withStatusCode (301 )
97+ .withHeader ("Location" , redirectLocation )
98+ );
99+
100+ // Redirect target responds successfully
101+ client .when (
102+ request ()
103+ .withMethod ("PUT" )
104+ .withPath (redirectedPath ),
105+ Times .once ()
106+ )
107+ .respond (
108+ response ()
109+ );
110+
111+ RepositoryConfig config = new RepositoryConfig ("test" );
112+
113+ // Expected: client should follow the 301 redirect and succeed without throwing
114+ getRDF4JSession ().createRepository (config );
115+
116+ // Verify both the original and redirected requests were made with additional headers preserved
117+ client .verify (
118+ request ()
119+ .withMethod ("PUT" )
120+ .withPath (originalPath )
121+ .withHeader (testHeader , testValue )
122+ );
123+ client .verify (
124+ request ()
125+ .withMethod ("PUT" )
126+ .withPath (redirectedPath )
127+ .withHeader (testHeader , testValue )
128+ );
129+ }
130+
80131 @ Test
81132 public void testUpdateRepositoryExecutesPost (MockServerClient client ) throws Exception {
82133 RepositoryConfig config = new RepositoryConfig ("test" );
You can’t perform that action at this time.
0 commit comments