Skip to content

Commit

Permalink
Run mvn fmt:format.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmehta19 committed Oct 25, 2024
1 parent 594df7b commit 16fd964
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
3 changes: 2 additions & 1 deletion oauth2_http/java/com/google/auth/oauth2/S2A.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ private S2AConfig getS2AConfigFromMDS() {
String plaintextS2AAddress = "";
String mtlsS2AAddress = "";
try {
HttpRequest request = transportFactory.create().createRequestFactory().buildGetRequest(genericUrl);
HttpRequest request =
transportFactory.create().createRequestFactory().buildGetRequest(genericUrl);
request.setParser(parser);
request.getHeaders().set(METADATA_FLAVOR, GOOGLE);
request.setThrowExceptionOnExecuteError(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,11 @@ public LowLevelHttpResponse execute() throws IOException {
GenericJson content = new GenericJson();
content.setFactory(OAuth2Utils.JSON_FACTORY);
if (requestStatusCode == 200) {
content.put(s2aContentMap.get("plaintextS2AAddressJsonKey"), s2aContentMap.get("plaintextS2AAddress"));
content.put(s2aContentMap.get("mtlsS2AAddressJsonKey"), s2aContentMap.get("mtlsS2AAddress"));
content.put(
s2aContentMap.get("plaintextS2AAddressJsonKey"),
s2aContentMap.get("plaintextS2AAddress"));
content.put(
s2aContentMap.get("mtlsS2AAddressJsonKey"), s2aContentMap.get("mtlsS2AAddress"));
}
String contentText = content.toPrettyString();

Expand Down
24 changes: 16 additions & 8 deletions oauth2_http/javatests/com/google/auth/oauth2/S2ATest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ public class S2ATest {
@Test
public void getS2AAddress_validAddress() {
MockMetadataServerTransportFactory transportFactory = new MockMetadataServerTransportFactory();
transportFactory.transport.setS2AContentMap("plaintextS2AAddressJsonKey", S2A.S2A_PLAINTEXT_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap(
"plaintextS2AAddressJsonKey", S2A.S2A_PLAINTEXT_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap("plaintextS2AAddress", S2A_PLAINTEXT_ADDRESS);
transportFactory.transport.setS2AContentMap("mtlsS2AAddressJsonKey", S2A.S2A_MTLS_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap(
"mtlsS2AAddressJsonKey", S2A.S2A_MTLS_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap("mtlsS2AAddress", S2A_MTLS_ADDRESS);
transportFactory.transport.setRequestStatusCode(HttpStatusCodes.STATUS_CODE_OK);

Expand All @@ -66,9 +68,11 @@ public void getS2AAddress_validAddress() {
@Test
public void getS2AAddress_queryEndpointResponseErrorCode_emptyAddress() {
MockMetadataServerTransportFactory transportFactory = new MockMetadataServerTransportFactory();
transportFactory.transport.setS2AContentMap("plaintextS2AAddressJsonKey", S2A.S2A_PLAINTEXT_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap(
"plaintextS2AAddressJsonKey", S2A.S2A_PLAINTEXT_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap("plaintextS2AAddress", S2A_PLAINTEXT_ADDRESS);
transportFactory.transport.setS2AContentMap("mtlsS2AAddressJsonKey", S2A.S2A_MTLS_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap(
"mtlsS2AAddressJsonKey", S2A.S2A_MTLS_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap("mtlsS2AAddress", S2A_MTLS_ADDRESS);
transportFactory.transport.setRequestStatusCode(
HttpStatusCodes.STATUS_CODE_SERVICE_UNAVAILABLE);
Expand All @@ -83,9 +87,11 @@ public void getS2AAddress_queryEndpointResponseErrorCode_emptyAddress() {
@Test
public void getS2AAddress_queryEndpointResponseEmpty_emptyAddress() {
MockMetadataServerTransportFactory transportFactory = new MockMetadataServerTransportFactory();
transportFactory.transport.setS2AContentMap("plaintextS2AAddressJsonKey", S2A.S2A_PLAINTEXT_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap(
"plaintextS2AAddressJsonKey", S2A.S2A_PLAINTEXT_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap("plaintextS2AAddress", S2A_PLAINTEXT_ADDRESS);
transportFactory.transport.setS2AContentMap("mtlsS2AAddressJsonKey", S2A.S2A_MTLS_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap(
"mtlsS2AAddressJsonKey", S2A.S2A_MTLS_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap("mtlsS2AAddress", S2A_MTLS_ADDRESS);
transportFactory.transport.setRequestStatusCode(HttpStatusCodes.STATUS_CODE_OK);
transportFactory.transport.setEmptyContent(true);
Expand All @@ -102,7 +108,8 @@ public void getS2AAddress_queryEndpointResponseInvalidPlaintextJsonKey_plaintext
MockMetadataServerTransportFactory transportFactory = new MockMetadataServerTransportFactory();
transportFactory.transport.setS2AContentMap("plaintextS2AAddressJsonKey", INVALID_JSON_KEY);
transportFactory.transport.setS2AContentMap("plaintextS2AAddress", S2A_PLAINTEXT_ADDRESS);
transportFactory.transport.setS2AContentMap("mtlsS2AAddressJsonKey", S2A.S2A_MTLS_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap(
"mtlsS2AAddressJsonKey", S2A.S2A_MTLS_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap("mtlsS2AAddress", S2A_MTLS_ADDRESS);
transportFactory.transport.setRequestStatusCode(HttpStatusCodes.STATUS_CODE_OK);

Expand All @@ -116,7 +123,8 @@ public void getS2AAddress_queryEndpointResponseInvalidPlaintextJsonKey_plaintext
@Test
public void getS2AAddress_queryEndpointResponseInvalidMtlsJsonKey_mtlsEmptyAddress() {
MockMetadataServerTransportFactory transportFactory = new MockMetadataServerTransportFactory();
transportFactory.transport.setS2AContentMap("plaintextS2AAddressJsonKey", S2A.S2A_PLAINTEXT_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap(
"plaintextS2AAddressJsonKey", S2A.S2A_PLAINTEXT_ADDRESS_JSON_KEY);
transportFactory.transport.setS2AContentMap("plaintextS2AAddress", S2A_PLAINTEXT_ADDRESS);
transportFactory.transport.setS2AContentMap("mtlsS2AAddressJsonKey", INVALID_JSON_KEY);
transportFactory.transport.setS2AContentMap("mtlsS2AAddress", S2A_MTLS_ADDRESS);
Expand Down

0 comments on commit 16fd964

Please sign in to comment.