@rebasepro/server-postgresql 0.0.1-canary.bbcb8b4 → 0.0.1-canary.c53f5db

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -666,6 +666,53 @@ using: "{is_locked} = false" }
666
666
  expect(result).toContain('as: "restrictive"');
667
667
  });
668
668
 
669
+ it("should enable RLS on every table even without any security rules", async () => {
670
+ const collections: EntityCollection[] = [{
671
+ slug: "public_data",
672
+ table: "public_data",
673
+ name: "Public Data",
674
+ properties: { title: { type: "string" } }
675
+ // No securityRules defined — table should still have .enableRLS()
676
+ }];
677
+
678
+ const result = await generateSchema(collections);
679
+ expect(result).toContain(".enableRLS()");
680
+ // No policies should be generated
681
+ expect(result).not.toContain("pgPolicy(");
682
+ });
683
+
684
+ it("should enable RLS on tables that do have security rules", async () => {
685
+ const collections: EntityCollection[] = [{
686
+ slug: "secure_data",
687
+ table: "secure_data",
688
+ name: "Secure Data",
689
+ properties: { title: { type: "string" } },
690
+ securityRules: [
691
+ { operation: "select", access: "public" }
692
+ ]
693
+ }];
694
+
695
+ const result = await generateSchema(collections);
696
+ expect(result).toContain(".enableRLS()");
697
+ expect(result).toContain("pgPolicy(");
698
+ });
699
+
700
+ it("should fall back to deny-all (sql`false`) when no USING clause can be generated", async () => {
701
+ const collections: EntityCollection[] = [{
702
+ slug: "deny_test",
703
+ table: "deny_test",
704
+ name: "Deny Test",
705
+ properties: { title: { type: "string" } },
706
+ securityRules: [
707
+ { operation: "select" }
708
+ // No access, ownerField, or using — should produce sql`false`
709
+ ]
710
+ }];
711
+
712
+ const result = await generateSchema(collections);
713
+ expect(result).toContain("sql`false`");
714
+ });
715
+
669
716
  });
670
717
  });
671
718
  // V2 improvements tests