Skip to content

Functions Interop #2113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion FirebaseFunctions.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ iOS SDK for Cloud Functions for Firebase.
s.source_files = 'Functions/FirebaseFunctions/**/*'
s.public_header_files = 'Functions/FirebaseFunctions/Public/*.h'

s.dependency 'FirebaseCore', '~> 5.0'
s.dependency 'FirebaseAuthInterop', '~> 1.0'
s.dependency 'FirebaseCore', '~> 5.1'
s.dependency 'GTMSessionFetcher/Core', '~> 1.1'

s.pod_target_xcconfig = {
Expand Down
6 changes: 3 additions & 3 deletions Functions/Backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "functions",
"description": "Cloud Functions for Firebase",
"dependencies": {
"firebase-admin": "~4.2.1",
"firebase-functions": "^0.5.7"
"firebase-admin": "^6.0.0",
"firebase-functions": "^2.1.0"
},
"private": true,
"devDependencies": {
"@google-cloud/functions-emulator": "^1.0.0-alpha.21"
"@google-cloud/functions-emulator": "^1.0.0-beta.5"
}
}
36 changes: 26 additions & 10 deletions Functions/Example/FirebaseFunctions.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
7CBFAA88205702AB00A65866 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; };
7CBFAA8B205702AB00A65866 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; };
7CF3BEC21F97EE2F00B16B6E /* FUNFakeInstanceID.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CF3BEC01F97EE2F00B16B6E /* FUNFakeInstanceID.m */; };
7CF563091F1FE70600FEE1F4 /* FUNFakeApp.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CF563081F1FE70600FEE1F4 /* FUNFakeApp.m */; };
873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; };
C8AEC40B21B7EE440051C01E /* FIRAuthInteropFake.m in Sources */ = {isa = PBXBuildFile; fileRef = C8AEC40A21B7EE440051C01E /* FIRAuthInteropFake.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -74,9 +74,9 @@
7CBFAA91205702AB00A65866 /* FirebaseFunctions_IntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FirebaseFunctions_IntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
7CF3BEC01F97EE2F00B16B6E /* FUNFakeInstanceID.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUNFakeInstanceID.m; sourceTree = "<group>"; };
7CF3BEC11F97EE2F00B16B6E /* FUNFakeInstanceID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUNFakeInstanceID.h; sourceTree = "<group>"; };
7CF563081F1FE70600FEE1F4 /* FUNFakeApp.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FUNFakeApp.m; sourceTree = "<group>"; };
7CF5630A1F1FE76700FEE1F4 /* FUNFakeApp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FUNFakeApp.h; sourceTree = "<group>"; };
873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
C8AEC40921B7EE440051C01E /* FIRAuthInteropFake.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FIRAuthInteropFake.h; path = ../../../Example/Shared/FIRAuthInteropFake.h; sourceTree = "<group>"; };
C8AEC40A21B7EE440051C01E /* FIRAuthInteropFake.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FIRAuthInteropFake.m; path = ../../../Example/Shared/FIRAuthInteropFake.m; sourceTree = "<group>"; };
E0A8D570636E99E7C3396DF8 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
F1F2A7C03C10A3A03F9502B8 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -207,8 +207,8 @@
7C70065B20572C1B007A5573 /* TestUtils */ = {
isa = PBXGroup;
children = (
7CF5630A1F1FE76700FEE1F4 /* FUNFakeApp.h */,
7CF563081F1FE70600FEE1F4 /* FUNFakeApp.m */,
C8AEC40921B7EE440051C01E /* FIRAuthInteropFake.h */,
C8AEC40A21B7EE440051C01E /* FIRAuthInteropFake.m */,
7CF3BEC11F97EE2F00B16B6E /* FUNFakeInstanceID.h */,
7CF3BEC01F97EE2F00B16B6E /* FUNFakeInstanceID.m */,
);
Expand Down Expand Up @@ -349,7 +349,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7CF563091F1FE70600FEE1F4 /* FUNFakeApp.m in Sources */,
6003F59E195388D20070C39A /* FIRAppDelegate.m in Sources */,
6003F5A7195388D20070C39A /* FIRViewController.m in Sources */,
7CF3BEC21F97EE2F00B16B6E /* FUNFakeInstanceID.m in Sources */,
Expand All @@ -370,6 +369,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C8AEC40B21B7EE440051C01E /* FIRAuthInteropFake.m in Sources */,
7CBFAA82205702AB00A65866 /* FIRIntegrationTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -538,7 +538,11 @@
"DEBUG=1",
"$(inherited)",
);
HEADER_SEARCH_PATHS = "$(SRCROOT)/../FirebaseFunctions";
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../../Firebase/Core/Private",
"$(SRCROOT)/../FirebaseFunctions",
);
INFOPLIST_FILE = "Tests/Tests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -557,7 +561,11 @@
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = NO;
HEADER_SEARCH_PATHS = "$(SRCROOT)/../FirebaseFunctions";
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../../Firebase/Core/Private",
"$(SRCROOT)/../FirebaseFunctions",
);
INFOPLIST_FILE = "Tests/Tests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -580,7 +588,11 @@
"DEBUG=1",
"$(inherited)",
);
HEADER_SEARCH_PATHS = "$(SRCROOT)/../FirebaseFunctions";
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../../Firebase/Core/Private",
"$(SRCROOT)/../FirebaseFunctions",
);
INFOPLIST_FILE = "IntegrationTests/IntegrationTests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -599,7 +611,11 @@
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = NO;
HEADER_SEARCH_PATHS = "$(SRCROOT)/../FirebaseFunctions";
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../../Firebase/Core/Private",
"$(SRCROOT)/../FirebaseFunctions",
);
INFOPLIST_FILE = "IntegrationTests/IntegrationTests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
18 changes: 13 additions & 5 deletions Functions/Example/IntegrationTests/FIRIntegrationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@

#import <XCTest/XCTest.h>

#import "FIRAuthInteropFake.h"
#import "FIRError.h"
#import "FIRFunctions+Internal.h"
#import "FIRFunctions.h"
#import "FIRHTTPSCallable.h"
#import "FUNFakeApp.h"
#import "FUNFakeInstanceID.h"

// Project ID used by these tests.
static NSString *const kProjectID = @"functions-integration-test";

@interface FIRIntegrationTests : XCTestCase {
FIRFunctions *_functions;
}
Expand All @@ -30,8 +33,10 @@ @implementation FIRIntegrationTests

- (void)setUp {
[super setUp];
id app = [[FUNFakeApp alloc] initWithProjectID:@"functions-integration-test"];
_functions = [FIRFunctions functionsForApp:app];
_functions = [[FIRFunctions alloc]
initWithProjectID:kProjectID
region:@"us-central1"
auth:[[FIRAuthInteropFake alloc] initWithToken:nil userID:nil error:nil]];
[_functions useLocalhost];
}

Expand Down Expand Up @@ -76,8 +81,10 @@ - (void)testScalar {

- (void)testToken {
// Recreate _functions with a token.
id app = [[FUNFakeApp alloc] initWithProjectID:@"functions-integration-test" token:@"token"];
FIRFunctions *functions = [FIRFunctions functionsForApp:app];
FIRFunctions *functions = [[FIRFunctions alloc]
initWithProjectID:kProjectID
region:@"us-central1"
auth:[[FIRAuthInteropFake alloc] initWithToken:@"token" userID:nil error:nil]];
[functions useLocalhost];

XCTestExpectation *expectation = [[XCTestExpectation alloc] init];
Expand Down Expand Up @@ -115,6 +122,7 @@ - (void)testNull {
[self waitForExpectations:@[ expectation ] timeout:10];

// Test the version with no arguments.
expectation = [[XCTestExpectation alloc] init];
[function
callWithCompletion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
XCTAssertEqualObjects([NSNull null], result.data);
Expand Down
3 changes: 2 additions & 1 deletion Functions/Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ use_frameworks!
target 'FirebaseFunctions_Example' do
platform :ios, '8.0'

pod 'FirebaseAuthInterop', :path => '../../'
pod 'FirebaseCore', :path => '../../'
pod 'GoogleUtilities', :path => '../../'
pod 'FirebaseFunctions', :path => '../../'
pod 'GoogleUtilities', :path => '../../'

target 'FirebaseFunctions_Tests' do
inherit! :search_paths
Expand Down
39 changes: 0 additions & 39 deletions Functions/Example/TestUtils/FUNFakeApp.h

This file was deleted.

73 changes: 0 additions & 73 deletions Functions/Example/TestUtils/FUNFakeApp.m

This file was deleted.

10 changes: 2 additions & 8 deletions Functions/Example/Tests/FIRFunctionsTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#import "FIRFunctions+Internal.h"
#import "FIRFunctions.h"

#import "FUNFakeApp.h"

@interface FIRFunctionsTests : XCTestCase
@end

Expand All @@ -33,14 +31,10 @@ - (void)tearDown {
}

- (void)testURLWithName {
id app = [[FUNFakeApp alloc] initWithProjectID:@"my-project"];
FIRFunctions *functions = [FIRFunctions functionsForApp:app region:@"my-region"];
FIRFunctions *functions =
[[FIRFunctions alloc] initWithProjectID:@"my-project" region:@"my-region" auth:nil];
NSString *url = [functions URLWithName:@"my-endpoint"];
XCTAssertEqualObjects(@"https://my-region-my-project.cloudfunctions.net/my-endpoint", url);

functions = [FIRFunctions functionsForApp:app];
url = [functions URLWithName:@"my-endpoint"];
XCTAssertEqualObjects(@"https://us-central1-my-project.cloudfunctions.net/my-endpoint", url);
}

@end
11 changes: 11 additions & 0 deletions Functions/FirebaseFunctions/FIRFunctions+Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#import "FIRFunctions.h"

@protocol FIRAuthInterop;
@class FIRHTTPSCallableResult;

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -45,6 +46,16 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)useLocalhost;

/**
* Internal initializer for the Cloud Functions client.
* @param projectID The project ID for the Firebase project.
* @param region The region for the http trigger, such as "us-central1".
* @param auth The auth provider to use (optional).
*/
- (id)initWithProjectID:(NSString *)projectID
region:(NSString *)region
auth:(nullable id<FIRAuthInterop>)auth;

@end

NS_ASSUME_NONNULL_END
Loading