Skip to content

Commit aa00c74

Browse files
author
Michael Lehenbauer
committed
Merge branch 'master' into mikelehen/merge-master-to-firestore-api-changes
2 parents 2c6682c + c18af34 commit aa00c74

File tree

255 files changed

+9112
-3244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

255 files changed

+9112
-3244
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ DerivedData
3333
*.hmap
3434
*.ipa
3535

36+
# IntelliJ
37+
.idea
38+
3639
# Vim
3740
*.swo
3841
*.swp
@@ -57,4 +60,5 @@ Podfile.lock
5760

5861
# CMake
5962
.downloads
60-
.idea/
63+
Debug
64+
Release

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
osx_image: xcode9.1
1+
osx_image: xcode9.2
22
language: objective-c
33
cache:
44
- bundler
@@ -16,7 +16,9 @@ before_install:
1616
script:
1717
- "! git grep -I ' $'" # Fail on trailing whitespace in non-binary files
1818
- ./test.sh
19-
- bundle exec pod lib lint FirebaseCore.podspec
19+
20+
# TODO fix os_log deprecation warning in FIRLogger to remove --allow-warnings
21+
- bundle exec pod lib lint FirebaseCore.podspec --allow-warnings
2022

2123
# TODO - Uncomment subsequent lines once FirebaseCore source repo is in public Specs repo
2224
# - bundle exec pod lib lint FirebaseAuth.podspec

CMakeLists.txt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,27 @@
1717
cmake_minimum_required(VERSION 2.8.11)
1818
project(firebase C CXX)
1919

20+
# If no build type is specified, make it a debug build
21+
if(NOT CMAKE_BUILD_TYPE)
22+
set(CMAKE_BUILD_TYPE Debug)
23+
endif()
24+
25+
if(APPLE)
26+
# When building on the apple platform certain Objective-C++ classes bridge
27+
# back into other Firebase Cocoapods. This requires shelling out to xcodebuild
28+
# to verify the built frameworks are up-to-date. You can disable this to speed
29+
# up the build.
30+
option(BUILD_PODS, "Always build dependent cocoapods." ON)
31+
endif(APPLE)
32+
2033
list(INSERT CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake)
2134

22-
# External Projects install into this prefix and download into the source tree
23-
# to avoid re-downloading repeatedly during development.
24-
set(FIREBASE_INSTALL_DIR "${PROJECT_BINARY_DIR}/usr")
25-
set(FIREBASE_DOWNLOAD_DIR "${PROJECT_SOURCE_DIR}/.downloads")
35+
set(FIREBASE_INSTALL_DIR ${PROJECT_BINARY_DIR})
2636

2737
enable_testing()
2838

39+
include(external/FirebaseCore)
40+
2941
include(external/googletest)
30-
include(external/abseil-cpp)
42+
include(external/leveldb)
3143
include(external/firestore)

Example/Auth/ApiTests/AuthCredentialsTemplate.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ The name of the test user for Facebook Login.
5050
$KCUSTOM_AUTH_TOKEN_URL
5151
A URL to return a Custom Auth token.
5252
53+
$KCUSTOM_AUTH_TOKEN_EXPIRED_URL
54+
A URL to return an expired Custom Auth token.
55+
5356
$KCUSTOM_AUTH_USER_ID
5457
The ID of the test user in the Custom Auth token.
5558
*/
@@ -61,4 +64,5 @@ The ID of the test user in the Custom Auth token.
6164
#define KFACEBOOK_APP_ACCESS_TOKEN $KFACEBOOK_APP_ACCESS_TOKEN
6265
#define KFACEBOOK_USER_NAME $KFACEBOOK_USER_NAME
6366
#define KCUSTOM_AUTH_TOKEN_URL $KCUSTOM_AUTH_TOKEN_URL
67+
#define KCUSTOM_AUTH_TOKEN_EXPIRED_URL $KCUSTOM_AUTH_TOKEN_EXPIRED_URL
6468
#define KCUSTOM_AUTH_USER_ID $KCUSTOM_AUTH_USER_ID

Example/Auth/ApiTests/FirebaseAuthApiTests.m

Lines changed: 140 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
/** The url for obtaining a valid custom token string used to test Custom Auth. */
3737
static NSString *const kCustomTokenUrl = KCUSTOM_AUTH_TOKEN_URL;
3838

39+
/** The url for obtaining an expired but valid custom token string used to test Custom Auth failure.
40+
*/
41+
static NSString *const kExpiredCustomTokenUrl = KCUSTOM_AUTH_TOKEN_EXPIRED_URL;
42+
3943
/** Facebook app access token that will be used for Facebook Graph API, which is different from
4044
* account access token.
4145
*/
@@ -59,6 +63,12 @@
5963
/** The testing email address for testSignInExistingUserWithEmailAndPassword. */
6064
static NSString *const kExistingTestingEmailToSignIn = @"[email protected]";
6165

