Module: Reeve::Testing::Assertions
- Included in:
- ComplianceAssertions
- Defined in:
- lib/reeve/testing/assertions.rb
Overview
The Minitest front-end.
require "reeve/minitest"
class InvoiceSearchToolTest < ActiveSupport::TestCase
include Reeve::Testing::Assertions
test "does not leak across principals" do
assert_denies_access_for InvoiceSearchTool, stranger, query: "AC"
end
test "is audited" do
assert_audits_every_call InvoiceSearchTool
end
end
Note what this module does not reference: Minitest. It calls the assert its
including class already provides, which is why requiring it costs a stock
rails new application nothing and adds no dependency to this gem (FR-026).
Every message passed to assert is the check's own. Nothing here writes a sentence.
Instance Method Summary collapse
-
#assert_audits_every_call(tool, principal: nil, invoke: nil, ledger: nil, **arguments) ⇒ Object
FR-017.
-
#assert_denies_access_for(tool, principal, invoke: nil, ledger: nil, **arguments) ⇒ Object
FR-016.
-
#assert_no_cross_principal_leak(tool, principals: nil, invoke: nil, ledger: nil, **arguments) ⇒ Object
FR-016, the compliance form: two principals with disjoint records.
-
#assert_reeve_check(check) ⇒ Object
SC-009's escape hatch: any of the seven, straight from Minitest.
-
#assert_reeve_compliance(principals: nil, **options) ⇒ Object
A whole Report at once, for a host that would rather have one test than seven.
Instance Method Details
#assert_audits_every_call(tool, principal: nil, invoke: nil, ledger: nil, **arguments) ⇒ Object
FR-017. Pass invoke: to point the assertion at the host's own call site, which
is where an audit bypass actually lives.
50 51 52 53 54 55 56 57 |
# File 'lib/reeve/testing/assertions.rb', line 50 def assert_audits_every_call(tool, principal: nil, invoke: nil, ledger: nil, **arguments) assert_reeve_check( Checks::AuditCoverage.new( tool: tool, principal: principal || Testing.compliance_principals.first, arguments: arguments, invoke: invoke, ledger: ledger ) ) end |
#assert_denies_access_for(tool, principal, invoke: nil, ledger: nil, **arguments) ⇒ Object
FR-016.
28 29 30 31 32 33 34 35 |
# File 'lib/reeve/testing/assertions.rb', line 28 def assert_denies_access_for(tool, principal, invoke: nil, ledger: nil, **arguments) assert_reeve_check( Checks::CrossPrincipalLeak.new( tool: tool, principals: [principal], expect: :nothing, arguments: arguments, invoke: invoke, ledger: ledger ) ) end |
#assert_no_cross_principal_leak(tool, principals: nil, invoke: nil, ledger: nil, **arguments) ⇒ Object
FR-016, the compliance form: two principals with disjoint records.
38 39 40 41 42 43 44 45 46 |
# File 'lib/reeve/testing/assertions.rb', line 38 def assert_no_cross_principal_leak(tool, principals: nil, invoke: nil, ledger: nil, **arguments) assert_reeve_check( Checks::CrossPrincipalLeak.new( tool: tool, principals: principals || Testing.compliance_principals, arguments: arguments, invoke: invoke, ledger: ledger ) ) end |
#assert_reeve_check(check) ⇒ Object
SC-009's escape hatch: any of the seven, straight from Minitest.
60 61 62 63 64 |
# File 'lib/reeve/testing/assertions.rb', line 60 def assert_reeve_check(check) result = check.call assert result.passed?, result. result end |
#assert_reeve_compliance(principals: nil, **options) ⇒ Object
A whole Report at once, for a host that would rather have one test than seven.
67 68 69 70 71 72 73 |
# File 'lib/reeve/testing/assertions.rb', line 67 def assert_reeve_compliance(principals: nil, **) report = Checks.run_all( principals: principals || Testing.compliance_principals, ** ) assert report.passed?, report.to_s report end |