Commit Graph

35 Commits

Author SHA1 Message Date
Jeremy Lakeman
dced3bbb91 Avoid 1 second delay in tests when using curl to post forms 2016-05-18 12:11:58 +09:30
Jeremy Lakeman
7939a780fb Fix case where eof mime boundary overlaps buffer boundary 2016-04-11 13:10:37 +09:30
Andrew Bettison
3f8f0f6fc7 Improve Rhizome HTTP API diagnostics
Add RHIZOME_BUNDLE_STATUS_MANIFEST_TOO_BIG enum option to indicate
that the manifest exceeded 8 KiB in size.

Refactor rhizome_add_manifest() and rhizome_manifest_finalise()
to return 'struct rhizome_bundle_result' instead of 'enum
rhizome_bundle_status', so that that their detailed failure messages
can reach the HTTP API layer instead of just being logged.

Fix HTTP response status codes produced Rhizome direct HTTP requests
to be consistent with the Rhizome RESTful API.
2015-12-07 22:35:42 +10:30
Andrew Bettison
98ed0406c5 Refactor Rhizome result handling
- Introduce the new 'struct rhizome_bundle_result' that contains a
  rhizome_bundle_status enum value and an optional, nul-terminated
  string that provides an explanation of the cause of the status; add
  functions to construct, query, and free the struct

- Replace 'enum rhizome_add_result' with 'struct rhizome_bundle_result',
  removing an unnecessary level of enum interpretation

- Make rhizome_fill_manifest() return 'struct rhizome_bundle_result' and
  add logic to check that the supplied author SID is correct (previous
  behaviour was: if an incorrect author SID was supplied but the correct
  author could be found in the keyring, then the incorrect one was
  silently ignored)

- Simplify the response code in rhizome_restful.cc to take advantage of
  the new 'struct rhizome_bundle_result'; in particular, the mapping
  from 'enum rhizome_bundle_status' codes to HTTP status codes is now
  expressed in a single switch statement

- Fix some minor failures in test scripts revealed by the changes
2015-12-01 00:51:15 +10:30
Andrew Bettison
419364b5a9 Improve REST HTTP response status codes
List all the HTTP status codes in the REST API tech doc.

Only use 403 Forbidden for requests originating from a disallowed
origin (ie, not localhost).

- Return 400 for missing, unknown, duplicate and out-of-order form
  parts in POST requests.
- Return 415 Unsupported Media Type for unsupported form part
  Content-Disposition and Content-Type (including unsupported
  charset).
- Return 414 Request-URI Too Long for any buffer exhaustion while
  parsing request.