66+
/** The testing email address for testUpdatingUsersEmail. */
67+
static NSString *const kNewTestingEmail = @"[email protected]";
68+
69+
/** The testing password for testSignInExistingUserWithModifiedEmailAndPassword. */
70+
static NSString *const kNewTestingPasswordToSignIn = @"password_new";
71+
6272
/** Error message for invalid custom token sign in. */
6373
NSString *kInvalidTokenErrorMessage =
6474
@"The custom token format is incorrect. Please check the documentation.";
@@ -71,7 +81,7 @@
7181
*/
7282
NSString *kGoogleTestAccountRefreshToken = KGOOGLE_TEST_ACCOUNT_REFRESH_TOKEN;
7383

74-
static NSTimeInterval const kExpectationsTimeout = 30;
84+
static NSTimeInterval const kExpectationsTimeout = 10;
7585

7686
#ifdef NO_NETWORK
7787
#define SKIP_IF_ON_MOBILE_HARNESS \
@@ -141,6 +151,38 @@ - (void)testCreateAccountWithEmailAndPassword {
141151
[self deleteCurrentFirebaseUser];
142152
}
143153

154+
- (void)testUpdatingUsersEmail {
155+
SKIP_IF_ON_MOBILE_HARNESS
156+
FIRAuth *auth = [FIRAuth auth];
157+
if (!auth) {
158+
XCTFail(@"Could not obtain auth object.");
159+
}
160+
161+
__block NSError *apiError;
162+
XCTestExpectation *expectation =
163+
[self expectationWithDescription:@"Created account with email and password."];
164+
[auth createUserWithEmail:kTestingEmailToCreateUser
165+
password:@"password"
166+
completion:^(FIRUser *user, NSError *error) {
167+
apiError = error;
168+
[expectation fulfill];
169+
}];
170+
[self waitForExpectationsWithTimeout:kExpectationsTimeout handler:nil];
171+
expectation = [self expectationWithDescription:@"Created account with email and password."];
172+
XCTAssertEqualObjects(auth.currentUser.email, kTestingEmailToCreateUser);
173+
XCTAssertNil(apiError);
174+
[auth.currentUser updateEmail:kNewTestingEmail
175+
completion:^(NSError *_Nullable error) {
176+
apiError = error;
177+
[expectation fulfill];
178+
}];
179+
[self waitForExpectationsWithTimeout:kExpectationsTimeout handler:nil];
180+
XCTAssertNil(apiError);
181+
XCTAssertEqualObjects(auth.currentUser.email, kNewTestingEmail);
182+
// Clean up the created Firebase user for future runs.
183+
[self deleteCurrentFirebaseUser];
184+
}
185+
144186
- (void)testLinkAnonymousAccountToFacebookAccount {
145187
FIRAuth *auth = [FIRAuth auth];
146188
if (!auth) {
@@ -253,6 +295,92 @@ - (void)testSignInWithValidCustomAuthToken {
253295
XCTAssertEqualObjects(auth.currentUser.uid, kCustomAuthTestingAccountUserID);
254296
}
255297

298+
- (void)testSignInWithValidCustomAuthExpiredToken {
299+
FIRAuth *auth = [FIRAuth auth];
300+
if (!auth) {
301+
XCTFail(@"Could not obtain auth object.");
302+
}
303+
304+
NSError *error;
305+
NSString *customToken =
306+
[NSString stringWithContentsOfURL:[NSURL URLWithString:kExpiredCustomTokenUrl]
307+
encoding:NSUTF8StringEncoding
308+
error:&error];
309+
if (!customToken) {
310+
XCTFail(@"There was an error retrieving the custom token: %@", error);
311+
}
312+
XCTestExpectation *expectation =
313+
[self expectationWithDescription:@"CustomAuthToken sign-in finished."];
314+
315+
__block NSError *apiError;
316+
[auth signInWithCustomToken:customToken
317+
completion:^(FIRUser *_Nullable user, NSError *_Nullable error) {
318+
if (error) {
319+
apiError = error;
320+
}
321+
[expectation fulfill];
322+
}];
323+
[self waitForExpectationsWithTimeout:kExpectationsTimeout
324+
handler:^(NSError *error) {
325+
if (error != nil) {
326+
XCTFail(@"Failed to wait for expectations "
327+
@"in CustomAuthToken sign in. Error: %@",
328+
error.localizedDescription);
329+
}
330+
}];
331+
332+
XCTAssertNil(auth.currentUser);
333+
XCTAssertEqual(apiError.code, FIRAuthErrorCodeInvalidCustomToken);
334+
}
335+
336+
- (void)testInMemoryUserAfterSignOut {
337+
FIRAuth *auth = [FIRAuth auth];
338+
if (!auth) {
339+
XCTFail(@"Could not obtain auth object.");
340+
}
341+
NSError *error;
342+
NSString *customToken = [NSString stringWithContentsOfURL:[NSURL URLWithString:kCustomTokenUrl]
343+
encoding:NSUTF8StringEncoding
344+
error:&error];
345+
if (!customToken) {
346+
XCTFail(@"There was an error retrieving the custom token: %@", error);
347+
}
348+
XCTestExpectation *expectation =
349+
[self expectationWithDescription:@"CustomAuthToken sign-in finished."];
350+
__block NSError *rpcError;
351+
[auth signInWithCustomToken:customToken
352+
completion:^(FIRUser *_Nullable user, NSError *_Nullable error) {
353+
if (error) {
354+
rpcError = error;
355+
}
356+
[expectation fulfill];
357+
}];
358+
[self waitForExpectationsWithTimeout:kExpectationsTimeout
359+
handler:^(NSError *error) {
360+
if (error != nil) {
361+
XCTFail(@"Failed to wait for expectations "
362+
@"in CustomAuthToken sign in. Error: %@",
363+
error.localizedDescription);
364+
}
365+
}];
366+
XCTAssertEqualObjects(auth.currentUser.uid, kCustomAuthTestingAccountUserID);
367+
XCTAssertNil(rpcError);
368+
FIRUser *inMemoryUser = auth.currentUser;
369+
XCTestExpectation *expectation1 = [self expectationWithDescription:@"Profile data change."];
370+
[auth signOut:NULL];
371+
rpcError = nil;
372+
NSString *newEmailAddress = [self fakeRandomEmail];
373+
XCTAssertNotEqualObjects(newEmailAddress, inMemoryUser.email);
374+
[inMemoryUser updateEmail:newEmailAddress completion:^(NSError *_Nullable error) {
375+
rpcError = error;
376+
[expectation1 fulfill];
377+
}];
378+
[self waitForExpectationsWithTimeout:kExpectationsTimeout handler:nil];
379+
XCTAssertEqualObjects(inMemoryUser.email, newEmailAddress);
380+
XCTAssertNil(rpcError);
381+
XCTAssertNil(auth.currentUser);
382+
}
383+
256384
- (void)testSignInWithInvalidCustomAuthToken {
257385
FIRAuth *auth = [FIRAuth auth];
258386
if (!auth) {
@@ -354,6 +482,17 @@ - (void)testSignInWithGoogle {
354482

355483
#pragma mark - Helpers
356484

485+
/** Generate fake random email address */
486+
- (NSString *)fakeRandomEmail {
487+
NSMutableString *fakeEmail = [[NSMutableString alloc] init];
488+
for (int i=0; i<10; i++) {
489+
[fakeEmail appendString:
490+
[NSString stringWithFormat:@"%c", 'a' + arc4random_uniform('z' - 'a' + 1)]];
491+
}
492+
[fakeEmail appendString:@"@gmail.com"];
493+
return fakeEmail;
494+
}
495+
357496
/** Sign out current account. */
358497
- (void)signOut {
359498
NSError *signOutError;

Example/Auth/App/GoogleService-Info.plist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
<string>correct_client_id</string>
1111
<key>REVERSED_CLIENT_ID</key>
1212
<string>correct_reversed_client_id</string>
13-
<key>ANDROID_CLIENT_ID</key>
14-
<string>correct_android_client_id</string>
1513
<key>GOOGLE_APP_ID</key>
1614
<string>1:123:ios:123abc</string>
1715
<key>GCM_SENDER_ID</key>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2017 Google
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#import <UIKit/UIKit.h>
16+
17+
@interface AppDelegate : UIResponder <UIApplicationDelegate>
18+
19+
@property(strong, nonatomic) UIWindow *window;
20+
21+
@end
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright 2017 Google
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
@import FirebaseCore;
16+
@import FirebaseAuth;
17+
18+
#import "AppDelegate.h"
19+
20+
@interface AppDelegate ()
21+
22+
@end
23+
24+
@implementation AppDelegate
25+
26+
- (BOOL)application:(UIApplication *)application
27+
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
28+
// Override point for customization after application launch.
29+
[FIRApp configure];
30+
return YES;
31+
}
32+
33+
- (void)applicationWillResignActive:(UIApplication *)application {
34+
// Sent when the application is about to move from active to inactive state. This can occur for
35+
// certain types of temporary interruptions (such as an incoming phone call or SMS message) or
36+
// when the user quits the application and it begins the transition to the background state. Use
37+
// this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates.
38+
// Games should use this method to pause the game.
39+
}
40+
41+
- (void)applicationDidEnterBackground:(UIApplication *)application {
42+
// Use this method to release shared resources, save user data, invalidate timers, and store
43+
// enough application state information to restore your application to its current state in case
44+
// it is terminated later. If your application supports background execution, this method is
45+
// called instead of applicationWillTerminate: when the user quits.
46+
}
47+
48+
- (void)applicationWillEnterForeground:(UIApplication *)application {
49+
// Called as part of the transition from the background to the active state; here you can undo
50+
// many of the changes made on entering the background.
51+
}
52+
53+
- (void)applicationDidBecomeActive:(UIApplication *)application {
54+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If
55+
// the application was previously in the background, optionally refresh the user interface.
56+
}
57+
58+
- (void)applicationWillTerminate:(UIApplication *)application {
59+
// Called when the application is about to terminate. Save data if appropriate. See also
60+
// applicationDidEnterBackground:.
61+
}
62+
63+
@end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "tv"
5+
}
6+
],
7+
"info" : {
8+
"version" : 1,
9+
"author" : "xcode"
10+
}
11+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}

0 commit comments

Comments
 (0)