Skip to content

Commit 11cbc54

Browse files
committed
add tests, cleanup not used classed, lint.
1 parent 9e9af89 commit 11cbc54

File tree

14 files changed

+361
-605
lines changed

14 files changed

+361
-605
lines changed

oauth2_http/java/com/google/auth/oauth2/LoggerProvider.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions are
6+
* met:
7+
*
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above
11+
* copyright notice, this list of conditions and the following disclaimer
12+
* in the documentation and/or other materials provided with the
13+
* distribution.
14+
*
15+
* * Neither the name of Google LLC nor the names of its
16+
* contributors may be used to endorse or promote products derived from
17+
* this software without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
132
package com.google.auth.oauth2;
233

334
import org.slf4j.Logger;

oauth2_http/java/com/google/auth/oauth2/LoggingUtils.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions are
6+
* met:
7+
*
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above
11+
* copyright notice, this list of conditions and the following disclaimer
12+
* in the documentation and/or other materials provided with the
13+
* distribution.
14+
*
15+
* * Neither the name of Google LLC nor the names of its
16+
* contributors may be used to endorse or promote products derived from
17+
* this software without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
132
package com.google.auth.oauth2;
233

334
import com.google.api.client.http.HttpRequest;

oauth2_http/java/com/google/auth/oauth2/Slf4jUtils.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Google LLC
2+
* Copyright 2025 Google LLC
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are
@@ -36,8 +36,6 @@
3636
import com.google.api.client.http.UrlEncodedContent;
3737
import com.google.api.client.http.json.JsonHttpContent;
3838
import com.google.api.client.util.GenericData;
39-
// import com.google.auth.oauth2.LoggingConfigs.DefaultLoggerFactoryProvider;
40-
// import com.google.auth.oauth2.LoggingConfigs.LoggerFactoryProvider;
4139
import com.google.gson.Gson;
4240
import java.nio.charset.StandardCharsets;
4341
import java.security.MessageDigest;

oauth2_http/javatests/com/google/auth/oauth2/LoggingTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Google LLC
2+
* Copyright 2025 Google LLC
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are
@@ -182,6 +182,7 @@ public void serviceAccountCredentials_getRequestMetadata_hasAccessToken() throws
182182
|| kvp.key.equals("request.method")
183183
|| kvp.key.equals("request.url"));
184184
if (kvp.key.equals("request.payload")) {
185+
// ensure correctly formatted as JSON
185186
assertTrue(isValidJson((String) kvp.value));
186187
}
187188
}
@@ -520,9 +521,6 @@ public void idTokenWithAudience_full() throws IOException {
520521
|| kvp.key.equals("response.status")
521522
|| kvp.key.equals("response.status.message"));
522523
}
523-
// assertEquals("Response payload for ID token request",
524-
// testAppender.events.get(2).getMessage());
525-
// assertEquals(1, testAppender.events.get(2).getKeyValuePairs().size());
526524

527525
testAppender.stop();
528526
}

oauth2_http/javatests/com/google/auth/oauth2/LoggingUtilsTest.java

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Google LLC
2+
* Copyright 2025 Google LLC
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are
@@ -34,67 +34,18 @@
3434
import static org.junit.Assert.assertFalse;
3535
import static org.junit.Assert.assertTrue;
3636

37-
// import ch.qos.logback.classic.LoggerContext;
38-
import org.junit.After;
3937
import org.junit.Before;
4038
import org.junit.Test;
41-
import org.slf4j.Logger;
42-
import org.slf4j.LoggerFactory;
4339

4440
public class LoggingUtilsTest {
4541

46-
private static final Logger LOGGER = LoggerFactory.getLogger(LoggingUtilsTest.class);
47-
4842
private TestEnvironmentProvider testEnvironmentProvider;
4943

5044
@Before
5145
public void setup() {
5246
testEnvironmentProvider = new TestEnvironmentProvider();
5347
}
5448

55-
// @After
56-
// public void tearDown() {
57-
// LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
58-
// loggerContext.getLogger(Logger.ROOT_LOGGER_NAME).detachAppender("CONSOLE");
59-
// }
60-
61-
// @Test
62-
// public void testGetLogger_loggingEnabled_slf4jBindingPresent() {
63-
// testEnvironmentProvider.setEnv(LoggingUtils.GOOGLE_SDK_JAVA_LOGGING, "true");
64-
// LoggingUtils.setEnvironmentProvider(testEnvironmentProvider);
65-
// Logger logger = LoggingUtils.getLogger(LoggingUtilsTest.class);
66-
// assertNotNull(logger);
67-
// assertNotEquals(NOPLogger.class, logger.getClass());
68-
// }
69-
//
70-
// @Test
71-
// public void testGetLogger_loggingDisabled() {
72-
// testEnvironmentProvider.setEnv(LoggingUtils.GOOGLE_SDK_JAVA_LOGGING, "false");
73-
// LoggingConfigs.setEnvironmentProvider(testEnvironmentProvider);
74-
//
75-
// Logger logger = LoggingConfigs.getLogger(LoggingUtilsTest.class);
76-
// assertEquals(NOPLogger.class, logger.getClass());
77-
// }
78-
//
79-
// @Test
80-
// public void testGetLogger_loggingEnabled_noBinding() {
81-
// testEnvironmentProvider.setEnv(LoggingUtils.GOOGLE_SDK_JAVA_LOGGING, "true");
82-
// LoggingConfigs.setEnvironmentProvider(testEnvironmentProvider);
83-
// // Create a mock LoggerFactoryProvider
84-
// LoggerFactoryProvider mockLoggerFactoryProvider = mock(LoggerFactoryProvider.class);
85-
// ILoggerFactory mockLoggerFactory = mock(ILoggerFactory.class);
86-
// when(mockLoggerFactoryProvider.getLoggerFactory()).thenReturn(mockLoggerFactory);
87-
// when(mockLoggerFactory.getLogger(anyString()))
88-
// .thenReturn(org.slf4j.helpers.NOPLogger.NOP_LOGGER);
89-
//
90-
// // Use the mock LoggerFactoryProvider in getLogger()
91-
// Logger logger = LoggingConfigs.getLogger(LoggingUtilsTest.class,
92-
// mockLoggerFactoryProvider);
93-
//
94-
// // Assert that the returned logger is a NOPLogger
95-
// assertTrue(logger instanceof org.slf4j.helpers.NOPLogger);
96-
// }
97-
9849
@Test
9950
public void testIsLoggingEnabled_true() {
10051
testEnvironmentProvider.setEnv(LoggingUtils.GOOGLE_SDK_JAVA_LOGGING, "true");

oauth2_http/javatests/com/google/auth/oauth2/Slf4jUtils1xTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions are
6+
* met:
7+
*
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above
11+
* copyright notice, this list of conditions and the following disclaimer
12+
* in the documentation and/or other materials provided with the
13+
* distribution.
14+
*
15+
* * Neither the name of Google LLC nor the names of its
16+
* contributors may be used to endorse or promote products derived from
17+
* this software without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
132
package com.google.auth.oauth2;
233

334
import static org.junit.Assert.assertEquals;

0 commit comments

Comments
 (0)