Skip to content

Commit a55a602

Browse files
committed
Fix tests
1 parent 95a4d35 commit a55a602

File tree

4 files changed

+44
-41
lines changed

4 files changed

+44
-41
lines changed

firebase-functions/ktx/ktx.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,4 @@ dependencies {
5959
testImplementation(libs.junit)
6060
testImplementation(libs.truth)
6161
testImplementation(libs.androidx.test.core)
62-
testImplementation(project(":firebase-functions"))
6362
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.google.firebase.functions;
2+
3+
/**
4+
* Returns true if the {@link HttpsCallableReference} is configured to use FAC limited-use tokens.
5+
*/
6+
fun HttpsCallableReference.usesLimitedUseFacTokens() = options.getLimitedUseAppCheckTokens()

firebase-functions/ktx/src/test/kotlin/com/google/firebase/functions/ktx/FunctionsTests.kt

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ import com.google.common.truth.Truth.assertThat
1919
import com.google.firebase.FirebaseApp
2020
import com.google.firebase.FirebaseOptions
2121
import com.google.firebase.functions.FirebaseFunctions
22-
import com.google.firebase.functions.HttpsCallableReference
23-
import com.google.firebase.functions.TestVisibilityUtil
22+
import com.google.firebase.functions.usesLimitedUseFacTokens
2423
import com.google.firebase.ktx.Firebase
2524
import com.google.firebase.ktx.app
2625
import com.google.firebase.ktx.initialize
@@ -107,35 +106,47 @@ class LibraryVersionTest : BaseTestCase() {
107106

108107
@RunWith(RobolectricTestRunner::class)
109108
class AppCheckLimitedUseTest : BaseTestCase() {
109+
@Test
110+
fun `FirebaseFunctions#getHttpsCallable should not use limited-use tokens by default`() {
111+
val callable = Firebase.functions.getHttpsCallable("function")
112+
assertThat(callable.usesLimitedUseFacTokens()).isFalse()
113+
}
114+
110115
@Test
111116
fun `FirebaseFunctions#getHttpsCallable should build callable with FAC settings (when true)`() {
112117
val callable = Firebase.functions.getHttpsCallable("function") {
113118
limitedUseAppCheckTokens = true
114-
};
115-
assertThat(TestVisibilityUtil.refUsesLimitedUseFacTokens(callable)).isEqualTo(true)
119+
}
120+
assertThat(callable.usesLimitedUseFacTokens()).isTrue()
116121
}
117122

118-
// @Test
119-
// fun `FirebaseFunctions#getHttpsCallable should build callable with FAC settings (when false)`() {
120-
// val callable = Firebase.functions.getHttpsCallable("function") {
121-
// limitedUseAppCheckTokens = false
122-
// };
123-
// assertLimitedUseFACTokens(callable, false)
124-
// }
125-
//
126-
// @Test
127-
// fun `FirebaseFunctions#getHttpsCallableFromUrl callable with FAC settings (when true)`() {
128-
// val callable = Firebase.functions.getHttpsCallableFromUrl(URL()) {
129-
// limitedUseAppCheckTokens = true
130-
// };
131-
// assertLimitedUseFACTokens(callable, true)
132-
// }
133-
//
134-
// @Test
135-
// fun `FirebaseFunctions#getHttpsCallable should build callable with FAC settings (when false)`() {
136-
// val callable = Firebase.functions.getHttpsCallable("function") {
137-
// limitedUseAppCheckTokens = false
138-
// };
139-
// assertLimitedUseFACTokens(callable, false)
140-
// }
123+
@Test
124+
fun `FirebaseFunctions#getHttpsCallable should build callable with FAC settings (when false)`() {
125+
val callable = Firebase.functions.getHttpsCallable("function") {
126+
limitedUseAppCheckTokens = false
127+
}
128+
assertThat(callable.usesLimitedUseFacTokens()).isFalse()
129+
}
130+
131+
@Test
132+
fun `FirebaseFunctions#getHttpsCallableFromUrl should not use limited-use tokens by default`() {
133+
val callable = Firebase.functions.getHttpsCallableFromUrl(URL("https://functions.test"))
134+
assertThat(callable.usesLimitedUseFacTokens()).isFalse()
135+
}
136+
137+
@Test
138+
fun `FirebaseFunctions#getHttpsCallableFromUrl callable with FAC settings (when true)`() {
139+
val callable = Firebase.functions.getHttpsCallableFromUrl(URL("https://functions.test")) {
140+
limitedUseAppCheckTokens = true
141+
}
142+
assertThat(callable.usesLimitedUseFacTokens()).isTrue()
143+
}
144+
145+
@Test
146+
fun `FirebaseFunctions#getHttpsCallableFromUrl callable with FAC settings (when false)`() {
147+
val callable = Firebase.functions.getHttpsCallableFromUrl(URL("https://functions.test")) {
148+
limitedUseAppCheckTokens = false
149+
}
150+
assertThat(callable.usesLimitedUseFacTokens()).isFalse()
151+
}
141152
}

firebase-functions/src/test/java/com/google/firebase/functions/TestVisibilityUtil.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)