@@ -33,19 +33,21 @@ void runSecondDatabaseTests() {
3333 'Second Database' ,
3434 () {
3535 late FirebaseFirestore firestore;
36+ String collectionForSecondDatabase = 'flutterfire-2' ;
3637
3738 setUpAll (() async {
3839 firestore = FirebaseFirestore .instanceFor (
3940 app: Firebase .app (),
4041 databaseId: 'flutterfire-2' ,
4142 );
43+
44+ firestore.useFirestoreEmulator ('localhost' , 8080 );
4245 });
4346
4447 Future <CollectionReference <Map <String , dynamic >>> initializeTest (
4548 String id,
4649 ) async {
4750 // Pushed rules which only allow database "flutterfire-2" to have "flutterfire-2" collection writes
48- String collectionForSecondDatabase = 'flutterfire-2' ;
4951
5052 CollectionReference <Map <String , dynamic >> collection =
5153 firestore.collection (
@@ -61,6 +63,23 @@ void runSecondDatabaseTests() {
6163 return collection;
6264 }
6365
66+ group (
67+ 'queries for default database are banned for this collection: "$collectionForSecondDatabase "' ,
68+ () {
69+ testWidgets ('barred query' , (_) async {
70+ final defaultFirestore = FirebaseFirestore .instance;
71+ try {
72+ await defaultFirestore
73+ .collection (collectionForSecondDatabase)
74+ .add ({'foo' : 'bar' });
75+ fail ('Should have thrown a [FirebaseException]' );
76+ } catch (e) {
77+ expect (e, isA <FirebaseException >());
78+ expect ((e as FirebaseException ).code, equals ('permission-denied' ));
79+ }
80+ });
81+ });
82+
6483 group ('equality' , () {
6584 // testing == override using e2e tests as it is dependent on the platform
6685 testWidgets ('handles deeply compares query parameters' , (_) async {
@@ -190,6 +209,8 @@ void runSecondDatabaseTests() {
190209 }
191210 fail ('Should have thrown a [FirebaseException]' );
192211 },
212+ // Emulator for 2nd database allows this request, the live project correctly throws a "permission-denied" error
213+ skip: true ,
193214 );
194215 });
195216
@@ -335,6 +356,8 @@ void runSecondDatabaseTests() {
335356
336357 fail ('Should have thrown a [FirebaseException]' );
337358 },
359+ // Emulator for 2nd database allows this request, the live project correctly throws a "permission-denied" error
360+ skip: true ,
338361 );
339362 });
340363
@@ -1810,6 +1833,8 @@ void runSecondDatabaseTests() {
18101833 expect (result.docs.length, equals (1 ));
18111834 expect (result.docs[0 ].data ()['genre' ], equals ('sci-fi' ));
18121835 },
1836+ // Emulator for 2nd database allows this request, the live project correctly throws a "permission-denied" error
1837+ skip: true ,
18131838 );
18141839
18151840 testWidgets (
@@ -1849,6 +1874,8 @@ void runSecondDatabaseTests() {
18491874 expect (results.docs[0 ].id, equals ('doc2' ));
18501875 expect (results.docs[1 ].id, equals ('doc1' ));
18511876 },
1877+ // Emulator for 2nd database allows this request, the live project correctly throws a "permission-denied" error
1878+ skip: true ,
18521879 );
18531880
18541881 testWidgets ('isEqualTo filter' , (_) async {
0 commit comments