Skip to content

Commit

Permalink
Add more policy tests (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
samteb authored Jan 29, 2024
1 parent 9ac2b60 commit bfd683d
Show file tree
Hide file tree
Showing 10 changed files with 730 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test_checkAccCondition {
}

test_checkAccStartDate {
conditions = {"start": secondsToNanoSeconds(mockNowS - ((12 * 60) * 60))}
conditions = {"start": secondsToNanoSeconds(nowSeconds - ((12 * 60) * 60))}
checkAccStartDate(elevenHoursAgo, conditions.start)
}

Expand All @@ -31,7 +31,7 @@ test_checkSpendingsByAmount {
"eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
},
"users": {"test-alice-uid"},
"startDate": secondsToNanoSeconds(mockNowS - ((12 * 60) * 60)),
"startDate": secondsToNanoSeconds(nowSeconds - ((12 * 60) * 60)),
}

checkSpendings("1000000000000000000", conditions) with input as request with data.entities as entities
Expand All @@ -45,7 +45,7 @@ test_checkSpendingsByValue {
"eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
},
"users": {"test-alice-uid"},
"startDate": secondsToNanoSeconds(mockNowS - ((12 * 60) * 60)),
"startDate": secondsToNanoSeconds(nowSeconds - ((12 * 60) * 60)),
}

checkSpendings("900000000000000000", conditions) with input as request with data.entities as entities
Expand Down
10 changes: 4 additions & 6 deletions apps/authz/src/opa/rego/__test__/main_test.rego
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ package main

import future.keywords.in

mockNowS = 1630540800
twentyHoursAgo = (nowSeconds - ((20 * 60) * 60)) * 1000 # in ms

twentyHoursAgo = (mockNowS - ((20 * 60) * 60)) * 1000 # in ms
elevenHoursAgo = (nowSeconds - ((11 * 60) * 60)) * 1000 # in ms

elevenHoursAgo = (mockNowS - ((11 * 60) * 60)) * 1000 # in ms
tenHoursAgo = (nowSeconds - ((10 * 60) * 60)) * 1000 # in ms

tenHoursAgo = (mockNowS - ((10 * 60) * 60)) * 1000 # in ms

nineHoursAgo = (mockNowS - ((9 * 60) * 60)) * 1000 # in ms
nineHoursAgo = (nowSeconds - ((9 * 60) * 60)) * 1000 # in ms

principalReq = {"userId": "test-bob-uid"}

Expand Down
Loading

0 comments on commit bfd683d

Please sign in to comment.