Skip to content

Commit 277a72c

Browse files
committed
added android tests to github action workflow
1 parent b4c4e9f commit 277a72c

5 files changed

Lines changed: 41 additions & 5 deletions

File tree

.github/workflows/main.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,27 @@ jobs:
3131
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f
3232
with:
3333
directory: coverage
34+
35+
android-test:
36+
name: Run Android tests
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
42+
43+
- name: Setup
44+
uses: ./.github/actions/setup
45+
46+
- name: Set up JDK 17
47+
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5
48+
with:
49+
distribution: temurin
50+
java-version: '17'
51+
52+
- name: Setup Gradle
53+
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5
54+
55+
- name: Run Android unit tests
56+
working-directory: example/android
57+
run: ./gradlew :react-native-auth0:testDebugUnitTest

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,4 +1079,4 @@ This project is licensed under the MIT license. See the <a href="https://github.
10791079
[license-image]: https://img.shields.io/npm/l/react-native-auth0.svg?style=flat-square
10801080
[license-url]: #license
10811081
[downloads-image]: https://img.shields.io/npm/dm/react-native-auth0.svg?style=flat-square
1082-
[downloads-url]: https://npmjs.org/package/react-native-auth0
1082+
[downloads-url]: https://npmjs.org/package/react-native-auth0

android/src/main/java/com/auth0/react/A0Auth0Module.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ class A0Auth0Module(private val reactContext: ReactApplicationContext) : A0Auth0
8282
options.getMap("defaultHeaders")?.let { headers ->
8383
builder.defaultHeaders(headers.toHashMap().mapValues { it.value?.toString() ?: "" })
8484
}
85+
// Only honor enableLogging on debug builds: Auth0.Android logs full request/response
86+
// bodies at this level, including plaintext access/refresh/ID tokens from token-endpoint
87+
// responses. Test coverage in A0Auth0ModuleNetworkingOptionsTest ensures this gate holds.
8588
if (isDebuggable && options.hasKey("enableLogging")) {
8689
builder.enableLogging(options.getBoolean("enableLogging"))
8790
}

android/src/test/java/com/auth0/react/A0Auth0ModuleNetworkingOptionsTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ class A0Auth0ModuleNetworkingOptionsTest {
8080
fun `enableLogging is ignored on a non-debuggable build even when requested`() {
8181
server.enqueue(MockResponse().setBody("{}"))
8282

83-
// If the debuggable gate is ever removed, Auth0.Android attaches its logging
84-
// interceptor and this request crashes ("Method ... not mocked") because
85-
// android.util.Log isn't stubbed in this unit test environment - that crash is
86-
// exactly the regression this test is meant to catch.
83+
// SECURITY: If the isDebuggable gate is ever removed, Auth0.Android attaches its
84+
// logging interceptor which logs full request/response bodies (including tokens).
85+
// This test would crash ("Method android.util.Log not mocked") if that happens,
86+
// catching the security regression before it ships.
8787
val client = A0Auth0Module.buildNetworkingClient(
8888
JavaOnlyMap.of("enableLogging", true),
8989
isDebuggable = false

src/types/common.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,15 @@ export interface Auth0Options {
228228
* Mirrors `DefaultClient.Builder` from the Auth0.Android SDK.
229229
*
230230
* @remarks Android only. Has no effect on iOS or web.
231+
*
232+
* @example
233+
* ```ts
234+
* networkingOptions: {
235+
* connectTimeout: 30,
236+
* readTimeout: 30,
237+
* defaultHeaders: { 'X-App-Version': '1.2.3' }
238+
* }
239+
* ```
231240
*/
232241
export interface NetworkingOptions {
233242
/** Connection timeout, in seconds. @default 10 */

0 commit comments

Comments
 (0)