From b1f7315b9a1bcea8b3d75c637eea8adee7f5809a Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 10 Mar 2019 15:43:14 +0200 Subject: Change: update docs, drop unnecessary junk --- yarns/000.yarn | 42 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) (limited to 'yarns') diff --git a/yarns/000.yarn b/yarns/000.yarn index 4e6719c..d9f16f5 100644 --- a/yarns/000.yarn +++ b/yarns/000.yarn @@ -4,6 +4,7 @@ author: Lars Wirzenius ... [yarn]: https://liw.fi/cmdtest/ +[Effireg]: https://effireg.liw.fi/ # Introduction @@ -12,6 +13,9 @@ scenario tests. It is meant to be understandable to Effi sysadmins, and those writing applications using the API, as well as be an executable test suite for the API. +Effiapi is part of [Effireg][], a privacy-aware register of members +for associations. + The API is a simple RESTful HTTP API using JSON. This means that: * each API call is an HTTP request, with a response @@ -31,12 +35,13 @@ Examples will be provided. # Test scenarios -## Manage memberships - -This section shows the API calls to manage a memberhip. +## Manage memberships - happy path - SCENARIO Manage memberships +This section shows the API calls to manage a memberhip. The test +scaffolding starts an effiapi instance, and defines an API client for +the administrator, which has all the access. + SCENARIO Manage a membership GIVEN An effiapi instance First make sure the register is empty. @@ -50,7 +55,7 @@ First make sure the register is empty. THEN HTTP status is 200 AND body matches { "resources": [] } -Create a member. +Create a member. Check in various ways that it exists. WHEN admin requests POST /memb with body { "fullname": "James Bond" } THEN HTTP status is 201 @@ -83,7 +88,7 @@ Update the member. AND body matches { "fullname": "Alfred Pennyworth" } AND header Muck-Revision is ${REV2} -Delete the member. +Delete the member. Check in various ways that it no longer exists. WHEN admin requests DELETE /memb with id ${ID} THEN HTTP status is 200 @@ -104,14 +109,10 @@ Done. FINALLY Effiapi is terminated -TODO: - -* search -* members can see their own data, and can't see each others' -* member follows authn link emailed to them - # Appendix: Yarn scenario step implementations +Most of the interesting code is in the `lib.py` module. + ## Start and stop effiapi IMPLEMENTS GIVEN An effiapi instance @@ -134,9 +135,6 @@ TODO: rid = get_expanded_match() rev = get_expanded_match() body = get_json_match() - print('rid', repr(rid)) - print('rev', repr(rev)) - print('body', repr(body)) headers = { 'Muck-Id': rid, 'Muck-Revision': rev, @@ -145,9 +143,7 @@ TODO: IMPLEMENTS WHEN admin requests GET /memb with header (\S+): (\S+) header = get_next_match() - print('header', repr(header)) value = get_expanded_match() - print('value', repr(value)) headers = { header: value, } @@ -155,7 +151,6 @@ TODO: IMPLEMENTS WHEN admin requests GET /search with (.+) body = get_expanded_json_match() - print('body', repr(body)) headers = { 'Content-Type': 'application/json', } @@ -163,7 +158,6 @@ TODO: IMPLEMENTS WHEN admin requests DELETE /memb with id (\S+) rid = get_expanded_match() - print('rid', repr(rid)) headers = { 'Muck-id': rid, } @@ -174,31 +168,21 @@ TODO: IMPLEMENTS THEN HTTP status is (\d+) expected = int(get_next_match()) actual = effiapi.get_status_code() - print 'actual:', repr(actual) - print 'expecting:', repr(expected) assertEqual(effiapi.get_status_code(), expected) IMPLEMENTS THEN remember header (\S+) as (.+) header = get_next_match() varname = get_next_match() value = effiapi.get_header(header) - print 'header:', repr(header) - print 'value:', repr(value) - print 'varname:', repr(varname) save_for_expansion(varname, value) IMPLEMENTS THEN header (\S+) is (.+) header = get_next_match() expected = get_expanded_match() actual = effiapi.get_header(header) - print 'header:', repr(header) - print 'expected:', repr(expected) - print 'actual:', repr(actual) assertEqual(actual, expected) IMPLEMENTS THEN body matches (.+) expected = get_expanded_json_match() actual = effiapi.get_json_body() - print 'expected:', expected - print 'actual: ', actual assertEqual(actual, expected) -- cgit v1.2.1