Skip to content

Commit

Permalink
Move approvals test to the new Rego location
Browse files Browse the repository at this point in the history
Original commit: 33ae82c
  • Loading branch information
wcalderipe committed Mar 20, 2024
1 parent cd18f44 commit 870918f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type Input = {
transactionRequest?: TransactionRequest
principal: CredentialEntity
resource?: { uid: string }
approvals: CredentialEntity[]
approvals?: CredentialEntity[]
transfers?: HistoricalTransfer[]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,26 @@ permit[{"policyId": "approvalByUserRoles"}] = reason {
"approvalsMissing": approvals.approvalsMissing,
}
}

permit[{"policyId": "withoutApprovals"}] = reason {
resources = {"eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e"}
transferTypes = {"transferERC20"}
tokens = {"eip155:137/erc20:0x2791bca1f2de4661ed88a30c99a7a9449aa84174"}
transferValueCondition = {"currency": "*", "operator": "lte", "value": "1000000000000000000"}

checkResourceIntegrity
checkPrincipal
checkNonceExists
checkAction({"signTransaction"})
checkWalletId(resources)
checkIntentType(transferTypes)
checkIntentToken(tokens)
checkIntentAmount(transferValueCondition)

reason = {
"type": "permit",
"policyId": "withoutApprovals",
"approvalsSatisfied": [],
"approvalsMissing": [],
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,22 @@ test_approvalByUserRoles {
"type": "permit",
}
}

test_withoutApprovals {
withoutApprovalsReq = {
"action": "signTransaction",
"transactionRequest": transactionRequestReq,
"principal": {"userId": "test-alice-uid"}, "resource": resourceReq,
"intent": intentReq,
"feeds": feedsReq,
}

res = permit[{"policyId": "withoutApprovals"}] with input as withoutApprovalsReq with data.entities as entities

res == {
"type": "permit",
"policyId": "withoutApprovals",
"approvalsSatisfied": [],
"approvalsMissing": [],
}
}

0 comments on commit 870918f

Please sign in to comment.