Alternera.Plugin.Test.Host (alternera_plugin_sdk v0.9.0)

Copy Markdown View Source

A Alternera.Plugin.Host for a plugin's own project, where there is no proxy to ask. It is the SDK's default, so a plugin's tests need no setup; the proxy names its own host in its config, which replaces it.

Tenant variables are a plain map of name to value in the template data's :tenant_vars. A plain reference resolves to its value and raises Alternera.Plugin.UnresolvedVariableError when the map does not hold it. A secret reference stays as it was written, which is what a step sees in the proxy too, and raises under allow_secret?: false. No method is allowed, the limits are the proxy's defaults, an error's map is its own fields, and the stores and caches live in the calling process: a test starts empty and sees its own writes.

The values a step reads by reference (Plugin.Secret.values/4) are the ones Alternera.Plugin.Test.stub_tenant_vars/1 set in the calling process.

Nothing leaves the process. An outbound call (Plugin.Provisional.Outbound) goes to the function Alternera.Plugin.Test.stub_outbound/1 set in the calling process, and fails unavailable without one. A recorded exchange's body is its :request_body or :response_body. Fingerprints are keyed with a fixed test key, and a saved body copy keeps 64 KiB, as the proxy's does. A step's flow checks (Plugin.Provisional.Checks) see each condition's shape only, no cache setting is wrong and no cache key reads the body. A rate (Plugin.Provisional.Rate) is counted in the calling process too. A store is secret when Alternera.Plugin.Test.secret_store/2 named it, and a cache target to invalidate is %{store: name, key: key}. Credentials (Plugin.Provisional.Credentials) come from the function Alternera.Plugin.Test.stub_authorization/1 set, and none apply without one. The signed-in caller (Plugin.Provisional.Identity) is the one Alternera.Plugin.Test.sign_in/1 set, anonymous without one, and a signed assertion is test-assertion. and its claims as key=value pairs. A response cache (Plugin.Provisional.ResponseCache) keys an entry by the request's method and URL, whatever its key says, looks up GET and HEAD only, and keeps what Alternera.Plugin.Test.ResponseCacheFill observed in the calling process; a dry run reads and never fills, and a response is kept when its status is one the cache keeps. Stored files (Plugin.Provisional.Files) live in the calling process, or in the process it was started from ($callers), so a task a test starts sees them; the uploader is the user id given. A resource's records (resource_get/3) are the ones Alternera.Plugin.Test.stub_resources/1 set in the calling process; a name it did not set is an unknown resource.