Skip to content

Commit 977d738

Browse files
committed
Fix test after throw change
1 parent d480132 commit 977d738

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

core/http-auth-aws/src/test/java/software/amazon/awssdk/http/auth/aws/internal/signer/AwsChunkedV4PayloadSignerTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
1919
import static org.junit.jupiter.api.Assertions.assertEquals;
20+
import static org.junit.jupiter.api.Assumptions.assumeFalse;
2021
import static software.amazon.awssdk.checksums.DefaultChecksumAlgorithm.CRC32;
2122
import static software.amazon.awssdk.checksums.DefaultChecksumAlgorithm.SHA256;
2223

@@ -360,6 +361,8 @@ void sign_withPreExistingTrailersAndChecksumAndSignedPayload_shouldAwsChunkEncod
360361
@ParameterizedTest(name = "{0}")
361362
@MethodSource("signingImpls")
362363
void sign_withoutContentLength_calculatesContentLengthFromPayload(String name, SigningImplementation impl) {
364+
assumeFalse("ASYNC".equalsIgnoreCase(name), "The async path disallows unknown content length");
365+
363366
String expectedContent =
364367
"4\r\n{\"Ta\r\n" +
365368
"4\r\nbleN\r\n" +

core/http-auth-aws/src/test/java/software/amazon/awssdk/http/auth/aws/internal/signer/util/SignerUtilsTest.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package software.amazon.awssdk.http.auth.aws.internal.signer.util;
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
1920
import static software.amazon.awssdk.http.Header.CONTENT_LENGTH;
2021
import static software.amazon.awssdk.http.auth.aws.internal.signer.util.SignerConstant.X_AMZ_DECODED_CONTENT_LENGTH;
2122

@@ -109,23 +110,16 @@ void computeAndMoveContentLength_async_contentLengthPresent_shouldNotSubscribeTo
109110
assertThat(request.firstMatchingHeader(X_AMZ_DECODED_CONTENT_LENGTH)).contains("10");
110111
}
111112

112-
@ParameterizedTest
113-
@MethodSource("publishers")
114-
void computeAndMoveContentLength_contentLengthNotPresent_shouldInvokeSubscribe(Flowable<ByteBuffer> publisher, long expectedLength) {
113+
@Test
114+
void computeAndMoveContentLength_contentLengthNotPresent_throws() {
115115
SdkHttpRequest.Builder request = SdkHttpRequest.builder();
116116

117-
if (publisher != null) {
118-
publisher = Mockito.spy(publisher);
119-
}
120-
121-
SignerUtils.computeAndMoveContentLength(request, publisher).join();
117+
Publisher<ByteBuffer> contentPublisher = Flowable.just(ByteBuffer.wrap("content".getBytes(StandardCharsets.UTF_8)));
122118

123-
if (publisher != null) {
124-
Mockito.verify(publisher, Mockito.times(1)).subscribe(Mockito.any(Subscriber.class));
125-
}
119+
assertThatThrownBy(() -> SignerUtils.computeAndMoveContentLength(request, contentPublisher).join())
120+
.isInstanceOf(UnsupportedOperationException.class)
121+
.hasMessage("Content-Length header must be specified");
126122

127-
assertThat(request.firstMatchingHeader(CONTENT_LENGTH)).isEmpty();
128-
assertThat(request.firstMatchingHeader(X_AMZ_DECODED_CONTENT_LENGTH)).contains(String.valueOf(expectedLength));
129123
}
130124

131125
public static Stream<Arguments> streams() {

0 commit comments

Comments
 (0)