Skip to content

Commit

Permalink
test: simple cases added for multi line permission expression
Browse files Browse the repository at this point in the history
  • Loading branch information
tolgaOzen committed Sep 25, 2024
1 parent 0aa070c commit 14d20fc
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pkg/dsl/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1007,5 +1007,39 @@ rule confidentiality_level_low(confidentiality_level double) {
_, err := pr.Parse()
Expect(err).ShouldNot(HaveOccurred())
})

It("Case 28 - Multi-line Permission Expression w/ Rule", func() {
pr := NewParser(`
entity account {
relation owner @user
relation admin @user
permission withdraw = admin or
owner
}
`)

_, err := pr.Parse()
Expect(err).ShouldNot(HaveOccurred())
})

It("Case 29 - Multi-line Permission Expression w/ Rule - should fail", func() {
pr := NewParser(`
entity account {
relation owner @user
relation admin @user
permission withdraw = admin
or owner
}
`)

_, err := pr.Parse()
// Ensure an error is returned
Expect(err).Should(HaveOccurred())

// Ensure the error message contains the expected string
Expect(err.Error()).Should(ContainSubstring("7:15:expected token to be RELATION, PERMISSION, ATTRIBUTE, got OR instead"))
})
})
})

0 comments on commit 14d20fc

Please sign in to comment.