diff --git a/gradle.properties b/gradle.properties index 4083ddf7..fa246149 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ org.gradle.parallel=true javaFormatVersion=0.0.39 jmustacheVersion=1.15 -springFrameworkVersion=6.0.0 +springFrameworkVersion=6.0.14-SNAPSHOT diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CliOperationRequest.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CliOperationRequest.java index d3b2f9f2..a955fcaf 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CliOperationRequest.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/cli/CliOperationRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 the original author or authors. + * Copyright 2014-2023 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. @@ -18,6 +18,7 @@ package org.springframework.restdocs.cli; import java.net.URI; import java.util.Arrays; +import java.util.Base64; import java.util.Collection; import java.util.HashSet; import java.util.List; @@ -30,7 +31,6 @@ import org.springframework.http.HttpMethod; import org.springframework.restdocs.operation.OperationRequest; import org.springframework.restdocs.operation.OperationRequestPart; import org.springframework.restdocs.operation.RequestCookie; -import org.springframework.util.Base64Utils; /** * An {@link OperationRequest} wrapper with methods that are useful when producing a @@ -137,7 +137,7 @@ final class CliOperationRequest implements OperationRequest { } static String decodeBasicAuthHeader(List value) { - return new String(Base64Utils.decodeFromString(value.get(0).substring(6))); + return new String(Base64.getDecoder().decode(value.get(0).substring(6))); } } diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/HeadersModifyingOperationPreprocessor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/HeadersModifyingOperationPreprocessor.java index 72078847..9f0d4372 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/HeadersModifyingOperationPreprocessor.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/operation/preprocess/HeadersModifyingOperationPreprocessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 the original author or authors. + * Copyright 2014-2023 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,7 +57,7 @@ public class HeadersModifyingOperationPreprocessor implements OperationPreproces private HttpHeaders preprocess(HttpHeaders headers) { HttpHeaders modifiedHeaders = new HttpHeaders(); - modifiedHeaders.putAll(headers); + modifiedHeaders.addAll(headers); for (Modification modification : this.modifications) { modification.applyTo(modifiedHeaders); } diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/CurlRequestSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/CurlRequestSnippetTests.java index 8b32c3b0..2348adc4 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/CurlRequestSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/CurlRequestSnippetTests.java @@ -17,6 +17,7 @@ package org.springframework.restdocs.cli; import java.io.IOException; +import java.util.Base64; import org.junit.Test; import org.junit.runner.RunWith; @@ -26,7 +27,6 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.restdocs.AbstractSnippetTests; import org.springframework.restdocs.templates.TemplateFormat; -import org.springframework.util.Base64Utils; import static org.assertj.core.api.Assertions.assertThat; @@ -261,7 +261,7 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests { @Test public void basicAuthCredentialsAreSuppliedUsingUserOption() throws IOException { new CurlRequestSnippet(this.commandFormatter).document(this.operationBuilder.request("http://localhost/foo") - .header(HttpHeaders.AUTHORIZATION, "Basic " + Base64Utils.encodeToString("user:secret".getBytes())) + .header(HttpHeaders.AUTHORIZATION, "Basic " + Base64.getEncoder().encodeToString("user:secret".getBytes())) .build()); assertThat(this.generatedSnippets.curlRequest()) .is(codeBlock("bash").withContent("$ curl 'http://localhost/foo' -i -u 'user:secret' -X GET")); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/HttpieRequestSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/HttpieRequestSnippetTests.java index a387906d..3d4f9ff8 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/HttpieRequestSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/HttpieRequestSnippetTests.java @@ -17,6 +17,7 @@ package org.springframework.restdocs.cli; import java.io.IOException; +import java.util.Base64; import org.junit.Test; import org.junit.runner.RunWith; @@ -26,7 +27,6 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.restdocs.AbstractSnippetTests; import org.springframework.restdocs.templates.TemplateFormat; -import org.springframework.util.Base64Utils; import static org.assertj.core.api.Assertions.assertThat; @@ -260,7 +260,7 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests { @Test public void basicAuthCredentialsAreSuppliedUsingAuthOption() throws IOException { new HttpieRequestSnippet(this.commandFormatter).document(this.operationBuilder.request("http://localhost/foo") - .header(HttpHeaders.AUTHORIZATION, "Basic " + Base64Utils.encodeToString("user:secret".getBytes())) + .header(HttpHeaders.AUTHORIZATION, "Basic " + Base64.getEncoder().encodeToString("user:secret".getBytes())) .build()); assertThat(this.generatedSnippets.httpieRequest()) .is(codeBlock("bash").withContent("$ http --auth 'user:secret' GET 'http://localhost/foo'"));