usagi: Web API test plugin for haas
usagi is a plugin for haas that adds support for discovering Web API test cases descibed in YAML.
usagi requires haas v0.6.0 or later.
Current Features
Describe web API tests using YAML.
Template URLs to avoid repeating items.
Variables and target hostname can be provided by environment variables.
YAML format contains multiple test cases.
Each test case is a grouping of related tests.
Make flexible assertions about the server’s response.
Contribute web API test runner functionality through plugins.
Assert that the SHA256 of the response body matches an expected value.
Filter JSON response bodies before comparison using jq filter syntax: http://stedolan.github.io/jq/
Plugins
Var loaders
Load from environment
Template string based on other vars
Load from file, either plaintext or JSON
Assertions
Assert status code
Assert header is present or matches value or regexp
TODO
Add more assertions!
Test config format
version: Currently required, but unverified (we are at v0.1.0.devN, after all).
config: Common test case configuration.
host: The name (or IP) of the host to test.
Can come from env, template, file, like vars.
scheme: The scheme (http, https) to use to connect to host
vars: Common variable definitions for all test cases; formatted as a dictionary of var name to type and value.
Simple string vars are allowed.
Others are specified as a dictionary with key type to determine how to load.
cases: Collection of test cases. Each case contains multiple tests
name: The name of the test case
tests: Collection of individual tests
name: The name of the test
url: The URI/path relative to host against which the test will be executed.
method: The HTTP method to use for the test.
assertions: List of assertions to make about the test.
Example Test
---
version: '1.0'
config:
# Host is loaded as an environment variable
host:
type: env
env: TEST_HOSTNAME
vars:
# Simple string var
api_root: "/api/v1/json"
# Template var
metadata:
type: template
template: "{api_root}/metadata"
# Variable loaded as JSON from file
expected_index:
type: file
file: some_file.json
format: json
cases:
- name: "Basic"
tests:
- name: "Test root URL"
url: "/"
assertions:
- name: status_code
expected: 200
- name: header
header: Content-Type
value: text/plain
- name: "A case"
tests:
- name: "Authentication failure"
url:
type: template
template: "{metadata}/auth/required"
parameters:
method: GET
headers:
Content-Type: application/json
assertions:
- name: status_code
expected: 401
- name: header
header: WWW-Authenticate
regexp: "Basic realm=.*"
- name: "POST json"
url:
type: template
template: "{metadata}/post"
parameters:
method: POST
body:
format: json
lookup-var: false
value:
some: ["json-compatible", "structure"]
assertions:
- name: status_code
expected: 204
Metadata
Release files for usagi 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| usagi-0.3.1.tar.gz | 18.7 kB | Without provenance | Details for usagi-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| usagi-0.3.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for usagi-0.3.1-py2.py3-none-any.whl |
Total release size: 46.8 kB
Release files / usagi-0.3.1.tar.gz
| Download URL | usagi-0.3.1.tar.gz |
|---|---|
| Size | 18.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bbcae90adfeb2b566fde7e41bf7a28ac80dad032f3e5a5594b12e773dab52cc4
|
|
BLAKE2b-256 checksum How to use checksums |
eeba4dfa7c5c669e93bb41a66847ec5ce0ddef07c17eb9b118917dc13dd68d44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / usagi-0.3.1-py2.py3-none-any.whl
| Download URL | usagi-0.3.1-py2.py3-none-any.whl |
|---|---|
| Size | 28.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
77aeb3153933c996823ba6ccb4720091a7282183dbf8749d942c06459ffef4a8
|
|
BLAKE2b-256 checksum How to use checksums |
41e9ef2486729712c95708f8cff6645764c27abfa2419a620a1a010a83eb3763
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for usagi 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.