Commit Graph

740 Commits

Author SHA1 Message Date
Andrew Bettison
8345d896a6 Add Route REST API (fixes #96)
Consists of a single, one-shot request, GET /restful/route/all.json, for
the time being.  A "newsince" request can be added later.

Add a Markdown tech doc that specifies the new Route REST API and update
the MDP tech doc a little.

Add the 'routerestful' test script, which uses some test utility
fuctions that have been factored out of the 'routing' test script into
the new testdefs_routing.sh.

Add the new 'allrestful' test script.
2018-03-29 15:31:03 +10:30
Andrew Bettison
2ef315b692 Fix tfw_createfile utility
Was not omitting characters given by the --omit option.
2018-03-29 15:19:54 +10:30
Andrew Bettison
2e0cb4e6dc Improve test framework error handling
If runTests() terminated with a FATAL condition, the cause was not
always apparent, because the error message usually got overwritten by
the test progress output on the user's terminal.  To fix this, the main
loop's standard error is now collected in a temporary file which is sent
to standard error just before exit.

The test framework was not always handling its internal FATAL error code
(255) correctly, so this has been fixed.

One cause of a FATAL termination was if a test's unique temporary
directory, which was based on its Process ID, already existed.  Anything
that left a temporary directory behind increased the likelihood of a
FATAL in a subsequent test run.  (For example, one keyring test case was
not killing its Serval DNA daemon, and the daemon was re-creating its
instance directory before eventually terminating itself.  This test case
has been fixed.)

The test framework now allocates its temporary directory by re-trying
different random numbers until mkdir(1) succeeds, and only fataling
after 20 failures.
2018-03-29 15:09:45 +10:30
Andrew Bettison
4f5567e2c1 Use rigorous quoting throughout test scripts
This makes it much easier to refactor test fixtures and utilities.
2018-03-27 17:29:21 +10:30
Andrew Bettison
1936015ac7 Fix Rhizome protocol "ManyFiles" test
Increase the timeout from 30 to 240 seconds.  Reduce debug logging.  Fix
bundle authors.
2018-03-27 17:29:21 +10:30
Andrew Bettison
bc7f7aeaaf Refactor all REST API tests
Rename 'testdefs_json.sh' to 'testdefs_rest.sh'; add setup functions and
rest_request() function, and roll out through existing test scripts.
2018-03-27 17:29:21 +10:30
Andrew Bettison
9ef7d33d69 Log more debug in MDP_ROUTE_TABLE request 2018-03-27 09:06:41 +10:30
Andrew Bettison
007a7af122 Update Java API to use new Keyring REST API
The ServalDCient class now requires a "verb" parameter as well as the
URL parameter.

Add Java API method to query a single keyring identity.
2018-03-19 18:07:33 +10:30
Andrew Bettison
98ec1c9608 Redesign the Keyring REST API (fixes #132)
The new API follows REST rules by using the proper request verbs:
POST, PUT, PATCH and DELETE, instead of just GET.

The legacy GET-only API is still supported for backward compatibility,
but not longer tested or documented.

Add a new query-single-identity operation.

Implement the lock-single-identity operation, which until now had been
documented but not yet implemented.  Whenever a single identity is
locked (released), any other unlocked identities with the same PIN are
flagged to indicate that the PIN is not "fully" unlocked, so that the
next time the PIN is entered, the slot decryption is re-tried for
non-loaded identities, and the locked identity will be unlocked again.

Update the 'keyring' and 'keyringrestful' test scripts:
- refactored to reduce curl command-line clutter in test cases
- now tests the redesigned request verbs and paths
- added a test for GET /restful/keyring/SID
- added a test for PUT /restful/keyring/SID/lock
2018-03-19 18:06:23 +10:30
Andrew Bettison
fad187046e Add missing tests/alljava script 2018-03-06 18:31:26 +10:30
Andrew Bettison
3ffa4b10af Add Swift keyring client API with tests
Add a swift-client-api subdirectory containing a Swift source package
and a Makefile.in that compiles it into the "ServalClient" Swift module
using the Swift package manager.  The Swift API contains the following
classes:

- ServalKeyring provides the operations: add, remove, set, list
- AbstractId and its specialisation SubscriberId, already in near-final
  form, are data types for SID and the like
- ServalRestfulClient (internal) uses an HTTP client to access the
  Serval DNA RESTful interface

Improve the REST /keyring/set operation to only alter the DID or Name if
the corresponding query parameter is supplied.  Modify the internal
keyring_set_did() function to only assign the DID or Name if the
corresponding parameter is not a null pointer.

The configure script ensures that the Swift build target version is
10.10 or later when compiling for Mac OS-X, so that the package manager
will succeed.

Add autoconf macros for the Swift package manager.
2018-03-06 15:29:17 +10:30
Andrew Bettison
e9d91d04ca Fix failing Rhizome Java API tests
Update the Java API to be consistent with recent changes to the Rhizome
REST API was that regularised the MIME types used in Content-Type
headers.

Add some missing CONTENT_TYPE_ constants to "httpd.h", and ensure they
are consistent with the Java getMimeType() methods in subclasses of
AbstractId.

Add the --stderr option to all executeJavaOk statements in the
'rhizomejava' test script, to reveal the exception message in the case
of failure.
2018-03-06 15:16:56 +10:30
Andrew Bettison
16d4a6d18e Fix the $JAVAC conditional in tests/all
Add a test script for all Java tests, called "alljava".

Include testconfig.sh in testdefs.sh, not testdefs_java.sh, so that the
tests/all script can successfully test the $JAVAC variable.
2018-03-06 15:16:56 +10:30
Andrew Bettison
92fa6c196a Rewrite logging system
Rename the logging primitive functions and utility functions, prefixing
all with 'serval_log', eg: logMessage() -> serval_logf() etc.

Add an XPRINTF xhexdump() function and use it to implement the
serval_log_hexdump() utility, renamed from dump().  Add macros
WHY_dump(), WARN_dump(), HINT_dump() and DEBUG_dump(), and use them
everywhere.

Remove the 'log.console.dump_config' and 'log.file.dump_config'
configuration options; configuration is now dumped in every log prolog.

The logging system now constructs the log prolog by invoking the new
'log_prolog' trigger, so that it no longer depends on the version string
and configuration system.  Any system that wants to present a message in
the log prolog can define its own trigger, which calls standard log
primitives to print the message.

Split the logging system into a front-end (log.c) that provides the
logging primitives and is independent of the configuration system, and a
set of back-end "outputters" (log_output_console.c, log_output_file.c,
log_output_android.c) that may depend on the configuration system and
are decoupled from the front-end using the 'logoutput' link section.

These log outputters are explicitly linked into executables by the
Makefile rules, but could also be linked in using USE_FEATURE().  The
USE_FEATURE() calls have _not_ been added to servald_features.c, so that
different daemon executables can be built with the same feature set but
different log outputs.
2018-03-06 15:16:56 +10:30
Andrew Bettison
cc016f7bf7 Fix two broken rhizomerestful tests
On Debian testing, it appears that curl(1) no longer sends an Expect:
100-continue header by default, so the test script must explicitly
supply it.
2017-11-21 15:11:48 +10:30
Jeremy Lakeman
ce2c276570 Detect Wifi and cabled ethernet on linux systems, allow matching by type in config 2017-11-07 16:53:19 +10:30
Andrew Bettison
68deae8393 Improve out-of-tree build support
Use the conventional autoconf @srcdir@ substitution instead of requiring
the SOURCE_PREFIX variable to be passed to the Makefile.

Also support running test scripts in an out-of-tree build directory.
2017-10-23 17:51:42 +10:30
Andrew Bettison
34e2e8d4bc Improve and document HTTP REST Rhizome import
The REST Rhizome import request now requires the 'id' and 'version'
query parameters to either both be supplied or neither, and fails if
they do not match the manifest that is supplied in the request body.
Added a test case for this.

Added a test case to ensure that if the 'id' and 'version' query
parameters cause a hit (already in store) then the response is sent
immediately without reading the request body.

Improve the documentation for the REST Rhizome import request.
2017-10-20 15:50:18 +10:30
Andrew Bettison
fc478d07ff Preserve curl trace files in all rhizomerestful test cases
These trace files make it easier to see the innards of REST
API requests and responses, which improves the value of tests
as API specification/documentation.
2017-10-20 09:47:34 +10:30
Jeremy Lakeman
3333d2faa2 Compare MeshMS sender first, so you can talk to yourself (Fixes #124) 2017-09-06 12:38:53 +09:30
Jeremy Lakeman
d1a1a41f08 Escape codepoints U+10000 to U+10FFFF in json output as surrogate pairs 2017-06-29 19:23:51 +09:30
Jeremy Lakeman
65932e05db Improve reliability of last routing test 2017-06-20 16:32:12 +09:30
Jeremy Lakeman
9cb561229a Allow following a feed that isn't in rhizome yet, and override the displayed name 2017-06-20 12:17:57 +09:30
Jeremy Lakeman
508e95436a Add API's for marking a feed as blocked 2017-06-07 13:52:44 +09:30
Jeremy Lakeman
af2d32c25b Add Java API for importing bundles with manifests in zip comments 2017-05-24 13:33:03 +09:30
Jeremy Lakeman
2db8c24e15 Use chunked transfer encoding and expect header in Java API 2017-05-23 11:37:26 +09:30
Jeremy Lakeman
77b603942f Support "Transfer-Encoding: chunked" for POST'ed content 2017-05-22 16:17:17 +09:30
Jeremy Lakeman
87d171cdf7 Reject rhizome import before sending manifest & payload 2017-05-17 14:55:56 +09:30
Jeremy Lakeman
e376c1cb80 Add proper server support for http/1.1 Expect header 2017-05-17 14:24:28 +09:30
Jeremy Lakeman
a473304c06 Add restful import API 2017-05-17 10:16:46 +09:30
Jeremy Lakeman
9b7d8bfa23 Resume activity newsince when acking our own message 2017-05-10 15:21:21 +09:30
Jeremy Lakeman
3812587a31 Ack the senders ply and thread into activity feed 2017-05-10 11:01:02 +09:30
Jeremy Lakeman
4b98def664 Add newsince request for incoming activity 2017-04-19 14:46:37 +09:30
Jeremy Lakeman
be9c138559 Add restful API for feed activity 2017-04-19 14:46:37 +09:30
Jeremy Lakeman
1973df13b3 cli interface for reading threaded feed activity 2017-04-19 14:46:37 +09:30
Jeremy Lakeman
5ccff053c2 Add bundle author to feed metadata 2017-04-19 14:46:36 +09:30
Jeremy Lakeman
d2dfe71f26 Restful meshmb list subscribed feeds 2017-04-19 14:46:36 +09:30
Jeremy Lakeman
e7ca268dbc Add restful API's for follow and ignore 2017-04-19 14:46:36 +09:30
Jeremy Lakeman
a8c29bbb15 Add MeshMB cli commands to follow and ignore feeds 2017-04-19 14:46:36 +09:30
Jeremy Lakeman
2f60b8417f Test and fix rhizome clean verify 2017-04-19 14:46:36 +09:30
Jeremy Lakeman
88d70fc386 Don't assert if a query parameter is empty 2017-03-22 13:04:58 +10:30
Jeremy Lakeman
77198dd163 Read earlier journal payload out of store 2017-03-08 13:37:26 +10:30
Jeremy Lakeman
585e573ecf Refactor rhizome storage methods to return database busy status, and pause rhizome sync 2017-03-06 16:12:55 +10:30
Jeremy Lakeman
2540c9e633 Cause rhizome add to poke the daemon and trigger all bundle add notifications 2017-03-06 16:12:55 +10:30
Jeremy Lakeman
3726fe2f73 Move vomp console feature to test binary 2016-11-21 11:09:27 +10:30
Andrew Bettison
e769af0067 Compile Java during make, not during tests
Re-organised all Java source code under the java-api subdirectory, which
also contains a Makefile.in that performs the Java compilation.  This
makefile is only invoked if ./configure finds a working Java compiler.
2016-11-14 11:28:08 +10:30
Andrew Bettison
a8e394d299 Add "keyring remove" command
Adds a CLI and RESTful API operation for "keyring remove", with simple
test cases.  Added the corresponding Java API operation.  Updated the
API documentation.

API change: for consistency with RESTful API design, the GET
/restful/keyring/add operation now returns "201 Created" not "200 OK" if
successful.
2016-11-07 13:07:49 +10:30
Jeremy Lakeman
f4210e06d8 Make sure all restful newsince responses can be sorted by the front end 2016-10-31 10:56:10 +10:30
Jeremy Lakeman
09d04d7c8f Add restful api for listing broadcast messages 2016-10-26 13:08:19 +10:30
Jeremy Lakeman
c2956568d6 Send a meshmb message via restful api 2016-10-26 13:08:13 +10:30