From 5dc9c4c527883355a267a8e94a4eb0b61f7e3467 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 27 Mar 2019 15:31:55 +0100 Subject: [PATCH] URL Cleanup - Fix broken tests See gh-22680 --- .../simp/SimpMessagingTemplateTests.java | 4 +-- .../oxm/AbstractMarshallerTests.java | 6 ++-- .../oxm/castor/CastorMarshallerTests.java | 8 ++--- .../oxm/jaxb/Jaxb2UnmarshallerTests.java | 6 ++-- .../htmlunit/HtmlUnitRequestBuilderTests.java | 4 +-- .../http/RequestEntityTests.java | 2 +- .../server/ServletServerHttpRequestTests.java | 8 +++-- .../reactive/ServerHttpRequestTests.java | 12 ++++---- .../web/client/RestTemplateTests.java | 2 +- .../web/cors/reactive/CorsUtilsTests.java | 4 +-- ...uestPartServletServerHttpRequestTests.java | 3 +- .../util/DefaultUriBuilderFactoryTests.java | 27 +++++++++-------- .../util/DefaultUriTemplateHandlerTests.java | 4 +-- .../web/util/UriComponentsBuilderTests.java | 22 +++++++------- .../web/util/UriUtilsTests.java | 4 +-- .../web/util/WebUtilsTests.java | 30 +++++++++---------- .../AppCacheManifestTransformerTests.java | 4 +-- .../web/reactive/resource/test/test.appcache | 2 +- .../MvcUriComponentsBuilderTests.java | 6 ++-- .../AppCacheManifestTransformerTests.java | 4 +-- .../web/servlet/resource/test/test.appcache | 2 +- 21 files changed, 84 insertions(+), 80 deletions(-) diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessagingTemplateTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessagingTemplateTests.java index adb21898877..990239464ad 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessagingTemplateTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessagingTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,7 +83,7 @@ public class SimpMessagingTemplateTests { MessageHeaderAccessor.getAccessor(messages.get(0), SimpMessageHeaderAccessor.class); assertNotNull(headerAccessor); - assertEquals("/user/http:%2F%2Fjoe.openid.example.org%2F/queue/foo", headerAccessor.getDestination()); + assertEquals("/user/https:%2F%2Fjoe.openid.example.org%2F/queue/foo", headerAccessor.getDestination()); } @Test diff --git a/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java index ce2c7df76c3..7ea9967b29c 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ public abstract class AbstractMarshallerTests { marshaller.marshal(flights, domResult); Document expected = builder.newDocument(); Element flightsElement = expected.createElementNS("http://samples.springframework.org/flight", "tns:flights"); - Attr namespace = expected.createAttributeNS("https://www.w3.org/2000/xmlns/", "xmlns:tns"); + Attr namespace = expected.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns"); namespace.setNodeValue("http://samples.springframework.org/flight"); flightsElement.setAttributeNode(namespace); expected.appendChild(flightsElement); @@ -98,7 +98,7 @@ public abstract class AbstractMarshallerTests { Document result = (Document) domResult.getNode(); Document expected = builder.newDocument(); Element flightsElement = expected.createElementNS("http://samples.springframework.org/flight", "tns:flights"); - Attr namespace = expected.createAttributeNS("https://www.w3.org/2000/xmlns/", "xmlns:tns"); + Attr namespace = expected.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns"); namespace.setNodeValue("http://samples.springframework.org/flight"); flightsElement.setAttributeNode(namespace); expected.appendChild(flightsElement); diff --git a/spring-oxm/src/test/java/org/springframework/oxm/castor/CastorMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/castor/CastorMarshallerTests.java index ede0f2b5a76..6fcc3bbe012 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/castor/CastorMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/castor/CastorMarshallerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,7 +76,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests" + "" + "test8"; @@ -91,7 +91,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests" + "" + "" + "test8"; @@ -101,7 +101,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests" + "" + "test8"; diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2UnmarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2UnmarshallerTests.java index 919d9b4504a..f40cec6c78a 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2UnmarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2UnmarshallerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,9 +91,9 @@ public class Jaxb2UnmarshallerTests extends AbstractUnmarshallerTests")).willReturn(dataHandler); given(mimeContainer.getAttachment("696cfb9a-4d2d-402f-bb5c-59fa69e7f0b3@spring-ws.png")).willReturn(dataHandler); String content = "" + "" + - "" + + "" + "" + "" + - "" + + "" + "" + "696cfb9a-4d2d-402f-bb5c-59fa69e7f0b3@spring-ws.png" + ""; diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java index 642888580ec..41e773fdc45 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java @@ -618,7 +618,7 @@ public class HtmlUnitRequestBuilderTests { @Test public void buildRequestRemotePort80WithDefault() throws Exception { - webRequest.setUrl(new URL("https://example.com/")); + webRequest.setUrl(new URL("http://example.com/")); MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); @@ -650,7 +650,7 @@ public class HtmlUnitRequestBuilderTests { @Test public void buildRequestUrl() { String uri = requestBuilder.buildRequest(servletContext).getRequestURL().toString(); - assertThat(uri, equalTo("https://example.com/test/this/here")); + assertThat(uri, equalTo("http://example.com/test/this/here")); } @Test diff --git a/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java b/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java index 1d28a27fe6c..3a2aa2b65c8 100644 --- a/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java +++ b/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java @@ -61,7 +61,7 @@ public class RequestEntityTests { URI uri = new UriTemplate("https://example.com/{foo}").expand("bar"); RequestEntity.get(uri).accept(MediaType.TEXT_PLAIN).build(); - String url = "http://www.{host}.com/{path}"; + String url = "https://www.{host}.com/{path}"; String host = "example"; String path = "foo/bar"; URI expected = new URI("https://www.example.com/foo/bar"); diff --git a/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java b/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java index 35e1897189c..2c1aa4151c7 100644 --- a/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,6 +60,7 @@ public class ServletServerHttpRequestTests { @Test public void getUriForSimplePath() throws URISyntaxException { URI uri = new URI("https://example.com/path"); + mockRequest.setScheme(uri.getScheme()); mockRequest.setServerName(uri.getHost()); mockRequest.setServerPort(uri.getPort()); mockRequest.setRequestURI(uri.getPath()); @@ -70,6 +71,7 @@ public class ServletServerHttpRequestTests { @Test public void getUriWithQueryString() throws URISyntaxException { URI uri = new URI("https://example.com/path?query"); + mockRequest.setScheme(uri.getScheme()); mockRequest.setServerName(uri.getHost()); mockRequest.setServerPort(uri.getPort()); mockRequest.setRequestURI(uri.getPath()); @@ -82,7 +84,7 @@ public class ServletServerHttpRequestTests { mockRequest.setServerName("example.com"); mockRequest.setRequestURI("/path"); mockRequest.setQueryString("query=foo"); - assertEquals(new URI("https://example.com/path?query=foo"), request.getURI()); + assertEquals(new URI("http://example.com/path?query=foo"), request.getURI()); } @Test // SPR-16414 @@ -90,7 +92,7 @@ public class ServletServerHttpRequestTests { mockRequest.setServerName("example.com"); mockRequest.setRequestURI("/path"); mockRequest.setQueryString("query=foo%%x"); - assertEquals(new URI("https://example.com/path"), request.getURI()); + assertEquals(new URI("http://example.com/path"), request.getURI()); } @Test // SPR-13876 diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java index e23a2b34aa6..611b8b8d414 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -96,16 +96,16 @@ public class ServerHttpRequestTests { request = createHttpRequest("/").mutate().method(HttpMethod.DELETE).build(); assertEquals(HttpMethod.DELETE, request.getMethod()); - String baseUri = "https://www.aaa.org/articles/"; + String baseUri = "http://www.aaa.org/articles/"; - request = createHttpRequest(baseUri).mutate().uri(URI.create("https://bbb.org:9090/b")).build(); - assertEquals("https://bbb.org:9090/b", request.getURI().toString()); + request = createHttpRequest(baseUri).mutate().uri(URI.create("http://bbb.org:9090/b")).build(); + assertEquals("http://bbb.org:9090/b", request.getURI().toString()); request = createHttpRequest(baseUri).mutate().path("/b/c/d").build(); - assertEquals("https://www.aaa.org/b/c/d", request.getURI().toString()); + assertEquals("http://www.aaa.org/b/c/d", request.getURI().toString()); request = createHttpRequest(baseUri).mutate().path("/app/b/c/d").contextPath("/app").build(); - assertEquals("https://www.aaa.org/app/b/c/d", request.getURI().toString()); + assertEquals("http://www.aaa.org/app/b/c/d", request.getURI().toString()); assertEquals("/app", request.getPath().contextPath().value()); } diff --git a/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java b/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java index 5b6e6c38e67..27134f9f3f3 100644 --- a/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java @@ -562,7 +562,7 @@ public class RestTemplateTests { public void ioExceptionWithEmptyQueryString() throws Exception { // https://example.com/resource? - URI uri = new URI("http", "example.com", "/resource", "", null); + URI uri = new URI("https", "example.com", "/resource", "", null); given(converter.canRead(String.class, null)).willReturn(true); given(converter.getSupportedMediaTypes()).willReturn(Collections.singletonList(parseMediaType("foo/bar"))); diff --git a/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsUtilsTests.java b/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsUtilsTests.java index 6f711fee2f4..b34ccd4d8d8 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,7 +95,7 @@ public class CorsUtilsTests { @Test // SPR-16362 public void isSameOriginWithDifferentSchemes() { MockServerHttpRequest request = MockServerHttpRequest - .get("https://mydomain1.com") + .get("http://mydomain1.com") .header(HttpHeaders.ORIGIN, "https://mydomain1.com") .build(); assertFalse(CorsUtils.isSameOrigin(request)); diff --git a/spring-web/src/test/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequestTests.java b/spring-web/src/test/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequestTests.java index 6759871191f..93ecae33c89 100644 --- a/spring-web/src/test/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequestTests.java +++ b/spring-web/src/test/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequestTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,6 +57,7 @@ public class RequestPartServletServerHttpRequestTests { ServerHttpRequest request = new RequestPartServletServerHttpRequest(this.mockRequest, "part"); URI uri = new URI("https://example.com/path?query"); + this.mockRequest.setScheme("https"); this.mockRequest.setServerName(uri.getHost()); this.mockRequest.setServerPort(uri.getPort()); this.mockRequest.setRequestURI(uri.getPath()); diff --git a/spring-web/src/test/java/org/springframework/web/util/DefaultUriBuilderFactoryTests.java b/spring-web/src/test/java/org/springframework/web/util/DefaultUriBuilderFactoryTests.java index 8f77188ee8e..4d6ed8e87b8 100644 --- a/spring-web/src/test/java/org/springframework/web/util/DefaultUriBuilderFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/DefaultUriBuilderFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.util; import java.net.URI; @@ -48,14 +49,14 @@ public class DefaultUriBuilderFactoryTests { @Test public void baseUri() { - DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://www.foo.com/v1?id=123"); + DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://example.com/v1?id=123"); URI uri = factory.uriString("/bar").port(8080).build(); - assertEquals("https://foo.com:8080/v1/bar?id=123", uri.toString()); + assertEquals("http://example.com:8080/v1/bar?id=123", uri.toString()); } @Test public void baseUriWithFullOverride() { - DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://www.foo.com/v1?id=123"); + DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://example.com/v1?id=123"); URI uri = factory.uriString("https://example.com/1/2").build(); assertEquals("Use of host should case baseUri to be completely ignored", "https://example.com/1/2", uri.toString()); @@ -63,17 +64,17 @@ public class DefaultUriBuilderFactoryTests { @Test public void baseUriWithPathOverride() { - DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://www.foo.com/v1"); + DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://example.com/v1"); URI uri = factory.builder().replacePath("/baz").build(); - assertEquals("http://www.foo.com/baz", uri.toString()); + assertEquals("http://example.com/baz", uri.toString()); } @Test public void defaultUriVars() { DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://{host}/v1"); - factory.setDefaultUriVariables(singletonMap("host", "foo.com")); + factory.setDefaultUriVariables(singletonMap("host", "example.com")); URI uri = factory.uriString("/{id}").build(singletonMap("id", "123")); - assertEquals("http://www.foo.com/v1/123", uri.toString()); + assertEquals("http://example.com/v1/123", uri.toString()); } @Test @@ -81,15 +82,15 @@ public class DefaultUriBuilderFactoryTests { DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://{host}/v1"); factory.setDefaultUriVariables(singletonMap("host", "spring.io")); URI uri = factory.uriString("/bar").build(singletonMap("host", "docs.spring.io")); - assertEquals("https://docs.spring.io/v1/bar", uri.toString()); + assertEquals("http://docs.spring.io/v1/bar", uri.toString()); } @Test public void defaultUriVarsWithEmptyVarArg() { DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://{host}/v1"); - factory.setDefaultUriVariables(singletonMap("host", "foo.com")); + factory.setDefaultUriVariables(singletonMap("host", "example.com")); URI uri = factory.uriString("/bar").build(); - assertEquals("Expected delegation to build(Map) method", "http://www.foo.com/v1/bar", uri.toString()); + assertEquals("Expected delegation to build(Map) method", "http://example.com/v1/bar", uri.toString()); } @Test @@ -137,10 +138,10 @@ public class DefaultUriBuilderFactoryTests { public void encodingValuesOnlySpr14147() { DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(); factory.setEncodingMode(EncodingMode.VALUES_ONLY); - factory.setDefaultUriVariables(singletonMap("host", "www.example.com")); + factory.setDefaultUriVariables(singletonMap("host", "example.com")); UriBuilder uriBuilder = factory.uriString("http://{host}/user/{userId}/dashboard"); - assertEquals("https://www.example.com/user/john%3Bdoe/dashboard", + assertEquals("http://example.com/user/john%3Bdoe/dashboard", uriBuilder.build(singletonMap("userId", "john;doe")).toString()); } diff --git a/spring-web/src/test/java/org/springframework/web/util/DefaultUriTemplateHandlerTests.java b/spring-web/src/test/java/org/springframework/web/util/DefaultUriTemplateHandlerTests.java index e38f3fe66d2..a3666d375cf 100644 --- a/spring-web/src/test/java/org/springframework/web/util/DefaultUriTemplateHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/DefaultUriTemplateHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -142,7 +142,7 @@ public class DefaultUriTemplateHandlerTests { Map vars = new HashMap<>(1); vars.put("userId", "john;doe"); - String template = "http://{host}/user/{userId}/dashboard"; + String template = "https://{host}/user/{userId}/dashboard"; URI actual = this.handler.expand(template, vars); assertEquals("https://www.example.com/user/john%3Bdoe/dashboard", actual.toString()); diff --git a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java index e61b42699b9..0decc4d160c 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java @@ -51,10 +51,10 @@ public class UriComponentsBuilderTests { @Test public void plain() throws URISyntaxException { UriComponentsBuilder builder = UriComponentsBuilder.newInstance(); - UriComponents result = builder.scheme("http").host("example.com") + UriComponents result = builder.scheme("https").host("example.com") .path("foo").queryParam("bar").fragment("baz") .build(); - assertEquals("http", result.getScheme()); + assertEquals("https", result.getScheme()); assertEquals("example.com", result.getHost()); assertEquals("foo", result.getPath()); assertEquals("bar", result.getQuery()); @@ -67,18 +67,18 @@ public class UriComponentsBuilderTests { @Test public void multipleFromSameBuilder() throws URISyntaxException { UriComponentsBuilder builder = UriComponentsBuilder.newInstance() - .scheme("http").host("example.com").pathSegment("foo"); + .scheme("https").host("example.com").pathSegment("foo"); UriComponents result1 = builder.build(); builder = builder.pathSegment("foo2").queryParam("bar").fragment("baz"); UriComponents result2 = builder.build(); - assertEquals("http", result1.getScheme()); + assertEquals("https", result1.getScheme()); assertEquals("example.com", result1.getHost()); assertEquals("/foo", result1.getPath()); URI expected = new URI("https://example.com/foo"); assertEquals("Invalid result URI", expected, result1.toUri()); - assertEquals("http", result2.getScheme()); + assertEquals("https", result2.getScheme()); assertEquals("example.com", result2.getHost()); assertEquals("/foo/foo2", result2.getPath()); assertEquals("bar", result2.getQuery()); @@ -110,7 +110,7 @@ public class UriComponentsBuilderTests { public void fromHierarchicalUri() throws URISyntaxException { URI uri = new URI("https://example.com/foo?bar#baz"); UriComponents result = UriComponentsBuilder.fromUri(uri).build(); - assertEquals("http", result.getScheme()); + assertEquals("https", result.getScheme()); assertEquals("example.com", result.getHost()); assertEquals("/foo", result.getPath()); assertEquals("bar", result.getQuery()); @@ -143,7 +143,7 @@ public class UriComponentsBuilderTests { @Test public void fromUriString() { UriComponents result = UriComponentsBuilder.fromUriString("https://www.ietf.org/rfc/rfc3986.txt").build(); - assertEquals("http", result.getScheme()); + assertEquals("https", result.getScheme()); assertNull(result.getUserInfo()); assertEquals("www.ietf.org", result.getHost()); assertEquals(-1, result.getPort()); @@ -155,7 +155,7 @@ public class UriComponentsBuilderTests { String url = "https://arjen:foobar@java.sun.com:80" + "/javase/6/docs/api/java/util/BitSet.html?foo=bar#and(java.util.BitSet)"; result = UriComponentsBuilder.fromUriString(url).build(); - assertEquals("http", result.getScheme()); + assertEquals("https", result.getScheme()); assertEquals("arjen:foobar", result.getUserInfo()); assertEquals("java.sun.com", result.getHost()); assertEquals(80, result.getPort()); @@ -278,7 +278,7 @@ public class UriComponentsBuilderTests { @Test // SPR-14761 public void fromHttpRequestWithForwardedIPv4Host() { MockHttpServletRequest request = new MockHttpServletRequest(); - request.setScheme("http"); + request.setScheme("https"); request.setServerName("localhost"); request.setServerPort(-1); request.setRequestURI("/mvc-showcase"); @@ -287,7 +287,7 @@ public class UriComponentsBuilderTests { HttpRequest httpRequest = new ServletServerHttpRequest(request); UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build(); - assertEquals("http://192.168.0.1/mvc-showcase", result.toString()); + assertEquals("https://192.168.0.1/mvc-showcase", result.toString()); } @Test // SPR-14761 @@ -491,7 +491,7 @@ public class UriComponentsBuilderTests { HttpRequest httpRequest = new ServletServerHttpRequest(request); UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build(); - assertEquals("https://a.example.org/mvc-showcase", result.toString()); + assertEquals("http://a.example.org/mvc-showcase", result.toString()); } @Test // SPR-12816 diff --git a/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java b/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java index 6d6803c0443..86a66bff8d2 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,7 +94,7 @@ public class UriUtilsTests { @Test public void encode() { assertEquals("Invalid encoded result", "foo", UriUtils.encode("foo", CHARSET)); - assertEquals("Invalid encoded result", "http%3A%2F%2Fexample.com%2Ffoo%20bar", + assertEquals("Invalid encoded result", "https%3A%2F%2Fexample.com%2Ffoo%20bar", UriUtils.encode("https://example.com/foo bar", CHARSET)); } diff --git a/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java b/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java index fd98c781038..121cd6c77a4 100644 --- a/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -92,24 +92,24 @@ public class WebUtilsTests { @Test public void isValidOrigin() { List allowed = Collections.emptyList(); - assertTrue(checkValidOrigin("mydomain1.com", -1, "https://mydomain1.com", allowed)); + assertTrue(checkValidOrigin("mydomain1.com", -1, "http://mydomain1.com", allowed)); assertFalse(checkValidOrigin("mydomain1.com", -1, "http://mydomain2.com", allowed)); allowed = Collections.singletonList("*"); assertTrue(checkValidOrigin("mydomain1.com", -1, "http://mydomain2.com", allowed)); - allowed = Collections.singletonList("https://mydomain1.com"); - assertTrue(checkValidOrigin("mydomain2.com", -1, "https://mydomain1.com", allowed)); + allowed = Collections.singletonList("http://mydomain1.com"); + assertTrue(checkValidOrigin("mydomain2.com", -1, "http://mydomain1.com", allowed)); assertFalse(checkValidOrigin("mydomain2.com", -1, "http://mydomain3.com", allowed)); } @Test public void isSameOrigin() { - assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "https://mydomain1.com")); - assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "https://www.mydomain1.com/")); + assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "http://mydomain1.com")); + assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "http://mydomain1.com:80")); assertTrue(checkSameOrigin("https", "mydomain1.com", 443, "https://mydomain1.com")); assertTrue(checkSameOrigin("https", "mydomain1.com", 443, "https://mydomain1.com:443")); - assertTrue(checkSameOrigin("http", "mydomain1.com", 123, "https://mydomain1.com:123")); + assertTrue(checkSameOrigin("http", "mydomain1.com", 123, "http://mydomain1.com:123")); assertTrue(checkSameOrigin("ws", "mydomain1.com", -1, "ws://mydomain1.com")); assertTrue(checkSameOrigin("wss", "mydomain1.com", 443, "wss://mydomain1.com")); @@ -119,14 +119,14 @@ public class WebUtilsTests { assertFalse(checkSameOrigin("https", "mydomain1.com", -1, "https://mydomain1.com")); // Handling of invalid origins as described in SPR-13478 - assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "https://mydomain1.com/")); - assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "https://www.mydomain1.com/")); - assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "https://mydomain1.com/path")); - assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "https://www.mydomain1.com/path")); - assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "https://mydomain1.com/")); - assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "https://www.mydomain1.com/")); - assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "https://mydomain1.com/path")); - assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "https://www.mydomain1.com/path")); + assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "http://mydomain1.com/")); + assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "http://mydomain1.com:80")); + assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "http://mydomain1.com/path")); + assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "http://mydomain1.com:80/path")); + assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "http://mydomain1.com/")); + assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "http://mydomain1.com:80/")); + assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "http://mydomain1.com/path")); + assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "http://mydomain1.com:80/path")); // Handling of IPv6 hosts as described in SPR-13525 assertTrue(checkSameOrigin("http", "[::1]", -1, "http://[::1]")); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java index 8425e2f724d..b0135d80eb0 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -109,7 +109,7 @@ public class AppCacheManifestTransformerTests { containsString("/static/js/bar-bd508c62235b832d960298ca6c0b7645.js")); assertThat("should not rewrite external resources", content, containsString("//example.org/style.css")); - assertThat("should not rewrite external resources", content, containsString("https://example.org/image.png")); + assertThat("should not rewrite external resources", content, containsString("http://example.org/image.png")); // Not the same hash as Spring MVC // Hash is computed from links, and not from the linked content diff --git a/spring-webflux/src/test/resources/org/springframework/web/reactive/resource/test/test.appcache b/spring-webflux/src/test/resources/org/springframework/web/reactive/resource/test/test.appcache index 986d1055a64..76e2f32a98d 100644 --- a/spring-webflux/src/test/resources/org/springframework/web/reactive/resource/test/test.appcache +++ b/spring-webflux/src/test/resources/org/springframework/web/reactive/resource/test/test.appcache @@ -11,7 +11,7 @@ NETWORK: CACHE: js/bar.js -https://example.org/image.png +http://example.org/image.png FALLBACK: /main /static.html \ No newline at end of file diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java index 2e896fe9c8d..7dd7c2cafda 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -424,7 +424,7 @@ public class MvcUriComponentsBuilderTests { this.request.setServerPort(9999); this.request.setContextPath("/base"); - assertEquals("https://example.org:9999/base/api/people/123/addresses", + assertEquals("http://example.org:9999/base/api/people/123/addresses", fromController(PersonsAddressesController.class).buildAndExpand("123").toString()); } @@ -437,7 +437,7 @@ public class MvcUriComponentsBuilderTests { this.request.setServerPort(9999); this.request.setContextPath("/base"); - assertEquals("https://example.org:9999/base/api/people/123/addresses/DE", + assertEquals("http://example.org:9999/base/api/people/123/addresses/DE", fromMethodCall(on(PersonsAddressesController.class).getAddressesForCountry("DE")) .buildAndExpand("123").toString()); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java index f8ef6606461..98462abc6b3 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -111,7 +111,7 @@ public class AppCacheManifestTransformerTests { containsString("/static/js/bar-bd508c62235b832d960298ca6c0b7645.js")); assertThat("should not rewrite external resources", content, containsString("//example.org/style.css")); - assertThat("should not rewrite external resources", content, containsString("https://example.org/image.png")); + assertThat("should not rewrite external resources", content, containsString("http://example.org/image.png")); assertThat("should generate fingerprint", content, containsString("# Hash: 4bf0338bcbeb0a5b3a4ec9ed8864107d")); diff --git a/spring-webmvc/src/test/resources/org/springframework/web/servlet/resource/test/test.appcache b/spring-webmvc/src/test/resources/org/springframework/web/servlet/resource/test/test.appcache index 986d1055a64..76e2f32a98d 100644 --- a/spring-webmvc/src/test/resources/org/springframework/web/servlet/resource/test/test.appcache +++ b/spring-webmvc/src/test/resources/org/springframework/web/servlet/resource/test/test.appcache @@ -11,7 +11,7 @@ NETWORK: CACHE: js/bar.js -https://example.org/image.png +http://example.org/image.png FALLBACK: /main /static.html \ No newline at end of file