- Return 419 Authentication Timeout for missing crypto secret.
2015-11-02 12:26:40 +10:30
Andrew Bettison
4564e955e3 Improve HTTP Origin response headers
Re-introduce "Origin: null" handling, because actually it is in the
spec.
2015-11-02 11:58:24 +10:30
Andrew Bettison
404cc1476d Improve HTTP Origin header parsing
Parses the separate parts of the URI: scheme, hostname, port.
No longer supports "Origin: null", because that is not in the
spec.
2015-10-01 07:05:17 +09:30
Andrew Bettison
6123503c15 Improve Rhizome HTTP status codes
Also improve some reason phrases and test them
2015-09-21 18:43:24 +09:30
Andrew Bettison
6febcc350d Replace RESTful newsince polling with triggers
Remove the 'api.restful.newsince_poll_ms' config option, no longer
needed.
2015-06-02 02:23:06 +09:30
Andrew Bettison
ed1acca0ed Fix 'rhizomerestful' and 'rhizomejava' newsince-arrival tests
Use POST /restfule/rhizome/insert REST request to add bundles instead of
CLI 'rhizome file add', to avoid database locking storm and prepare for
replacing polling with trigger-based wakeup in newsince requests.
2015-06-02 02:23:06 +09:30
Andrew Bettison
858a7fc577 Refactor: define extract_http_header() in testdefs.sh
Also http_unquote_string()
2015-06-02 02:23:06 +09:30
Andrew Bettison
45c6b9ecfa Refactor: set $CR and $HT in testdefs.sh
Fix some bugs in test scripts that used $CR without setting it
2015-06-02 02:23:06 +09:30
Andrew Bettison
979854ae0b Test that Rhizome RESTful append rejects non-journals 2015-04-13 16:24:05 +09:30
Andrew Bettison
0f8141af95 Test RESTful Rhizome journal append with shared payload
When an append produces a payload that is already in the store,
the append must succeed, and the returned status codes should
indicate that the payload already existed
2015-04-13 16:24:05 +09:30
Andrew Bettison
53e4e5be5f Improve 'rhizomerestful' journal append test case
Add asserts for the returned status codes
2015-04-13 14:43:52 +09:30
Andrew Bettison
7734e24006 /restful/rhizome/append on existing journal
Refactor Rhizome insert/append logic into functions used by both CLI and
RESTful API.  Improve RESTful diagnostic messages.
2015-03-30 18:24:12 +10:30
Andrew Bettison
214dad421b Rename 'rhizomerestful' journal test cases 2015-03-30 18:21:31 +10:30
Andrew Bettison
dbea301ce2 Rhizome test defs support 'tail' field 2015-03-28 05:09:37 +10:30
Andrew Bettison
705dbeff09 Fix bug in rhizome_write_open_journal()
Was treating PAYLOAD_STATUS_NEW as an error
2015-03-23 17:40:08 +10:30
Andrew Bettison
015b4a0b07 Refactor and improve "journal append"
Distinguish between fatal and user-supplied-input errors, return
error descriptive text in a strbuf to allow dynamic content, apply
user-supplied field assgnments/deletions _after_ copying existing
manifest fields, use exit status 4 (invalid manifest) when applying
journal append to a non-journal or vice versa
2015-03-23 17:38:46 +10:30
Andrew Bettison
c9131f43a2 POST /restful/rhizome/append for journals 2015-03-02 18:52:12 +10:30
Andrew Bettison
4b234fbfbd Fix /restful/rhizome/insert HTTP status code
Return 403 "Forbidden" instead of 501 "Not implemented" when
given a journal bundle
2015-03-02 18:49:51 +10:30
Andrew Bettison
081f7ab8c8 Add recent bundle secret improvements to RESTful API
The "#passphrase" notation was already supported, and now the RESTful
API can be used to create and update anonymous and authored bundles
using only the bundle secret, just like the CLI.
2014-11-14 17:31:08 +10:30
Andrew Bettison
3c4703feb4 Reduce DB locking issues in RESTful tests
Add environment variable SERVALD_RHIZOME_DB_RETRY_LIMIT to extend the
Rhizome DB retry period, set it to 60 seconds in RESTful tests to
override the default 5 seconds
2014-11-12 23:08:19 +10:30
Jeremy Lakeman
31cf3a67b5 Allow lcal http servers to perform cross site scripting of restful APIs 2014-07-28 12:54:57 +09:30
Andrew Bettison
4c6612a61e Rhizome Java API: list bundles new since token 2014-07-12 22:49:00 +09:30
Andrew Bettison
8842f32b19 Rhizome Java API: insert journal is not implemented
Change the HTTP response code for unimplemented operations from 403 to
501
2014-07-10 22:23:11 +09:30
Andrew Bettison
e35bf77938 Rhizome Java API: insert/update empty bundle 2014-07-10 22:06:46 +09:30
Andrew Bettison
04b2a20e54 Rhizome Java API: improved form-data headers
Change manifest Content-Type from rhizome-manifest/text to
rhizome/manifest; format="text+binarysig"

Add "Content-Transfer-Encoding" form-part headers to Java API
sent form parts, although not currently checked by Rhizome
RESTful interface
2014-07-10 21:12:40 +09:30
Andrew Bettison
3715c5bf0b Rhizome Java API: negative fetch tests 2014-07-10 06:30:50 +09:30
Andrew Bettison
cf43635789 Improve Rhizome HTTP RESTful interface
Add RHIZOME_BUNDLE_STATUS_READONLY enum value

Tighten up switch statements on bundle and payload status enums (no
default labels)

Rename some recently added enum entries

Return bundle status and payload status in HTTP responses

Add test for failing to decrypt a foreign encrypted bundle payload,
fix bug that caused an assertion failure

Add tests for fetching a non-existent manifest and fetching bundles
whose payload blob is not in the store
2014-07-10 06:29:51 +09:30
Andrew Bettison
a9ec5dcf69 Refactor Rhizome test script ready for re-use
Move add_bundles() function from 'rhizomerestful' test script into
testdefs_rhizome.sh, rename to rhizome_add_bundles() and add a new
SID argument
2014-06-30 11:11:01 +09:30
Andrew Bettison
067340bbba Change HTTP Authorization realm to "Serval RESTful API"
Was "Serval Rhizome", which is not accurate
2014-06-30 11:11:01 +09:30
Andrew Bettison
11e9d38299 Rename config 'rhizome.api.restful' to 'api.restful' 2014-06-30 11:11:01 +09:30
Andrew Bettison
776d4de894 Split up 'rhizomehttp' test script
New scripts 'rhizomerestful' and 'meshmsrestful'
New testdefs_json.sh
Improved testdefs.sh functions for discovering HTTP server port
2014-06-26 15:08:48 +09:30