Skip to content

Commit

Permalink
chore: remove use of Truth assertions (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsirac authored Oct 16, 2020
1 parent dc16550 commit 6d04b05
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 210 deletions.
206 changes: 103 additions & 103 deletions oauth2_http/javatests/com/google/auth/oauth2/AwsRequestSignerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

package com.google.auth.oauth2;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;

import com.google.api.client.json.GenericJson;
import com.google.api.client.json.JsonFactory;
Expand Down Expand Up @@ -88,13 +88,13 @@ public void sign_getHost() {
+ "aws4_request, SignedHeaders=date;host, Signature="
+ expectedSignature;

assertThat(signature.getSignature()).isEqualTo(expectedSignature);
assertThat(signature.getAuthorizationHeader()).isEqualTo(expectedAuthHeader);
assertThat(signature.getSecurityCredentials()).isEqualTo(BOTOCORE_CREDENTIALS);
assertThat(signature.getDate()).isEqualTo(DATE);
assertThat(signature.getHttpMethod()).isEqualTo("GET");
assertThat(signature.getRegion()).isEqualTo("us-east-1");
assertThat(signature.getUrl()).isEqualTo(URI.create(url).normalize().toString());
assertEquals(expectedSignature, signature.getSignature());
assertEquals(expectedAuthHeader, signature.getAuthorizationHeader());
assertEquals(BOTOCORE_CREDENTIALS, signature.getSecurityCredentials());
assertEquals(DATE, signature.getDate());
assertEquals("GET", signature.getHttpMethod());
assertEquals("us-east-1", signature.getRegion());
assertEquals(URI.create(url).normalize().toString(), signature.getUrl());
}

// https://github.com/boto/botocore/blob/879f8440a4e9ace5d3cf145ce8b3d5e5ffb892ef/tests/unit/auth/aws4_testsuite/get-relative-relative.req
Expand All @@ -119,13 +119,13 @@ public void sign_getHostRelativePath() {
+ "aws4_request, SignedHeaders=date;host, Signature="
+ expectedSignature;

assertThat(signature.getSignature()).isEqualTo(expectedSignature);
assertThat(signature.getAuthorizationHeader()).isEqualTo(expectedAuthHeader);
assertThat(signature.getSecurityCredentials()).isEqualTo(BOTOCORE_CREDENTIALS);
assertThat(signature.getDate()).isEqualTo(DATE);
assertThat(signature.getHttpMethod()).isEqualTo("GET");
assertThat(signature.getRegion()).isEqualTo("us-east-1");
assertThat(signature.getUrl()).isEqualTo(URI.create(url).normalize().toString());
assertEquals(expectedSignature, signature.getSignature());
assertEquals(expectedAuthHeader, signature.getAuthorizationHeader());
assertEquals(BOTOCORE_CREDENTIALS, signature.getSecurityCredentials());
assertEquals(DATE, signature.getDate());
assertEquals("GET", signature.getHttpMethod());
assertEquals("us-east-1", signature.getRegion());
assertEquals(URI.create(url).normalize().toString(), signature.getUrl());
}

// https://github.com/boto/botocore/blob/879f8440a4e9ace5d3cf145ce8b3d5e5ffb892ef/tests/unit/auth/aws4_testsuite/get-slash-dot-slash.req
Expand All @@ -150,13 +150,13 @@ public void sign_getHostInvalidPath() {
+ "aws4_request, SignedHeaders=date;host, Signature="
+ expectedSignature;

assertThat(signature.getSignature()).isEqualTo(expectedSignature);
assertThat(signature.getAuthorizationHeader()).isEqualTo(expectedAuthHeader);
assertThat(signature.getSecurityCredentials()).isEqualTo(BOTOCORE_CREDENTIALS);
assertThat(signature.getDate()).isEqualTo(DATE);
assertThat(signature.getHttpMethod()).isEqualTo("GET");
assertThat(signature.getRegion()).isEqualTo("us-east-1");
assertThat(signature.getUrl()).isEqualTo(URI.create(url).normalize().toString());
assertEquals(expectedSignature, signature.getSignature());
assertEquals(expectedAuthHeader, signature.getAuthorizationHeader());
assertEquals(BOTOCORE_CREDENTIALS, signature.getSecurityCredentials());
assertEquals(DATE, signature.getDate());
assertEquals("GET", signature.getHttpMethod());
assertEquals("us-east-1", signature.getRegion());
assertEquals(URI.create(url).normalize().toString(), signature.getUrl());
}

// https://github.com/boto/botocore/blob/879f8440a4e9ace5d3cf145ce8b3d5e5ffb892ef/tests/unit/auth/aws4_testsuite/get-slash-pointless-dot.req
Expand All @@ -181,13 +181,13 @@ public void sign_getHostDotPath() {
+ "aws4_request, SignedHeaders=date;host, Signature="
+ expectedSignature;

assertThat(signature.getSignature()).isEqualTo(expectedSignature);
assertThat(signature.getAuthorizationHeader()).isEqualTo(expectedAuthHeader);
assertThat(signature.getSecurityCredentials()).isEqualTo(BOTOCORE_CREDENTIALS);
assertThat(signature.getDate()).isEqualTo(DATE);
assertThat(signature.getHttpMethod()).isEqualTo("GET");
assertThat(signature.getRegion()).isEqualTo("us-east-1");
assertThat(signature.getUrl()).isEqualTo(URI.create(url).normalize().toString());
assertEquals(expectedSignature, signature.getSignature());
assertEquals(expectedAuthHeader, signature.getAuthorizationHeader());
assertEquals(BOTOCORE_CREDENTIALS, signature.getSecurityCredentials());
assertEquals(DATE, signature.getDate());
assertEquals("GET", signature.getHttpMethod());
assertEquals("us-east-1", signature.getRegion());
assertEquals(URI.create(url).normalize().toString(), signature.getUrl());
}

// https://github.com/boto/botocore/blob/879f8440a4e9ace5d3cf145ce8b3d5e5ffb892ef/tests/unit/auth/aws4_testsuite/get-utf8.req
Expand All @@ -212,13 +212,13 @@ public void sign_getHostUtf8Path() {
+ "aws4_request, SignedHeaders=date;host, Signature="
+ expectedSignature;

assertThat(signature.getSignature()).isEqualTo(expectedSignature);
assertThat(signature.getAuthorizationHeader()).isEqualTo(expectedAuthHeader);
assertThat(signature.getSecurityCredentials()).isEqualTo(BOTOCORE_CREDENTIALS);
assertThat(signature.getDate()).isEqualTo(DATE);
assertThat(signature.getHttpMethod()).isEqualTo("GET");
assertThat(signature.getRegion()).isEqualTo("us-east-1");
assertThat(signature.getUrl()).isEqualTo(URI.create(url).normalize().toString());
assertEquals(expectedSignature, signature.getSignature());
assertEquals(expectedAuthHeader, signature.getAuthorizationHeader());
assertEquals(BOTOCORE_CREDENTIALS, signature.getSecurityCredentials());
assertEquals(DATE, signature.getDate());
assertEquals("GET", signature.getHttpMethod());
assertEquals("us-east-1", signature.getRegion());
assertEquals(URI.create(url).normalize().toString(), signature.getUrl());
}

// https://github.com/boto/botocore/blob/879f8440a4e9ace5d3cf145ce8b3d5e5ffb892ef/tests/unit/auth/aws4_testsuite/get-vanilla-query-order-key-case.req
Expand All @@ -243,13 +243,13 @@ public void sign_getHostDuplicateQueryParam() {
+ "aws4_request, SignedHeaders=date;host, Signature="
+ expectedSignature;

assertThat(signature.getSignature()).isEqualTo(expectedSignature);
assertThat(signature.getAuthorizationHeader()).isEqualTo(expectedAuthHeader);
assertThat(signature.getSecurityCredentials()).isEqualTo(BOTOCORE_CREDENTIALS);
assertThat(signature.getDate()).isEqualTo(DATE);
assertThat(signature.getHttpMethod()).isEqualTo("GET");
assertThat(signature.getRegion()).isEqualTo("us-east-1");
assertThat(signature.getUrl()).isEqualTo(URI.create(url).normalize().toString());
assertEquals(expectedSignature, signature.getSignature());
assertEquals(expectedAuthHeader, signature.getAuthorizationHeader());
assertEquals(BOTOCORE_CREDENTIALS, signature.getSecurityCredentials());
assertEquals(DATE, signature.getDate());
assertEquals("GET", signature.getHttpMethod());
assertEquals("us-east-1", signature.getRegion());
assertEquals(URI.create(url).normalize().toString(), signature.getUrl());
}

// https://github.com/boto/botocore/blob/879f8440a4e9ace5d3cf145ce8b3d5e5ffb892ef/tests/unit/auth/aws4_testsuite/post-header-key-sort.req
Expand Down Expand Up @@ -277,14 +277,14 @@ public void sign_postWithUpperCaseHeaderKey() {
+ "aws4_request, SignedHeaders=date;host;zoo, Signature="
+ expectedSignature;

assertThat(signature.getSignature()).isEqualTo(expectedSignature);
assertThat(signature.getAuthorizationHeader()).isEqualTo(expectedAuthHeader);
assertThat(signature.getSecurityCredentials()).isEqualTo(BOTOCORE_CREDENTIALS);
assertThat(signature.getDate()).isEqualTo(DATE);
assertThat(signature.getHttpMethod()).isEqualTo("POST");
assertThat(signature.getRegion()).isEqualTo("us-east-1");
assertThat(signature.getUrl()).isEqualTo(URI.create(url).normalize().toString());
assertThat(signature.getCanonicalHeaders().get(headerKey.toLowerCase())).isEqualTo(headerValue);
assertEquals(expectedSignature, signature.getSignature());
assertEquals(expectedAuthHeader, signature.getAuthorizationHeader());
assertEquals(BOTOCORE_CREDENTIALS, signature.getSecurityCredentials());
assertEquals(DATE, signature.getDate());
assertEquals("POST", signature.getHttpMethod());
assertEquals("us-east-1", signature.getRegion());
assertEquals(URI.create(url).normalize().toString(), signature.getUrl());
assertEquals(headerValue, signature.getCanonicalHeaders().get(headerKey.toLowerCase()));
}

// https://github.com/boto/botocore/blob/879f8440a4e9ace5d3cf145ce8b3d5e5ffb892ef/tests/unit/auth/aws4_testsuite/post-header-value-case.req
Expand Down Expand Up @@ -312,14 +312,14 @@ public void sign_postWithUpperCaseHeaderValue() {
+ "aws4_request, SignedHeaders=date;host;zoo, Signature="
+ expectedSignature;

assertThat(signature.getSignature()).isEqualTo(expectedSignature);
assertThat(signature.getAuthorizationHeader()).isEqualTo(expectedAuthHeader);
assertThat(signature.getSecurityCredentials()).isEqualTo(BOTOCORE_CREDENTIALS);
assertThat(signature.getDate()).isEqualTo(DATE);
assertThat(signature.getHttpMethod()).isEqualTo("POST");
assertThat(signature.getRegion()).isEqualTo("us-east-1");
assertThat(signature.getUrl()).isEqualTo(URI.create(url).normalize().toString());
assertThat(signature.getCanonicalHeaders().get(headerKey)).isEqualTo(headerValue);
assertEquals(expectedSignature, signature.getSignature());
assertEquals(expectedAuthHeader, signature.getAuthorizationHeader());
assertEquals(BOTOCORE_CREDENTIALS, signature.getSecurityCredentials());
assertEquals(DATE, signature.getDate());
assertEquals("POST", signature.getHttpMethod());
assertEquals("us-east-1", signature.getRegion());
assertEquals(URI.create(url).normalize().toString(), signature.getUrl());
assertEquals(headerValue, signature.getCanonicalHeaders().get(headerKey.toLowerCase()));
}

// https://github.com/boto/botocore/blob/879f8440a4e9ace5d3cf145ce8b3d5e5ffb892ef/tests/unit/auth/aws4_testsuite/get-header-value-trim.req
Expand Down Expand Up @@ -347,14 +347,14 @@ public void sign_postWithHeader() {
+ "aws4_request, SignedHeaders=date;host;p, Signature="
+ expectedSignature;

assertThat(signature.getSignature()).isEqualTo(expectedSignature);
assertThat(signature.getAuthorizationHeader()).isEqualTo(expectedAuthHeader);
assertThat(signature.getSecurityCredentials()).isEqualTo(BOTOCORE_CREDENTIALS);
assertThat(signature.getDate()).isEqualTo(DATE);
assertThat(signature.getHttpMethod()).isEqualTo("POST");
assertThat(signature.getRegion()).isEqualTo("us-east-1");
assertThat(signature.getUrl()).isEqualTo(URI.create(url).normalize().toString());
assertThat(signature.getCanonicalHeaders().get(headerKey)).isEqualTo(headerValue);
assertEquals(expectedSignature, signature.getSignature());
assertEquals(expectedAuthHeader, signature.getAuthorizationHeader());
assertEquals(BOTOCORE_CREDENTIALS, signature.getSecurityCredentials());
assertEquals(DATE, signature.getDate());
assertEquals("POST", signature.getHttpMethod());
assertEquals("us-east-1", signature.getRegion());
assertEquals(URI.create(url).normalize().toString(), signature.getUrl());
assertEquals(headerValue, signature.getCanonicalHeaders().get(headerKey.toLowerCase()));
}

// https://github.com/boto/botocore/blob/879f8440a4e9ace5d3cf145ce8b3d5e5ffb892ef/tests/unit/auth/aws4_testsuite/post-x-www-form-urlencoded.req
Expand Down Expand Up @@ -383,14 +383,14 @@ public void sign_postWithBodyNoCustomHeaders() {
+ "aws4_request, SignedHeaders=content-type;date;host, Signature="
+ expectedSignature;

assertThat(signature.getSignature()).isEqualTo(expectedSignature);
assertThat(signature.getAuthorizationHeader()).isEqualTo(expectedAuthHeader);
assertThat(signature.getSecurityCredentials()).isEqualTo(BOTOCORE_CREDENTIALS);
assertThat(signature.getDate()).isEqualTo(DATE);
assertThat(signature.getHttpMethod()).isEqualTo("POST");
assertThat(signature.getRegion()).isEqualTo("us-east-1");
assertThat(signature.getUrl()).isEqualTo(URI.create(url).normalize().toString());
assertThat(signature.getCanonicalHeaders().get(headerKey.toLowerCase())).isEqualTo(headerValue);
assertEquals(expectedSignature, signature.getSignature());
assertEquals(expectedAuthHeader, signature.getAuthorizationHeader());
assertEquals(BOTOCORE_CREDENTIALS, signature.getSecurityCredentials());
assertEquals(DATE, signature.getDate());
assertEquals("POST", signature.getHttpMethod());
assertEquals("us-east-1", signature.getRegion());
assertEquals(URI.create(url).normalize().toString(), signature.getUrl());
assertEquals(headerValue, signature.getCanonicalHeaders().get(headerKey.toLowerCase()));
}

// https://github.com/boto/botocore/blob/879f8440a4e9ace5d3cf145ce8b3d5e5ffb892ef/tests/unit/auth/aws4_testsuite/post-vanilla-query.req
Expand All @@ -415,13 +415,13 @@ public void sign_postWithQueryString() {
+ "aws4_request, SignedHeaders=date;host, Signature="
+ expectedSignature;

assertThat(signature.getSignature()).isEqualTo(expectedSignature);
assertThat(signature.getAuthorizationHeader()).isEqualTo(expectedAuthHeader);
assertThat(signature.getSecurityCredentials()).isEqualTo(BOTOCORE_CREDENTIALS);
assertThat(signature.getDate()).isEqualTo(DATE);
assertThat(signature.getHttpMethod()).isEqualTo("POST");
assertThat(signature.getRegion()).isEqualTo("us-east-1");
assertThat(signature.getUrl()).isEqualTo(URI.create(url).normalize().toString());
assertEquals(expectedSignature, signature.getSignature());
assertEquals(expectedAuthHeader, signature.getAuthorizationHeader());
assertEquals(BOTOCORE_CREDENTIALS, signature.getSecurityCredentials());
assertEquals(DATE, signature.getDate());
assertEquals("POST", signature.getHttpMethod());
assertEquals("us-east-1", signature.getRegion());
assertEquals(URI.create(url).normalize().toString(), signature.getUrl());
}

@Test
Expand All @@ -446,13 +446,13 @@ public void sign_getDescribeRegions() {
+ "aws4_request, SignedHeaders=host;x-amz-date;x-amz-security-token, Signature="
+ expectedSignature;

assertThat(signature.getSignature()).isEqualTo(expectedSignature);
assertThat(signature.getAuthorizationHeader()).isEqualTo(expectedAuthHeader);
assertThat(signature.getSecurityCredentials()).isEqualTo(awsSecurityCredentials);
assertThat(signature.getDate()).isEqualTo(X_AMZ_DATE);
assertThat(signature.getHttpMethod()).isEqualTo("GET");
assertThat(signature.getRegion()).isEqualTo("us-east-2");
assertThat(signature.getUrl()).isEqualTo(URI.create(url).normalize().toString());
assertEquals(expectedSignature, signature.getSignature());
assertEquals(expectedAuthHeader, signature.getAuthorizationHeader());
assertEquals(awsSecurityCredentials, signature.getSecurityCredentials());
assertEquals(X_AMZ_DATE, signature.getDate());
assertEquals("GET", signature.getHttpMethod());
assertEquals("us-east-2", signature.getRegion());
assertEquals(URI.create(url).normalize().toString(), signature.getUrl());
}

@Test
Expand All @@ -477,13 +477,13 @@ public void sign_postGetCallerIdentity() {
+ "aws4_request, SignedHeaders=host;x-amz-date;x-amz-security-token, Signature="
+ expectedSignature;

assertThat(signature.getSignature()).isEqualTo(expectedSignature);
assertThat(signature.getAuthorizationHeader()).isEqualTo(expectedAuthHeader);
assertThat(signature.getSecurityCredentials()).isEqualTo(awsSecurityCredentials);
assertThat(signature.getDate()).isEqualTo(X_AMZ_DATE);
assertThat(signature.getHttpMethod()).isEqualTo("POST");
assertThat(signature.getRegion()).isEqualTo("us-east-2");
assertThat(signature.getUrl()).isEqualTo(URI.create(url).normalize().toString());
assertEquals(expectedSignature, signature.getSignature());
assertEquals(expectedAuthHeader, signature.getAuthorizationHeader());
assertEquals(awsSecurityCredentials, signature.getSecurityCredentials());
assertEquals(X_AMZ_DATE, signature.getDate());
assertEquals("POST", signature.getHttpMethod());
assertEquals("us-east-2", signature.getRegion());
assertEquals(URI.create(url).normalize().toString(), signature.getUrl());
}

@Test
Expand Down Expand Up @@ -514,13 +514,13 @@ public void sign_postGetCallerIdentityNoToken() {
+ "aws4_request, SignedHeaders=host;x-amz-date, Signature="
+ expectedSignature;

assertThat(signature.getSignature()).isEqualTo(expectedSignature);
assertThat(signature.getAuthorizationHeader()).isEqualTo(expectedAuthHeader);
assertThat(signature.getSecurityCredentials()).isEqualTo(awsSecurityCredentialsWithoutToken);
assertThat(signature.getDate()).isEqualTo(X_AMZ_DATE);
assertThat(signature.getHttpMethod()).isEqualTo("POST");
assertThat(signature.getRegion()).isEqualTo("us-east-2");
assertThat(signature.getUrl()).isEqualTo(URI.create(url).normalize().toString());
assertEquals(expectedSignature, signature.getSignature());
assertEquals(expectedAuthHeader, signature.getAuthorizationHeader());
assertEquals(awsSecurityCredentialsWithoutToken, signature.getSecurityCredentials());
assertEquals(X_AMZ_DATE, signature.getDate());
assertEquals("POST", signature.getHttpMethod());
assertEquals("us-east-2", signature.getRegion());
assertEquals(URI.create(url).normalize().toString(), signature.getUrl());
}

public AwsSecurityCredentials retrieveAwsSecurityCredentials() throws IOException {
Expand Down
Loading

0 comments on commit 6d04b05

Please sign in to comment.