-
Notifications
You must be signed in to change notification settings - Fork 962
Closed
Labels
testing-sdktesting with emulatortesting with emulator
Description
[REQUIRED] Describe your environment
- Operating System version: macOS
- Browser version: none
- Firebase SDK version: @firebase/rules-unit-testing 1.0.0
- Firebase Product: firestore
[REQUIRED] Describe the problem
Steps to reproduce:
assertFails()
of @firebase/rules-unit-testing says Expected PERMISSION_DENIED but got unexpected error: FirebaseError: [code=permission-denied]: No matching allow statements
when assertFails(firestore().collection('tests').doc('a').get())
in the below rules. This throws below error.
{ FirebaseError: No matching allow statements
at new FirestoreError (/Users/moga/workspace/clones/UhooiPicBook-Firebase/node_modules/@firebase/firestore/src/util/error.ts:166:5)
at fromRpcStatus (/Users/moga/workspace/clones/UhooiPicBook-Firebase/node_modules/@firebase/firestore/src/remote/serializer.ts:134:10)
at fromWatchChange (/Users/moga/workspace/clones/UhooiPicBook-Firebase/node_modules/@firebase/firestore/src/remote/serializer.ts:490:33)
at PersistentListenStream.Object.<anonymous>.PersistentListenStream.onMessage (/Users/moga/workspace/clones/UhooiPicBook-Firebase/node_modules/@firebase/firestore/src/remote/persistent_stream.ts:576:25)
at /Users/moga/workspace/clones/UhooiPicBook-Firebase/node_modules/@firebase/firestore/src/remote/persistent_stream.ts:456:21
at /Users/moga/workspace/clones/UhooiPicBook-Firebase/node_modules/@firebase/firestore/src/remote/persistent_stream.ts:509:18
at /Users/moga/workspace/clones/UhooiPicBook-Firebase/node_modules/@firebase/firestore/src/util/async_queue.ts:367:14
at process._tickCallback (internal/process/next_tick.js:68:7)
code: 'permission-denied',
name: 'FirebaseError',
toString: [Function] }
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /tests/{monsterId} {
allow list: if true;
}
}
}
So I fix this problem at this commit. If this would be ok, I'm willing to create pr!
Relevant Code:
import * as firebase from '@firebase/rules-unit-testing'
const firestore = firebase.initializeTestApp({ projectId: 'sample', databaseName: 'db' }).firestore()
describe('test', () => {
it('this shoud be passed but fails', async () => {
await firebase.assertFails(firestore().collection('tests').doc('a').get())
})
})
uhooi, yorifuji, mogaming217 and yuchenshiyuchenshi
Metadata
Metadata
Labels
testing-sdktesting with emulatortesting with emulator