You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2018/10/09 09:12:57 UTC

[GitHub] zentol commented on a change in pull request #6796: [FLINK-10075] Redirect non-ssl requests to https url if ssl is enabled

zentol commented on a change in pull request #6796: [FLINK-10075] Redirect non-ssl requests to https url if ssl is enabled
URL: https://github.com/apache/flink/pull/6796#discussion_r223618264
 
 

 ##########
 File path: flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java
 ##########
 @@ -530,6 +530,20 @@ public void testDefaultVersionRouting() throws Exception {
 		}
 	}
 
+	@Test
+	public void testNonSslRedirectForEnabledSsl() throws Exception {
+		Assume.assumeTrue(config.getBoolean(SecurityOptions.SSL_REST_ENABLED));
+		OkHttpClient client = new OkHttpClient.Builder().followRedirects(false).build();
+		String httpsUrl = serverEndpoint.getRestBaseUrl() + "/path";
+		String httpUrl = httpsUrl.replace("https://", "http://");
+		Request request = new Request.Builder().url(httpUrl).build();
+		try (final Response response = client.newCall(request).execute()) {
+			assertEquals(HttpResponseStatus.MOVED_PERMANENTLY.code(), response.code());
+			assertTrue(response.headers().names().contains("Location"));
 
 Review comment:
   error message could be improved by using hamcrest `assertThat(response.headers().names(), contains("Location"))`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services