API Requests WriteAssertionsRequest - evansims/openfga-php GitHub Wiki

Request for writing test assertions to validate authorization model behavior. This request stores test assertions that define expected authorization outcomes for specific scenarios. Assertions are used to validate that authorization models behave correctly and can be run as part of testing and validation workflows.

Table of Contents


Namespace

OpenFGA\Requests


Source

View source code


Implements


Related Classes


Methods

getAssertions

public function getAssertions(): OpenFGA\Models\Collections\AssertionsInterface

Get the test assertions to write to the authorization model. Returns a collection of assertions that define test scenarios for the authorization model. Each assertion specifies a permission check and its expected outcome, creating a comprehensive test suite that verifies the model's behavior across various scenarios. Assertions help ensure that: - Permission checks return expected results - Model changes don't introduce regressions - Complex authorization logic works correctly - Edge cases and special scenarios are properly handled - Documentation of expected behavior is maintained

View source


Returns

AssertionsInterface — Collection of test assertions to validate authorization model behavior


getModel

public function getModel(): string

Get the authorization model ID to associate assertions with. Specifies which version of the authorization model these assertions should be tied to. Assertions are version-specific, allowing you to maintain different test suites for different model versions and ensure that tests remain relevant as your authorization schema evolves.

View source


Returns

string — The authorization model ID that these assertions will test


getRequest

public function getRequest(Psr\Http\Message\StreamFactoryInterface $streamFactory): OpenFGA\Network\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.

View source


Parameters

Name Type Description
$streamFactory StreamFactoryInterface PSR-7 stream factory for creating request body streams from serialized data

Returns

RequestContext — The prepared request context containing HTTP method, URL, headers, and body ready for execution


getStore

public function getStore(): string

Get the store ID where assertions will be written. Identifies the OpenFGA store that contains the authorization model and where the test assertions will be stored. Assertions are stored alongside the model they test, providing a complete testing framework within each store.

View source


Returns

string — The store ID where the test assertions will be written

⚠️ **GitHub.com Fallback** ⚠️