Skip to content

AZ502: A test acting as a type that doesn't sign in ​

A test acts as anyone, a user, or a principal type (type bot = app.bots principal).

Reported when the tests are compiled: rowfence test, the editor, rowfence dev.

The mistake ​

authz
app role app_user
type user = app.users
type team = app.teams
  member : user = app.team_members(team_id -> user_id)
  can see = member
test "teams"
  given t = {INSERT INTO app.teams (name) VALUES ('a') RETURNING id}
  team $t can see team $t
line 8: 'team' doesn't sign in: a test acts as anyone or as one of user [AZ502]

Fixed ​

authz
app role app_user
type user = app.users
type team = app.teams
  member : user = app.team_members(team_id -> user_id)
  can see = member
test "teams"
  given t = {INSERT INTO app.teams (name) VALUES ('a') RETURNING id}
  anyone cannot see team $t