Skip to content

Commit

Permalink
Move test packages and update linter.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffchao committed Jan 19, 2024
1 parent 9eef48e commit 9771070
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .regal/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ rules:
no-defined-entrypoint:
# This repo consists of a set of library functions, which therefore have no entrypoint.
level: ignore
style:
line-length:
# This repo consists of references to deeply-nested data variables.
level: ignore
7 changes: 4 additions & 3 deletions src/abbey/functions/expire_after_test.rego
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package abbey.functions_test

import data.abbey.functions
import future.keywords.if

test_after_expired_duration if {
not expire_after("1m") with data.system.abbey.target.grant.approved_at as "2023-01-01T01:00:00Z"
not functions.expire_after("1m") with data.system.abbey.target.grant.approved_at as "2023-01-01T01:00:00Z"
with time.now_ns as 1672534900000000000
}

test_at_expired_duration if {
not expire_after("1m") with data.system.abbey.target.grant.approved_at as "2023-01-01T01:00:00Z"
not functions.expire_after("1m") with data.system.abbey.target.grant.approved_at as "2023-01-01T01:00:00Z"
with time.now_ns as 1672534860000000000
}

test_before_expired_duration if {
expire_after("1m") with data.system.abbey.target.grant.approved_at as "2023-01-01T01:00:00Z"
functions.expire_after("1m") with data.system.abbey.target.grant.approved_at as "2023-01-01T01:00:00Z"
with time.now_ns as 0
}
7 changes: 4 additions & 3 deletions src/abbey/functions/expire_at_test.rego
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package abbey.functions_test

import data.abbey.functions
import future.keywords.if

test_after_expired_at_threshold if {
not expire_at("2023-01-01T02:00:00Z") with data.system.abbey.target.grant.approved_at as "2023-01-01T01:00:00Z"
not functions.expire_at("2023-01-01T02:00:00Z") with data.system.abbey.target.grant.approved_at as "2023-01-01T01:00:00Z"
with time.now_ns as 1672538500000000000
}

test_on_expired_at_threshold if {
not expire_at("2023-01-01T01:00:00Z") with data.system.abbey.target.grant.approved_at as "2023-01-01T01:00:00Z"
not functions.expire_at("2023-01-01T01:00:00Z") with data.system.abbey.target.grant.approved_at as "2023-01-01T01:00:00Z"
with time.now_ns as 1672538400000000000
}

test_before_expired_at_threshold if {
expire_at("2023-01-01T01:00:00Z") with data.system.abbey.target.grant.approved_at as "2023-01-01T01:00:00Z"
functions.expire_at("2023-01-01T01:00:00Z") with data.system.abbey.target.grant.approved_at as "2023-01-01T01:00:00Z"
with time.now_ns as 0
}
11 changes: 6 additions & 5 deletions src/abbey/functions/member_of_test.rego
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package abbey.functions_test

import data.abbey.functions
import future.keywords.if

fixture := {
Expand All @@ -14,28 +15,28 @@ fixture := {
}

test_member_of_googleworkspace_engineering_group if {
member_of("Engineering") with data.user as fixture
functions.member_of("Engineering") with data.user as fixture
}

test_member_of_okta_group if {
member_of("123") with data.user as fixture
functions.member_of("123") with data.user as fixture
}

# Tests if the user is a member of a group within Google. However, technically, the way we implement
# the `member_of` function entails a lookup against all of the user's `apps`. This means this test
# will also produce `false` if the group doesn't exist as a result of the group not being imported.
test_not_member_of_googleworkspace_engineering_group if {
not member_of("Marketing") with data.user as fixture
not functions.member_of("Marketing") with data.user as fixture
}

# Tests if the user is a member of a group within Okta. However, technically, the way we implement
# the `member_of` function entails a lookup against all of the user's `apps`. This means this test
# will also produce `false` if the group doesn't exist as a result of the group not being imported.
test_not_member_of_okta_group if {
not member_of("789") with data.user as fixture
not functions.member_of("789") with data.user as fixture
}

# Tests if the user is a member of a group, but the group is not imported.
test_unimported_group if {
not member_of("unimported") with data.user as fixture
not functions.member_of("unimported") with data.user as fixture
}

0 comments on commit 9771070

Please sign in to comment.