Skip to content

Commit

Permalink
Upgrade Storage rules runtime to v1.1.3 (ternary operators) (#5398)
Browse files Browse the repository at this point in the history
* upgrade rules

* format

* v1.1.3
  • Loading branch information
tonyjhuang authored Jan 6, 2023
1 parent 9c2eeba commit abcaaab
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Fix bug where CLI was unable to deploy Firebase Functions in some monorepo setups (#5391)
- Upgrade Storage Rules Runtime to v1.1.3 to support ternary operators (#5370)
32 changes: 32 additions & 0 deletions scripts/storage-emulator-integration/rules/runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,38 @@ describe("Storage Rules Runtime", function () {
).to.be.false;
});
});

describe("features", () => {
describe("ternary", () => {
it("should support ternary operators", async () => {
const rulesContent = `
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{file} {
allow read: if request.path[3] == "test" ? true : false;
}
}
}`;

expect(
await testIfPermitted(runtime, rulesContent, {
method: RulesetOperationMethod.GET,
path: "/b/BUCKET_NAME/o/test",
file: {},
})
).to.be.true;

expect(
await testIfPermitted(runtime, rulesContent, {
method: RulesetOperationMethod.GET,
path: "/b/BUCKET_NAME/o/someRandomFile",
file: {},
})
).to.be.false;
});
});
});
});

async function testIfPermitted(
Expand Down
6 changes: 3 additions & 3 deletions src/emulator/downloadableEmulators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ const EMULATOR_UPDATE_DETAILS: { [s in DownloadableEmulators]: EmulatorUpdateDet
expectedChecksum: "4f41d24a3c0f3b55ea22804a424cc0ee",
},
storage: {
version: "1.1.2",
expectedSize: 47028740,
expectedChecksum: "983b4415b1e72b109864f1b8e7ea7546",
version: "1.1.3",
expectedSize: 52892936,
expectedChecksum: "2ca11ec1193003bea89f806cc085fa25",
},
ui: experiments.isEnabled("emulatoruisnapshot")
? { version: "SNAPSHOT", expectedSize: -1, expectedChecksum: "" }
Expand Down
2 changes: 1 addition & 1 deletion src/emulator/storage/rules/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class DefaultStorageRulesManager implements StorageRulesManager {
}:${parsedIssue.sourcePosition_.line_}`
);
} catch {
this._logger.log("WARN", issue);
this._logger.logLabeled("WARN", "storage", issue);
}
});
return issues;
Expand Down

0 comments on commit abcaaab

Please sign in to comment.