Skip to content

Commit b3ad25c

Browse files
committed
Create an intergration test for the limited use tokens
1 parent 3830722 commit b3ad25c

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

app_check/integration_test/src/integration_test.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,32 @@ TEST_F(FirebaseAppCheckTest, TestDebugProviderValidToken) {
588588
got_token_future.wait_for(kGetTokenTimeout));
589589
}
590590

591+
TEST_F(FirebaseAppCheckTest, TestDebugProviderValidLimitedUseToken) {
592+
firebase::app_check::DebugAppCheckProviderFactory* factory =
593+
firebase::app_check::DebugAppCheckProviderFactory::GetInstance();
594+
ASSERT_NE(factory, nullptr);
595+
InitializeAppCheckWithDebug();
596+
InitializeApp();
597+
598+
firebase::app_check::AppCheckProvider* provider =
599+
factory->CreateProvider(app_);
600+
ASSERT_NE(provider, nullptr);
601+
auto got_token_promise = std::make_shared<std::promise<void>>();
602+
auto token_callback{
603+
[got_token_promise](firebase::app_check::AppCheckToken token,
604+
int error_code, const std::string& error_message) {
605+
EXPECT_EQ(firebase::app_check::kAppCheckErrorNone, error_code);
606+
EXPECT_EQ("", error_message);
607+
EXPECT_NE(0, token.expire_time_millis);
608+
EXPECT_NE("", token.token);
609+
got_token_promise->set_value();
610+
}};
611+
provider->GetLimitedUseToken(token_callback);
612+
auto got_token_future = got_token_promise->get_future();
613+
ASSERT_EQ(std::future_status::ready,
614+
got_token_future.wait_for(kGetTokenTimeout));
615+
}
616+
591617
TEST_F(FirebaseAppCheckTest, TestAppAttestProvider) {
592618
firebase::app_check::AppAttestProviderFactory* factory =
593619
firebase::app_check::AppAttestProviderFactory::GetInstance();

app_check/src/android/app_check_android.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,18 +242,13 @@ JNIEXPORT jlong JNICALL JniAppCheckProviderFactory_nativeCreateProvider(
242242
JNIEXPORT void JNICALL JniAppCheckProvider_nativeGetToken(
243243
JNIEnv* env, jobject j_provider, jlong c_provider,
244244
jobject task_completion_source) {
245-
// Create GlobalReferences to the provider and task. These references will be
246-
// deleted in the completion callback.
247245
jobject j_provider_global = env->NewGlobalRef(j_provider);
248246
jobject task_completion_source_global =
249247
env->NewGlobalRef(task_completion_source);
250248

251-
// Defines a C++ callback method to call
252-
// JniAppCheckProvider.HandleGetTokenResult with the resulting token
253249
auto token_callback{[j_provider_global, task_completion_source_global](
254250
firebase::app_check::AppCheckToken token,
255251
int error_code, const std::string& error_message) {
256-
// util::GetJNIEnvFromApp returns a threadsafe instance of JNIEnv.
257252
JNIEnv* env = firebase::util::GetJNIEnvFromApp();
258253
jstring error_string = env->NewStringUTF(error_message.c_str());
259254
jstring token_string = env->NewStringUTF(token.token.c_str());

0 commit comments

Comments
 (0)