URL Cleanup - Fix broken tests
See gh-22678
This commit is contained in:
@@ -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.
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -728,7 +728,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")));
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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<String, Object> 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());
|
||||
|
||||
@@ -49,10 +49,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());
|
||||
@@ -65,18 +65,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());
|
||||
@@ -108,7 +108,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());
|
||||
@@ -141,7 +141,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());
|
||||
@@ -153,7 +153,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());
|
||||
@@ -268,7 +268,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");
|
||||
@@ -277,7 +277,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
|
||||
@@ -466,7 +466,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
|
||||
|
||||
@@ -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.
|
||||
@@ -116,21 +116,21 @@ public class WebUtilsTests {
|
||||
@Test
|
||||
public void isValidOrigin() {
|
||||
List<String> 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("mydomain1.com", -1, "https://mydomain1.com"));
|
||||
assertTrue(checkSameOrigin("mydomain1.com", -1, "https://www.mydomain1.com/"));
|
||||
assertTrue(checkSameOrigin("mydomain1.com", -1, "http://mydomain1.com"));
|
||||
assertTrue(checkSameOrigin("mydomain1.com", -1, "http://mydomain1.com:80"));
|
||||
assertTrue(checkSameOrigin("mydomain1.com", 443, "https://mydomain1.com"));
|
||||
assertTrue(checkSameOrigin("mydomain1.com", 443, "https://mydomain1.com:443"));
|
||||
assertTrue(checkSameOrigin("mydomain1.com", 123, "https://mydomain1.com:123"));
|
||||
@@ -142,14 +142,14 @@ public class WebUtilsTests {
|
||||
assertFalse(checkSameOrigin("mydomain1.com", -1, "invalid-origin"));
|
||||
|
||||
// Handling of invalid origins as described in SPR-13478
|
||||
assertTrue(checkSameOrigin("mydomain1.com", -1, "https://mydomain1.com/"));
|
||||
assertTrue(checkSameOrigin("mydomain1.com", -1, "https://www.mydomain1.com/"));
|
||||
assertTrue(checkSameOrigin("mydomain1.com", -1, "https://mydomain1.com/path"));
|
||||
assertTrue(checkSameOrigin("mydomain1.com", -1, "https://www.mydomain1.com/path"));
|
||||
assertFalse(checkSameOrigin("mydomain2.com", -1, "https://mydomain1.com/"));
|
||||
assertFalse(checkSameOrigin("mydomain2.com", -1, "https://www.mydomain1.com/"));
|
||||
assertFalse(checkSameOrigin("mydomain2.com", -1, "https://mydomain1.com/path"));
|
||||
assertFalse(checkSameOrigin("mydomain2.com", -1, "https://www.mydomain1.com/path"));
|
||||
assertTrue(checkSameOrigin("mydomain1.com", -1, "http://mydomain1.com/"));
|
||||
assertTrue(checkSameOrigin("mydomain1.com", -1, "http://mydomain1.com:80"));
|
||||
assertTrue(checkSameOrigin("mydomain1.com", -1, "http://mydomain1.com/path"));
|
||||
assertTrue(checkSameOrigin("mydomain1.com", -1, "http://mydomain1.com:80/path"));
|
||||
assertFalse(checkSameOrigin("mydomain2.com", -1, "http://mydomain1.com/"));
|
||||
assertFalse(checkSameOrigin("mydomain2.com", -1, "http://mydomain1.com:80/"));
|
||||
assertFalse(checkSameOrigin("mydomain2.com", -1, "http://mydomain1.com/path"));
|
||||
assertFalse(checkSameOrigin("mydomain2.com", -1, "http://mydomain1.com:80/path"));
|
||||
|
||||
// Handling of IPv6 hosts as described in SPR-13525
|
||||
assertTrue(checkSameOrigin("[::1]", -1, "http://[::1]"));
|
||||
|
||||
Reference in New Issue
Block a user