View as Markdown

Test your app#

Run your app's tests without a browser, a phone or a node.

Level 1: A person approves with a passkey.
Class read: Nothing changes. The approval can be reused until it ends or the person withdraws it.
from app import app

client = app.test_client()


def test_a_request_without_a_passport_is_refused():
    r = client.get("/notes")
    assert r.status_code == 401
    assert r.json["type"] == "https://allowedby.org/errors/passport_required"


def test_agents_see_the_sentence_the_person_approves():
    r = client.get("/.well-known/allowedby")
    assert r.json["templates"]["notes:read"]["summary"]["en"] == "Read your notes"


def test_deleting_needs_an_approval_of_that_exact_request():
    r = client.get("/openapi.json")
    assert r.json["paths"]["/notes/{id}"]["delete"]["x-allowedby"]["class"] == "write-hard"

Run in 8 languages on this version. See the results

What the test proves#

  • the app's tests pass without a browser