-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: policy compilation error for deeply nested post-update rules (#1382
- Loading branch information
Showing
5 changed files
with
135 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { loadSchema } from '@zenstackhq/testtools'; | ||
|
||
describe('issue 1381', () => { | ||
it('regression', async () => { | ||
await loadSchema( | ||
` | ||
enum MemberRole { | ||
owner | ||
admin | ||
} | ||
enum SpaceType { | ||
contractor | ||
public | ||
private | ||
} | ||
model User { | ||
id String @id @default(cuid()) | ||
name String? | ||
email String? @unique @lower | ||
password String? @password @omit | ||
memberships Membership[] | ||
} | ||
model Membership { | ||
userId String | ||
user User @relation(fields: [userId], references: [id], onDelete: Cascade) | ||
spaceId String | ||
space Space @relation(fields: [spaceId], references: [id], onDelete: Cascade) | ||
role MemberRole @deny("update", auth() == user) | ||
@@id([userId, spaceId]) | ||
} | ||
model Space { | ||
id String @id @default(cuid()) | ||
name String | ||
type SpaceType @default(private) | ||
memberships Membership[] | ||
options Option[] | ||
} | ||
model Option { | ||
id String @id @default(cuid()) | ||
name String? | ||
spaceId String? | ||
space Space? @relation(fields: [spaceId], references: [id], onDelete: SetNull) | ||
@@allow("update", | ||
future().space.type in [contractor, public] && | ||
future().space.memberships?[space.type in [contractor, public] && auth() == user && role in [owner, admin]] | ||
) | ||
} | ||
`, | ||
{ | ||
provider: 'postgresql', | ||
pushDb: false, | ||
} | ||
); | ||
}); | ||
}); |