firebase / firebase/firebase-js-sdk
@firebase/rules-unit-testing logs rule fails as warnings
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
### [REQUIRED] Describe your environment
* Operating System version: Windows 10
* Firebase SDK version: 9.6.2
* rules-unit-test package version: 2.0.1
* Firebase Product: firestore
### [REQUIRED] Describe the problem
When using the rules-unit-testing package, a warning is logged whenever a rule fails even if `assertFails()` is present and suceeds.
Doesn't appear to cause any side-effects and can be disabled by calling `setLogLevel("silent")` during setup but I'm assuming this is a bug since all it appears to do is cause console noise during unit test runs.
#### Steps to reproduce:
* Setup a test environment.
* Create a basic test that calls `assertFails()` and suceeds.
* Run the test.
* A warning is logged to the console that firestore denied permission.
#### Relevant Code:
firestore.rules
```
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{uid} {
allow read, write: if false;
}
}
}
```
```javascript
it("test", async () => {
const testEnvironment = await initializeTestEnvironment({
projectId: "foo",
firestore: {
rules: fs.readFileSync("firestore.rules", "utf8"),
}
});
const randomUserDocument = testEnvironment.unauthenticatedContext().firestore().collection("users").doc("foo");
await assertFails(randomUserDocument.set({ foo: "bar" }));
});
```
Running this test succeeds but writes the following warning to console:
```
@firebase/firestore: Firestore (9.6.2): Connection GRPC stream error. Code: 7 Message: 7 PERMISSION_DENIED:
false for 'create' @ L100
at Logger.defaultLogHandler [as _logHandler] (node_modules/@firebase/logger/src/logger.ts:115:57)
at Logger.Object..Logger.warn (node_modules/@firebase/logger/src/logger.ts:206:21)
at logWarn (node_modules/@firebase/firestore/src/util/log.ts:69:15)
at ClientDuplexStreamImpl. (node_modules/@firebase/firestore/src/platform/node/grpc_connection.ts:252:9)
at Object.onReceiveStatus (node_modules/@firebase/firestore/node_modules/@grpc/grpc-js/src/client.ts:673:18)
at Object.onReceiveStatus (node_modules/@firebase/firestore/node_modules/@grpc/grpc-js/src/client-interceptors.ts:424:48)
```
Contributor guide
Assessment
This issue has not been assessed yet.