API Requests ReadAssertionsRequestInterface - evansims/openfga-php GitHub Wiki
Interface for reading test assertions from an authorization model. This interface defines the contract for requests that retrieve test assertions associated with a specific authorization model. Assertions are automated tests that verify authorization model behavior by checking specific permission scenarios against expected outcomes. Reading assertions is essential for: - Test Execution: Running automated tests to verify model behavior - Model Validation: Ensuring authorization logic works as expected - Debugging: Understanding test scenarios when troubleshooting issues - Documentation: Reviewing examples of how permissions should work - Continuous Integration: Automating authorization model testing - Regression Testing: Verifying that model changes don't break existing behavior The retrieved assertions include the test scenarios, expected outcomes, and any contextual data needed to execute the tests. This provides a complete test suite that can be run to validate the authorization model's correctness.
Table of Contents
OpenFGA\Requests
- ReadAssertionsResponseInterface (response)
- ReadAssertionsRequest (implementation)
public function getModel(): string
Get the authorization model ID to read assertions from. Specifies which version of the authorization model should have its assertions retrieved. Assertions are tied to specific model versions, ensuring that tests remain relevant to the particular authorization schema they were designed to validate.
string
— The authorization model ID whose assertions should be retrieved
public function getRequest(StreamFactoryInterface $streamFactory): RequestContext
Build a request context for HTTP execution. Transforms the request object into a standardized HTTP request context that can be executed by the OpenFGA HTTP client. This method handles all aspects of request preparation including parameter serialization, URL construction, header configuration, and body stream creation. The method validates that all required parameters are present and properly formatted, serializes complex objects to JSON, constructs the appropriate API endpoint URL, and creates the necessary HTTP message body streams.
Name | Type | Description |
---|---|---|
$streamFactory |
StreamFactoryInterface |
PSR-7 stream factory for creating request body streams from serialized data |
RequestContext
— The prepared request context containing HTTP method, URL, headers, and body ready for execution
public function getStore(): string
Get the store ID containing the assertions to read. Identifies which OpenFGA store contains the authorization model and its associated test assertions. Assertions are stored alongside the models they test, providing a complete testing framework within each store's context.
string
— The store ID containing the assertions to retrieve