Skip to content

Commit 2dda908

Browse files
committed
Polish "Use HTTPS for externals links where possible"
See gh-611
1 parent cb5d7c2 commit 2dda908

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private static final class XmlPrettyPrinter implements PrettyPrinter {
8282
public byte[] prettyPrint(byte[] original) throws Exception {
8383
Transformer transformer = TransformerFactory.newInstance().newTransformer();
8484
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
85-
transformer.setOutputProperty("{https://xml.apache.org/xslt}indent-amount",
85+
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
8686
"4");
8787
transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, "yes");
8888
ByteArrayOutputStream transformed = new ByteArrayOutputStream();

spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinkExtractorsPayloadTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public LinkExtractorsPayloadTests(LinkExtractor linkExtractor, String linkType)
6868
public void singleLink() throws IOException {
6969
Map<String, List<Link>> links = this.linkExtractor
7070
.extractLinks(createResponse("single-link"));
71-
assertLinks(Arrays.asList(new Link("alpha", "https://alpha.example.com", "Alpha")),
71+
assertLinks(
72+
Arrays.asList(new Link("alpha", "https://alpha.example.com", "Alpha")),
7273
links);
7374
}
7475

spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured/operation/preprocess/UriModifyingOperationPreprocessorTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,17 @@ public void requestUriPortCanBeRemoved() {
9494
@Test
9595
public void requestUriPathIsPreserved() {
9696
this.preprocessor.removePort();
97-
OperationRequest processed = this.preprocessor
98-
.preprocess(createRequestWithUri("https://api.example.com:12345/foo/bar"));
97+
OperationRequest processed = this.preprocessor.preprocess(
98+
createRequestWithUri("https://api.example.com:12345/foo/bar"));
9999
assertThat(processed.getUri())
100100
.isEqualTo(URI.create("https://api.example.com/foo/bar"));
101101
}
102102

103103
@Test
104104
public void requestUriQueryIsPreserved() {
105105
this.preprocessor.removePort();
106-
OperationRequest processed = this.preprocessor
107-
.preprocess(createRequestWithUri("https://api.example.com:12345?foo=bar"));
106+
OperationRequest processed = this.preprocessor.preprocess(
107+
createRequestWithUri("https://api.example.com:12345?foo=bar"));
108108
assertThat(processed.getUri())
109109
.isEqualTo(URI.create("https://api.example.com?foo=bar"));
110110
}

spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured3/operation/preprocess/UriModifyingOperationPreprocessorTests.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -93,17 +93,17 @@ public void requestUriPortCanBeRemoved() {
9393
@Test
9494
public void requestUriPathIsPreserved() {
9595
this.preprocessor.removePort();
96-
OperationRequest processed = this.preprocessor
97-
.preprocess(createRequestWithUri("https://api.example.com:12345/foo/bar"));
96+
OperationRequest processed = this.preprocessor.preprocess(
97+
createRequestWithUri("https://api.example.com:12345/foo/bar"));
9898
assertThat(processed.getUri())
9999
.isEqualTo(URI.create("https://api.example.com/foo/bar"));
100100
}
101101

102102
@Test
103103
public void requestUriQueryIsPreserved() {
104104
this.preprocessor.removePort();
105-
OperationRequest processed = this.preprocessor
106-
.preprocess(createRequestWithUri("https://api.example.com:12345?foo=bar"));
105+
OperationRequest processed = this.preprocessor.preprocess(
106+
createRequestWithUri("https://api.example.com:12345?foo=bar"));
107107
assertThat(processed.getUri())
108108
.isEqualTo(URI.create("https://api.example.com?foo=bar"));
109109
}
@@ -132,7 +132,7 @@ public void requestContentUriHostCanBeModified() {
132132
this.preprocessor.host("api.example.com");
133133
OperationRequest processed = this.preprocessor
134134
.preprocess(createRequestWithContent(
135-
"The uri 'http://localhost:12345' should be used"));
135+
"The uri 'https://localhost:12345' should be used"));
136136
assertThat(new String(processed.getContent()))
137137
.isEqualTo("The uri 'https://api.example.com:12345' should be used");
138138
}
@@ -212,7 +212,7 @@ public void responseContentUriHostCanBeModified() {
212212
this.preprocessor.host("api.example.com");
213213
OperationResponse processed = this.preprocessor
214214
.preprocess(createResponseWithContent(
215-
"The uri 'http://localhost:12345' should be used"));
215+
"The uri 'https://localhost:12345' should be used"));
216216
assertThat(new String(processed.getContent()))
217217
.isEqualTo("The uri 'https://api.example.com:12345' should be used");
218218
}
@@ -280,7 +280,7 @@ public void responseContentUriAnchorIsPreserved() {
280280
@Test
281281
public void urisInRequestHeadersCanBeModified() {
282282
OperationRequest processed = this.preprocessor.host("api.example.com")
283-
.preprocess(createRequestWithHeader("Foo", "http://locahost:12345"));
283+
.preprocess(createRequestWithHeader("Foo", "https://locahost:12345"));
284284
assertThat(processed.getHeaders().getFirst("Foo"))
285285
.isEqualTo("https://api.example.com:12345");
286286
assertThat(processed.getHeaders().getFirst("Host")).isEqualTo("api.example.com");
@@ -289,15 +289,15 @@ public void urisInRequestHeadersCanBeModified() {
289289
@Test
290290
public void urisInResponseHeadersCanBeModified() {
291291
OperationResponse processed = this.preprocessor.host("api.example.com")
292-
.preprocess(createResponseWithHeader("Foo", "http://locahost:12345"));
292+
.preprocess(createResponseWithHeader("Foo", "https://locahost:12345"));
293293
assertThat(processed.getHeaders().getFirst("Foo"))
294294
.isEqualTo("https://api.example.com:12345");
295295
}
296296

297297
@Test
298298
public void urisInRequestPartHeadersCanBeModified() {
299299
OperationRequest processed = this.preprocessor.host("api.example.com").preprocess(
300-
createRequestWithPartWithHeader("Foo", "http://locahost:12345"));
300+
createRequestWithPartWithHeader("Foo", "https://locahost:12345"));
301301
assertThat(processed.getParts().iterator().next().getHeaders().getFirst("Foo"))
302302
.isEqualTo("https://api.example.com:12345");
303303
}
@@ -306,7 +306,7 @@ public void urisInRequestPartHeadersCanBeModified() {
306306
public void urisInRequestPartContentCanBeModified() {
307307
OperationRequest processed = this.preprocessor.host("api.example.com")
308308
.preprocess(createRequestWithPartWithContent(
309-
"The uri 'http://localhost:12345' should be used"));
309+
"The uri 'https://localhost:12345' should be used"));
310310
assertThat(new String(processed.getParts().iterator().next().getContent()))
311311
.isEqualTo("The uri 'https://api.example.com:12345' should be used");
312312
}

0 commit comments

Comments
 (0)