M0 + M1 done

This commit is contained in:
marcos.lohmann_at_orcl
2026-09-11 15:04:34 -03:00
parent 5ebec725ec
commit 439f60598e
51 changed files with 2991 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
package emcp.transaction_test
import rego.v1
import data.emcp.transaction
sales_write_profile := {"restrictions": {
"max_transaction_value": 500000,
"allowed_regions": ["BR-SP", "BR-RJ"],
"approval_threshold": 100000,
}}
test_allow_within_limit_and_region if {
transaction.allow with input as {
"client_profile": "Sales.Write",
"tool": "sales.quote.create",
"arguments": {"amount": 50000, "region": "BR-SP"},
"customer_classification": "standard",
} with data.emcp.client_profiles as {"Sales.Write": sales_write_profile}
}
test_deny_above_transaction_limit if {
not transaction.allow with input as {
"client_profile": "Sales.Write",
"tool": "sales.quote.create",
"arguments": {"amount": 600000, "region": "BR-SP"},
"customer_classification": "standard",
} with data.emcp.client_profiles as {"Sales.Write": sales_write_profile}
}
test_deny_outside_allowed_region if {
not transaction.allow with input as {
"client_profile": "Sales.Write",
"tool": "sales.quote.create",
"arguments": {"amount": 50000, "region": "BR-MG"},
"customer_classification": "standard",
} with data.emcp.client_profiles as {"Sales.Write": sales_write_profile}
}
test_deny_restricted_customer if {
not transaction.allow with input as {
"client_profile": "Sales.Write",
"tool": "sales.quote.create",
"arguments": {"amount": 50000, "region": "BR-SP"},
"customer_classification": "restricted",
} with data.emcp.client_profiles as {"Sales.Write": sales_write_profile}
}
test_require_approval_above_threshold if {
# README.md §26: allowed, but only with human approval, above threshold.
transaction.allow with input as {
"client_profile": "Sales.Write",
"tool": "sales.quote.create",
"arguments": {"amount": 150000, "region": "BR-SP"},
"customer_classification": "standard",
} with data.emcp.client_profiles as {"Sales.Write": sales_write_profile}
transaction.require_approval with input as {
"client_profile": "Sales.Write",
"tool": "sales.quote.create",
"arguments": {"amount": 150000, "region": "BR-SP"},
"customer_classification": "standard",
} with data.emcp.client_profiles as {"Sales.Write": sales_write_profile}
}
test_no_approval_required_below_threshold if {
not transaction.require_approval with input as {
"client_profile": "Sales.Write",
"tool": "sales.quote.create",
"arguments": {"amount": 50000, "region": "BR-SP"},
"customer_classification": "standard",
} with data.emcp.client_profiles as {"Sales.Write": sales_write_profile}
}