Skip to content

refactor: Migrate Firebase Storage to nnbd #4753

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 29 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
41ede7c
add linting rules
Ehesp Jan 18, 2021
400ab59
update pubspec to null safe versions
Ehesp Jan 18, 2021
bffd376
fix linter warnings
Ehesp Jan 18, 2021
29be8a7
apply platform null safey migration
Ehesp Jan 18, 2021
328e619
refactor: fix linting issues
Salakar Jan 21, 2021
62cfc6f
Merge branch 'master' of https://github.com/FirebaseExtended/flutterf…
Salakar Jan 21, 2021
f47df2b
refactor: fix formatting
Salakar Jan 21, 2021
4f6767c
refactor: bump firebase_core version on PI deps
Salakar Jan 21, 2021
1deee8d
Merge branch 'master' into @ehesp/storage-nndb
russellwheatley Feb 3, 2021
1de6785
refactor(storage_web): migrate storage_web package NNBD
russellwheatley Feb 4, 2021
8050fc6
refactor(storage): NNBD rework for main package
russellwheatley Feb 4, 2021
a432bb9
chore(storage): null safe packages
russellwheatley Feb 4, 2021
16c385f
chore(storage):upgrade packages
russellwheatley Feb 5, 2021
efeb476
tests(storage): mock tests passing for storage main pkg
russellwheatley Feb 5, 2021
9789eba
tests(storage): platform interface test fixes
russellwheatley Feb 8, 2021
580d1f4
format: run formatter
russellwheatley Feb 8, 2021
599accf
tests(storage): fix e2e tests
russellwheatley Feb 8, 2021
9ff3250
chore(storage): analyze errors
russellwheatley Feb 8, 2021
44c0110
tests(storage_web): comment out broken tests for NNBD
russellwheatley Feb 10, 2021
c7fceb2
format: run formatter
russellwheatley Feb 10, 2021
826c632
chore(storage): NNBD PR review updates
russellwheatley Feb 10, 2021
b4eef7f
tests(storage): revert back to late for tests
russellwheatley Feb 10, 2021
109efaa
test(storage): make param dynamic to stop analysis err
russellwheatley Feb 10, 2021
dcc0d57
format: run formatter
russellwheatley Feb 10, 2021
ccf9329
chore(storage): rm analyze warning
russellwheatley Feb 10, 2021
5f8fdda
Restore packages/cloud_firestore/cloud_firestore/example/ios/Flutter/…
Salakar Feb 11, 2021
f1c4073
remove pedantic dependency
russellwheatley Feb 11, 2021
cf8325c
chore(storage): add anlysis options to example
russellwheatley Feb 11, 2021
0486583
chore: mockito dependency updates, dependency changes & analysis warn…
russellwheatley Feb 15, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ import 'package:cloud_firestore_platform_interface/src/method_channel/method_cha

import '../utils/test_common.dart';

const String mockId = 'mock-id';
const String mockPath = 'foo/bar';

