Skip to content

Commit ad25d85

Browse files
committed
Add in the app enabled test for th e
1 parent 3416930 commit ad25d85

10 files changed

Lines changed: 3476 additions & 1 deletion

File tree

functions/integration_test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ endif()
236236
# Add the Firebase libraries to the target using the function from the SDK.
237237
add_subdirectory(${FIREBASE_CPP_SDK_DIR} bin/ EXCLUDE_FROM_ALL)
238238
# Note that firebase_app needs to be last in the list.
239-
set(firebase_libs firebase_functions firebase_auth firebase_app)
239+
set(firebase_libs firebase_app_check firebase_functions firebase_auth firebase_app)
240240
set(gtest_libs gtest gmock)
241241
target_link_libraries(${integration_test_target_name} ${firebase_libs}
242242
${gtest_libs} ${ADDITIONAL_LIBS})

functions/integration_test/Podfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ use_frameworks! :linkage => :static
44

55
target 'integration_test' do
66
platform :ios, '15.0'
7+
pod 'Firebase/AppCheck', '12.10.0'
78
pod 'Firebase/Functions', '12.10.0'
89
pod 'Firebase/Auth', '12.10.0'
910
end
1011

1112
target 'integration_test_tvos' do
1213
platform :tvos, '15.0'
14+
pod 'Firebase/AppCheck', '12.10.0'
1315
pod 'Firebase/Functions', '12.10.0'
1416
pod 'Firebase/Auth', '12.10.0'
1517
end

functions/integration_test/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ android {
8484

8585
apply from: "$gradle.firebase_cpp_sdk_dir/Android/firebase_dependencies.gradle"
8686
firebaseCpp.dependencies {
87+
appCheck
8788
auth
8889
functions
8990
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"projects": {
3+
"default": "functions-test-app"
4+
}
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"functions": {
3+
}
4+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Import function triggers from their respective submodules:
3+
*
4+
* const {onCall} = require("firebase-functions/v1/https"); // wait, V1 doesn't have /v1/https
5+
*
6+
* See a full list of supported triggers at https://firebase.google.com/docs/functions
7+
*/
8+
9+
const functions = require("firebase-functions");
10+
11+
// Creates a function that consumes limited-use App Check tokens
12+
exports.addtwowithlimiteduse = functions.runWith({
13+
enforceAppCheck: true,
14+
consumeAppCheckToken: true,
15+
maxInstances: 10 // Setting maxInstances the V1 way
16+
}).https.onCall((data, context) => {
17+
// context.app will be defined if a valid App Check token was provided
18+
if (context.app === undefined) {
19+
throw new functions.https.HttpsError(
20+
'failed-precondition',
21+
'The function must be called from an App Check verified app.');
22+
}
23+
24+
const firstNumber = data.firstNumber;
25+
const secondNumber = data.secondNumber;
26+
27+
if (firstNumber === undefined || secondNumber === undefined) {
28+
throw new functions.https.HttpsError('invalid-argument', 'The function must be called with "firstNumber" and "secondNumber".');
29+
}
30+
31+
return {
32+
firstNumber: firstNumber,
33+
secondNumber: secondNumber,
34+
operator: '+',
35+
operationResult: Number(firstNumber) + Number(secondNumber),
36+
};
37+
});

0 commit comments

Comments
 (0)