Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a47784c
lazy replacing FST(Firebase)CredentialsProvider by (Firebase)Credenti…
zxu123 Feb 9, 2018
194f4e1
lazy replacing FSTUser by User
zxu123 Feb 9, 2018
fc1bb48
adding error-code parameter to TokenListener
zxu123 Feb 13, 2018
20b36c1
actually use const user& instead of pointer; also add an error util
zxu123 Feb 13, 2018
5b6cadf
add HashUser and pass into the unordered_map
zxu123 Feb 13, 2018
920a679
use User in test
zxu123 Feb 13, 2018
443d483
use c++ CredentialsProvider and subclass in test
zxu123 Feb 14, 2018
7622e8a
fix unit test
zxu123 Feb 14, 2018
c7311e4
use explicit capture in lambda instead of capture all by reference
zxu123 Feb 14, 2018
636fd60
cache currentUser explicitly when reset sync engineer test driver
zxu123 Feb 14, 2018
f687518
objc object should be captured by value in lambda
zxu123 Feb 14, 2018
dc4f02c
replacing Auth/FSTUser by C++ auth implementation
zxu123 Feb 15, 2018
b502b8e
address changes
zxu123 Feb 15, 2018
bfbb0e2
replacing FSTGetTokenResult by C++ Token implementation
zxu123 Feb 15, 2018
a64ca8c
Merge branch 'master' into cpp/port_token
zxu123 Feb 15, 2018
9fb7911
address changes
zxu123 Feb 16, 2018
4b4992a
Merge branch 'cpp/port_token' into cpp/port_auth
zxu123 Feb 16, 2018
26aede3
Merge branch 'master' into cpp/port_auth
zxu123 Feb 16, 2018
78388d8
fix unintentional change in merging
zxu123 Feb 16, 2018
1b7ca90
Merge branch 'cpp/port_auth' of https://github.com/firebase/firebase-…
zxu123 Feb 16, 2018
2bd877d
patch the change in objc Auth up-stream
zxu123 Feb 16, 2018
934cef5
somehow, the lambda-version of set-user-change-listener does not work…
zxu123 Feb 16, 2018
369f812
address changes
zxu123 Feb 16, 2018
6e4fdef
fix another const& v.s. dispatch bug
zxu123 Feb 16, 2018
5cb11ca
fix more const& v.s. dispatch bug zxu123 committed
zxu123 Feb 16, 2018
6874ddd
Merge branch 'cpp/port_token' into cpp/port_auth
zxu123 Feb 16, 2018
4bf88a1
Merge branch 'master' into cpp/port_auth
zxu123 Feb 20, 2018
64a2306
fix a bad sync line
zxu123 Feb 20, 2018
ded4a11
address changes
zxu123 Feb 22, 2018
4bc9ba5
address change
zxu123 Feb 22, 2018
8009791
address change
zxu123 Feb 22, 2018
29e44f5
Merge branch 'master' into cpp/port_auth
zxu123 Feb 22, 2018
3956b10
fix upstream change from merge
zxu123 Feb 22, 2018
c4a8336
fix upstream changes
zxu123 Feb 22, 2018
8df9ab4
Suggested fixes for cpp/port_auth (#846)
wilhuff Feb 23, 2018
91c5f8e
fix style
zxu123 Feb 26, 2018
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
9 changes: 4 additions & 5 deletions Firestore/Example/Tests/Integration/FSTDatastoreTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#import "Firestore/Source/API/FIRDocumentReference+Internal.h"
#import "Firestore/Source/API/FSTUserDataConverter.h"
#import "Firestore/Source/Auth/FSTEmptyCredentialsProvider.h"
#import "Firestore/Source/Core/FSTFirestoreClient.h"
#import "Firestore/Source/Core/FSTQuery.h"
#import "Firestore/Source/Core/FSTSnapshotVersion.h"
Expand All @@ -41,11 +40,13 @@

#import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h"

#include "Firestore/core/src/firebase/firestore/auth/empty_credentials_provider.h"
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"

namespace util = firebase::firestore::util;
using firebase::firestore::auth::EmptyCredentialsProvider;
using firebase::firestore::core::DatabaseInfo;
using firebase::firestore::model::DatabaseId;

Expand Down Expand Up @@ -141,7 +142,7 @@ @interface FSTDatastoreTests : XCTestCase
@implementation FSTDatastoreTests {
FSTDispatchQueue *_testWorkerQueue;
FSTLocalStore *_localStore;
id<FSTCredentialsProvider> _credentials;
EmptyCredentialsProvider _credentials;

DatabaseInfo _databaseInfo;
FSTDatastore *_datastore;
Expand Down Expand Up @@ -170,11 +171,9 @@ - (void)setUp {
queueWith:dispatch_queue_create("com.google.firestore.FSTDatastoreTestsWorkerQueue",
DISPATCH_QUEUE_SERIAL)];

_credentials = [[FSTEmptyCredentialsProvider alloc] init];

_datastore = [FSTDatastore datastoreWithDatabase:&_databaseInfo
workerDispatchQueue:_testWorkerQueue
credentials:_credentials];
credentials:&_credentials];

_remoteStore = [FSTRemoteStore remoteStoreWithLocalStore:_localStore datastore:_datastore];

Expand Down
10 changes: 5 additions & 5 deletions Firestore/Example/Tests/Integration/FSTStreamTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@

#import "Firestore/Example/Tests/Util/FSTHelpers.h"
#import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h"
#import "Firestore/Source/Auth/FSTEmptyCredentialsProvider.h"
#import "Firestore/Source/Remote/FSTDatastore.h"
#import "Firestore/Source/Remote/FSTStream.h"
#import "Firestore/Source/Util/FSTAssert.h"

#include "Firestore/core/src/firebase/firestore/auth/empty_credentials_provider.h"
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"

namespace util = firebase::firestore::util;
using firebase::firestore::auth::EmptyCredentialsProvider;
using firebase::firestore::core::DatabaseInfo;
using firebase::firestore::model::DatabaseId;

Expand Down Expand Up @@ -136,7 +137,7 @@ @implementation FSTStreamTests {
dispatch_queue_t _testQueue;
FSTDispatchQueue *_workerDispatchQueue;
DatabaseInfo _databaseInfo;
FSTEmptyCredentialsProvider *_credentials;
EmptyCredentialsProvider _credentials;
FSTStreamStatusDelegate *_delegate;

/** Single mutation to send to the write stream. */
Expand All @@ -155,7 +156,6 @@ DatabaseId database_id(util::MakeStringView([FSTIntegrationTestCase projectID]),

_databaseInfo = DatabaseInfo(database_id, "test-key", util::MakeStringView(settings.host),
settings.sslEnabled);
_credentials = [[FSTEmptyCredentialsProvider alloc] init];

_delegate = [[FSTStreamStatusDelegate alloc] initWithTestCase:self queue:_workerDispatchQueue];

Expand All @@ -165,14 +165,14 @@ DatabaseId database_id(util::MakeStringView([FSTIntegrationTestCase projectID]),
- (FSTWriteStream *)setUpWriteStream {
FSTDatastore *datastore = [[FSTDatastore alloc] initWithDatabaseInfo:&_databaseInfo
workerDispatchQueue:_workerDispatchQueue
credentials:_credentials];
credentials:&_credentials];
return [datastore createWriteStream];
}

- (FSTWatchStream *)setUpWatchStream {
FSTDatastore *datastore = [[FSTDatastore alloc] initWithDatabaseInfo:&_databaseInfo
workerDispatchQueue:_workerDispatchQueue
credentials:_credentials];
credentials:&_credentials];
return [datastore createWatchStream];
}

Expand Down
2 changes: 0 additions & 2 deletions Firestore/Example/Tests/SpecTests/FSTMockDatastore.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property(nonatomic) int writeStreamRequestCount;

+ (instancetype)mockDatastoreWithWorkerDispatchQueue:(FSTDispatchQueue *)workerDispatchQueue;

#pragma mark - Watch Stream manipulation.

/** Injects an Added WatchChange containing the given targetIDs. */
Expand Down
35 changes: 13 additions & 22 deletions Firestore/Example/Tests/SpecTests/FSTMockDatastore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#import "Firestore/Example/Tests/SpecTests/FSTMockDatastore.h"

#import "Firestore/Source/Auth/FSTEmptyCredentialsProvider.h"
#import "Firestore/Source/Core/FSTSnapshotVersion.h"
#import "Firestore/Source/Local/FSTQueryData.h"
#import "Firestore/Source/Model/FSTMutation.h"
Expand All @@ -27,10 +26,14 @@

#import "Firestore/Example/Tests/Remote/FSTWatchChange+Testing.h"

#include "Firestore/core/src/firebase/firestore/auth/credentials_provider.h"
#include "Firestore/core/src/firebase/firestore/auth/empty_credentials_provider.h"
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"

using firebase::firestore::auth::CredentialsProvider;
using firebase::firestore::auth::EmptyCredentialsProvider;
using firebase::firestore::core::DatabaseInfo;
using firebase::firestore::model::DatabaseId;

Expand All @@ -44,17 +47,17 @@ @interface FSTMockWatchStream : FSTWatchStream

- (instancetype)initWithDatastore:(FSTMockDatastore *)datastore
workerDispatchQueue:(FSTDispatchQueue *)workerDispatchQueue
credentials:(id<FSTCredentialsProvider>)credentials
credentials:(CredentialsProvider *)credentials
serializer:(FSTSerializerBeta *)serializer NS_DESIGNATED_INITIALIZER;

- (instancetype)initWithDatabase:(const DatabaseInfo *)database
workerDispatchQueue:(FSTDispatchQueue *)workerDispatchQueue
credentials:(id<FSTCredentialsProvider>)credentials
credentials:(CredentialsProvider *)credentials
serializer:(FSTSerializerBeta *)serializer NS_UNAVAILABLE;

- (instancetype)initWithDatabase:(const DatabaseInfo *)database
workerDispatchQueue:(FSTDispatchQueue *)workerDispatchQueue
credentials:(id<FSTCredentialsProvider>)credentials
credentials:(CredentialsProvider *)credentials
responseMessageClass:(Class)responseMessageClass NS_UNAVAILABLE;

@property(nonatomic, assign) BOOL open;
Expand All @@ -69,7 +72,7 @@ @implementation FSTMockWatchStream

- (instancetype)initWithDatastore:(FSTMockDatastore *)datastore
workerDispatchQueue:(FSTDispatchQueue *)workerDispatchQueue
credentials:(id<FSTCredentialsProvider>)credentials
credentials:(CredentialsProvider *)credentials
serializer:(FSTSerializerBeta *)serializer {
self = [super initWithDatabase:datastore.databaseInfo
workerDispatchQueue:workerDispatchQueue
Expand Down Expand Up @@ -170,17 +173,17 @@ @interface FSTMockWriteStream : FSTWriteStream

- (instancetype)initWithDatastore:(FSTMockDatastore *)datastore
workerDispatchQueue:(FSTDispatchQueue *)workerDispatchQueue
credentials:(id<FSTCredentialsProvider>)credentials
credentials:(CredentialsProvider *)credentials
serializer:(FSTSerializerBeta *)serializer NS_DESIGNATED_INITIALIZER;

- (instancetype)initWithDatabase:(const DatabaseInfo *)database
workerDispatchQueue:(FSTDispatchQueue *)workerDispatchQueue
credentials:(id<FSTCredentialsProvider>)credentials
credentials:(CredentialsProvider *)credentials
serializer:(FSTSerializerBeta *)serializer NS_UNAVAILABLE;

- (instancetype)initWithDatabase:(const DatabaseInfo *)database
workerDispatchQueue:(FSTDispatchQueue *)workerDispatchQueue
credentials:(id<FSTCredentialsProvider>)credentials
credentials:(CredentialsProvider *)credentials
responseMessageClass:(Class)responseMessageClass NS_UNAVAILABLE;

@property(nonatomic, strong, readonly) FSTMockDatastore *datastore;
Expand All @@ -193,7 +196,7 @@ @implementation FSTMockWriteStream

- (instancetype)initWithDatastore:(FSTMockDatastore *)datastore
workerDispatchQueue:(FSTDispatchQueue *)workerDispatchQueue
credentials:(id<FSTCredentialsProvider>)credentials
credentials:(CredentialsProvider *)credentials
serializer:(FSTSerializerBeta *)serializer {
self = [super initWithDatabase:datastore.databaseInfo
workerDispatchQueue:workerDispatchQueue
Expand Down Expand Up @@ -279,24 +282,12 @@ @interface FSTMockDatastore ()

/** Properties implemented in FSTDatastore that are nonpublic. */
@property(nonatomic, strong, readonly) FSTDispatchQueue *workerDispatchQueue;
@property(nonatomic, strong, readonly) id<FSTCredentialsProvider> credentials;
@property(nonatomic, assign, readonly) CredentialsProvider *credentials;

@end

@implementation FSTMockDatastore

+ (instancetype)mockDatastoreWithWorkerDispatchQueue:(FSTDispatchQueue *)workerDispatchQueue {
// This owns the DatabaseInfos since we do not have FirestoreClient instance to own them.
static DatabaseInfo database_info{DatabaseId{"project", "database"}, "persistence", "host",
false};

FSTEmptyCredentialsProvider *credentials = [[FSTEmptyCredentialsProvider alloc] init];

return [[FSTMockDatastore alloc] initWithDatabaseInfo:&database_info
workerDispatchQueue:workerDispatchQueue
credentials:credentials];
}

#pragma mark - Overridden FSTDatastore methods.

- (FSTWatchStream *)createWatchStream {
Expand Down
14 changes: 13 additions & 1 deletion Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@
#import "Firestore/Example/Tests/Core/FSTSyncEngine+Testing.h"
#import "Firestore/Example/Tests/SpecTests/FSTMockDatastore.h"

#include "Firestore/core/src/firebase/firestore/auth/empty_credentials_provider.h"
#include "Firestore/core/src/firebase/firestore/auth/user.h"
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"

using firebase::firestore::auth::EmptyCredentialsProvider;
using firebase::firestore::auth::HashUser;
using firebase::firestore::auth::User;
using firebase::firestore::core::DatabaseInfo;
using firebase::firestore::model::DatabaseId;

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -83,7 +89,9 @@ @implementation FSTSyncEngineTestDriver {
// ivar is declared as mutable.
std::unordered_map<User, NSMutableArray<FSTOutstandingWrite *> *, HashUser> _outstandingWrites;

DatabaseInfo _databaseInfo;
User _currentUser;
EmptyCredentialsProvider _credentialProvider;
}

- (instancetype)initWithPersistence:(id<FSTPersistence>)persistence
Expand All @@ -106,13 +114,17 @@ - (instancetype)initWithPersistence:(id<FSTPersistence>)persistence

_events = [NSMutableArray array];

_databaseInfo = {DatabaseId{"project", "database"}, "persistence", "host", false};

// Set up the sync engine and various stores.
dispatch_queue_t mainQueue = dispatch_get_main_queue();
FSTDispatchQueue *dispatchQueue = [FSTDispatchQueue queueWith:mainQueue];
_localStore = [[FSTLocalStore alloc] initWithPersistence:persistence
garbageCollector:garbageCollector
initialUser:initialUser];
_datastore = [FSTMockDatastore mockDatastoreWithWorkerDispatchQueue:dispatchQueue];
_datastore = [[FSTMockDatastore alloc] initWithDatabaseInfo:&_databaseInfo
workerDispatchQueue:dispatchQueue
credentials:&_credentialProvider];

_remoteStore = [FSTRemoteStore remoteStoreWithLocalStore:_localStore datastore:_datastore];

Expand Down
20 changes: 13 additions & 7 deletions Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,30 @@

#import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h"

#include <memory>
#include <utility>

#import <FirebaseCore/FIRLogger.h>
#import <FirebaseFirestore/FirebaseFirestore-umbrella.h>
#import <GRPCClient/GRPCCall+ChannelArg.h>
#import <GRPCClient/GRPCCall+Tests.h>

#include "Firestore/core/src/firebase/firestore/auth/empty_credentials_provider.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/util/autoid.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
#include "absl/memory/memory.h"

#import "Firestore/Source/API/FIRFirestore+Internal.h"
#import "Firestore/Source/Auth/FSTEmptyCredentialsProvider.h"
#import "Firestore/Source/Core/FSTFirestoreClient.h"
#import "Firestore/Source/Local/FSTLevelDB.h"
#import "Firestore/Source/Util/FSTDispatchQueue.h"

#import "Firestore/Example/Tests/Util/FSTEventAccumulator.h"

#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"

namespace util = firebase::firestore::util;
using firebase::firestore::auth::CredentialsProvider;
using firebase::firestore::auth::EmptyCredentialsProvider;
using firebase::firestore::model::DatabaseId;
using firebase::firestore::util::CreateAutoId;

Expand Down Expand Up @@ -135,15 +140,16 @@ - (FIRFirestore *)firestoreWithProjectID:(NSString *)projectID {
FSTDispatchQueue *workerDispatchQueue = [FSTDispatchQueue
queueWith:dispatch_queue_create("com.google.firebase.firestore", DISPATCH_QUEUE_SERIAL)];

FSTEmptyCredentialsProvider *credentialsProvider = [[FSTEmptyCredentialsProvider alloc] init];

FIRSetLoggerLevel(FIRLoggerLevelDebug);
// HACK: FIRFirestore expects a non-nil app, but for tests we cheat.
FIRApp *app = nil;
std::unique_ptr<CredentialsProvider> credentials_provider =
absl::make_unique<firebase::firestore::auth::EmptyCredentialsProvider>();

FIRFirestore *firestore = [[FIRFirestore alloc] initWithProjectID:util::MakeStringView(projectID)
database:DatabaseId::kDefault
persistenceKey:persistenceKey
credentialsProvider:credentialsProvider
credentialsProvider:std::move(credentials_provider)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::move is defined in <utility> (IWYU). Unfortunately, the C++ linter doesn't work for Objective-C++ :-(.

workerDispatchQueue:workerDispatchQueue
firebaseApp:app];

Expand Down
7 changes: 5 additions & 2 deletions Firestore/Source/API/FIRFirestore+Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

#import "FIRFirestore.h"

#include <memory>

#include "Firestore/core/src/firebase/firestore/auth/credentials_provider.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "absl/strings/string_view.h"

Expand All @@ -24,7 +27,6 @@ NS_ASSUME_NONNULL_BEGIN
@class FSTDispatchQueue;
@class FSTFirestoreClient;
@class FSTUserDataConverter;
@protocol FSTCredentialsProvider;

@interface FIRFirestore (/* Init */)

Expand All @@ -35,7 +37,8 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithProjectID:(const absl::string_view)projectID
database:(const absl::string_view)database
persistenceKey:(NSString *)persistenceKey
credentialsProvider:(id<FSTCredentialsProvider>)credentialsProvider
credentialsProvider:(std::unique_ptr<firebase::firestore::auth::CredentialsProvider>)
credentialsProvider
workerDispatchQueue:(FSTDispatchQueue *)workerDispatchQueue
firebaseApp:(FIRApp *)app;

Expand Down
Loading