//ignore: avoid_implementing_value_types
class MockDocumentReference extends Mock implements DocumentReferencePlatform {
@override
String get path => super.noSuchMethod(Invocation.getter(#path), 'foo/bar');
String get path => super.noSuchMethod(Invocation.getter(#path),
returnValue: mockPath, returnValueForMissingStub: mockPath);
@override
String get id => super.noSuchMethod(Invocation.getter(#id), 'mock-id');
String get id => super.noSuchMethod(Invocation.getter(#id),
returnValue: mockId, returnValueForMissingStub: mockId);
}

const _kTransactionId = '1022';
Expand Down
1 change: 0 additions & 1 deletion packages/firebase_auth/firebase_auth/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies:
sdk: flutter
flutter_signin_button: ^1.0.0
google_sign_in: ^5.0.0-nullsafety
uuid: ^2.0.2

dependency_overrides:
firebase_auth:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @dart = 2.9

import 'dart:convert';
import 'dart:math';

import 'package:http/http.dart' as http;
import 'package:uuid/uuid.dart';
import 'package:firebase_auth/firebase_auth.dart';

FirebaseAuth auth = FirebaseAuth.instance;
Expand All @@ -19,7 +19,7 @@ String /*!*/ generateRandomEmail({
String prefix = '',
String suffix = '@foo.bar',
}) {
var uuid = Uuid().v1();
var uuid = createCryptoRandomString();
var testEmail = prefix + uuid + suffix;

return testEmail;
Expand Down Expand Up @@ -78,3 +78,11 @@ Future<void> ensureSignedOut() async {
await auth.signOut();
}
}

Random _random = Random.secure();

String createCryptoRandomString([int length = 32]) {
var values = List<int>.generate(length, (i) => _random.nextInt(256));

return base64Url.encode(values).toLowerCase();
}
88 changes: 59 additions & 29 deletions packages/firebase_auth/firebase_auth/test/firebase_auth_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -651,31 +651,35 @@ class MockFirebaseAuth extends Mock
Stream<UserPlatform?> userChanges() {
return super.noSuchMethod(
Invocation.method(#userChanges, []),
const Stream<UserPlatform?>.empty(),
returnValue: const Stream<UserPlatform?>.empty(),
returnValueForMissingStub: const Stream<UserPlatform?>.empty(),
);
}

@override
Stream<UserPlatform?> idTokenChanges() {
return super.noSuchMethod(
Invocation.method(#idTokenChanges, []),
const Stream<UserPlatform?>.empty(),
returnValue: const Stream<UserPlatform?>.empty(),
returnValueForMissingStub: const Stream<UserPlatform?>.empty(),
);
}

@override
Stream<UserPlatform?> authStateChanges() {
return super.noSuchMethod(
Invocation.method(#authStateChanges, []),
const Stream<UserPlatform?>.empty(),
returnValue: const Stream<UserPlatform?>.empty(),
returnValueForMissingStub: const Stream<UserPlatform?>.empty(),
);
}

@override
FirebaseAuthPlatform delegateFor({FirebaseApp? app}) {
return super.noSuchMethod(
Invocation.method(#delegateFor, [], {#app: app}),
TestFirebaseAuthPlatform(),
returnValue: TestFirebaseAuthPlatform(),
returnValueForMissingStub: TestFirebaseAuthPlatform(),
);
}

Expand All @@ -686,7 +690,8 @@ class MockFirebaseAuth extends Mock
) {
return super.noSuchMethod(
Invocation.method(#createUserWithEmailAndPassword, [email, password]),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

Expand All @@ -700,7 +705,9 @@ class MockFirebaseAuth extends Mock
#signInWithPhoneNumber,
[phoneNumber, applicationVerifier],
),
neverEndingFuture<ConfirmationResultPlatform>(),
returnValue: neverEndingFuture<ConfirmationResultPlatform>(),
returnValueForMissingStub:
neverEndingFuture<ConfirmationResultPlatform>(),
);
}

Expand All @@ -710,15 +717,17 @@ class MockFirebaseAuth extends Mock
) {
return super.noSuchMethod(
Invocation.method(#signInWithCredential, [credential]),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

@override
Future<UserCredentialPlatform> signInWithCustomToken(String? token) {
return super.noSuchMethod(
Invocation.method(#signInWithCustomToken, [token]),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

Expand All @@ -729,15 +738,17 @@ class MockFirebaseAuth extends Mock
) {
return super.noSuchMethod(
Invocation.method(#signInWithEmailAndPassword, [email, password]),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

@override
Future<UserCredentialPlatform> signInWithPopup(AuthProvider? provider) {
return super.noSuchMethod(
Invocation.method(#signInWithPopup, [provider]),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

Expand All @@ -748,23 +759,26 @@ class MockFirebaseAuth extends Mock
) {
return super.noSuchMethod(
Invocation.method(#signInWithEmailLink, [email, emailLink]),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

@override
Future<void> signInWithRedirect(AuthProvider? provider) {
return super.noSuchMethod(
Invocation.method(#signInWithRedirect, [provider]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

@override
Future<UserCredentialPlatform> signInAnonymously() {
return super.noSuchMethod(
Invocation.method(#signInAnonymously, []),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

Expand All @@ -778,63 +792,71 @@ class MockFirebaseAuth extends Mock
#currentUser: currentUser,
#languageCode: languageCode,
}),
TestFirebaseAuthPlatform(),
returnValue: TestFirebaseAuthPlatform(),
returnValueForMissingStub: TestFirebaseAuthPlatform(),
);
}

@override
Future<UserCredentialPlatform> getRedirectResult() {
return super.noSuchMethod(
Invocation.method(#getRedirectResult, []),
neverEndingFuture<UserCredentialPlatform>(),
returnValue: neverEndingFuture<UserCredentialPlatform>(),
returnValueForMissingStub: neverEndingFuture<UserCredentialPlatform>(),
);
}

@override
Future<void> setLanguageCode(String? languageCode) {
return super.noSuchMethod(
Invocation.method(#setLanguageCode, [languageCode]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

@override
Future<void> useEmulator(String host, int port) {
return super.noSuchMethod(
Invocation.method(#useEmulator, [host, port]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

@override
Future<ActionCodeInfo> checkActionCode(String? code) {
return super.noSuchMethod(
Invocation.method(#checkActionCode, [code]),
neverEndingFuture<ActionCodeInfo>(),
returnValue: neverEndingFuture<ActionCodeInfo>(),
returnValueForMissingStub: neverEndingFuture<ActionCodeInfo>(),
);
}

@override
Future<void> confirmPasswordReset(String? code, String? newPassword) {
return super.noSuchMethod(
Invocation.method(#confirmPasswordReset, [code, newPassword]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

@override
Future<List<String>> fetchSignInMethodsForEmail(String? email) {
return super.noSuchMethod(
Invocation.method(#checkActionCode, [email]),
neverEndingFuture<List<String>>(),
returnValue: neverEndingFuture<List<String>>(),
returnValueForMissingStub: neverEndingFuture<List<String>>(),
);
}

@override
bool isSignInWithEmailLink(String? emailLink) {
return super.noSuchMethod(
Invocation.method(#isSignInWithEmailLink, [emailLink]),
false,
returnValue: false,
returnValueForMissingStub: false,
);
}

Expand All @@ -845,7 +867,8 @@ class MockFirebaseAuth extends Mock
]) {
return super.noSuchMethod(
Invocation.method(#sendPasswordResetEmail, [email, actionCodeSettings]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

Expand All @@ -856,7 +879,8 @@ class MockFirebaseAuth extends Mock
) {
return super.noSuchMethod(
Invocation.method(#sendSignInLinkToEmail, [email, actionCodeSettings]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

Expand All @@ -870,31 +894,35 @@ class MockFirebaseAuth extends Mock
appVerificationDisabledForTesting,
userAccessGroup,
]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

@override
Future<void> setPersistence(Persistence? persistence) {
return super.noSuchMethod(
Invocation.method(#setPersistence, [persistence]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

@override
Future<void> signOut() {
return super.noSuchMethod(
Invocation.method(#signOut, [signOut]),
neverEndingFuture<void>(),
returnValue: neverEndingFuture<void>(),
returnValueForMissingStub: neverEndingFuture<void>(),
);
}

@override
Future<String> verifyPasswordResetCode(String? code) {
return super.noSuchMethod(
Invocation.method(#verifyPasswordResetCode, [code]),
neverEndingFuture<String>(),
returnValue: neverEndingFuture<String>(),
returnValueForMissingStub: neverEndingFuture<String>(),
);
}

Expand All @@ -920,7 +948,8 @@ class MockFirebaseAuth extends Mock
#forceResendingToken: forceResendingToken,
#autoRetrievedSmsCodeForTesting: autoRetrievedSmsCodeForTesting,
}),
neverEndingFuture<String>(),
returnValue: neverEndingFuture<String>(),
returnValueForMissingStub: neverEndingFuture<String>(),
);
}
}
Expand Down Expand Up @@ -1000,7 +1029,8 @@ class MockRecaptchaVerifier extends Mock
RecaptchaVerifierFactoryPlatform get delegate {
return super.noSuchMethod(
Invocation.getter(#delegate),
MockRecaptchaVerifierFactoryPlatform(),
returnValue: MockRecaptchaVerifierFactoryPlatform(),
returnValueForMissingStub: MockRecaptchaVerifierFactoryPlatform(),
);
}
}
Expand Down
Loading