Commit Graph

42 Commits

Author SHA1 Message Date
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
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
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
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
a531c0e960 Use a random walk to find free keyring slots
Always round the file size up to the nearest 16 slots
2016-09-20 16:47:30 +09:30
Jeremy Lakeman
275c99bc4e Add cli option for changing an entry pin 2016-09-20 10:00:02 +09:30
Andrew Bettison
43bd0bd33f Fix a failing keyring test
The in-memory identity creation test was failing intermittently because
the server only creates the in-memory identity on the first tick, and
under load the server sometimes does not tick for a while, leading to a
race with the "servald id self" command.

The test case now waits for the server to emit a tick before running the
"id self" command.  This necessitated a new DEBUG() statement and a new
debug flag 'overlaytick'.

Also disabled Rhizome for all the keyring tests, as unnecessary Rhizome
DB creation was slowing down the fixtures.
2016-09-06 15:00:21 +09:30
Andrew Bettison
2cfdafdb56 Add some MDP client DEBUG trace statements 2016-09-06 13:31:38 +09:30
Jeremy Lakeman
b6256ea89a Add identity_t type & rename signing key api to identity. 2016-08-16 12:22:13 +09:30
Jeremy Lakeman
83b6ecb453 Roll an in memory identity when the keyring is empty 2016-08-02 11:01:32 +09:30
Andrew Bettison
586c6b3060 Add HTTP GET /restful/keyring/add 2015-08-10 18:13:57 +09:30
Jeremy Lakeman
032502f80c keyring create test now does what it says (and fails) 2015-01-17 21:57:59 +10:30
Jeremy Lakeman
6ab2cc5bb6 Only support one keyring pin per open file 2014-10-31 15:30:07 +10:30
Jeremy Lakeman
46ef40cf23 Migrate and refactor more interfaces from batphone 2014-02-19 15:35:08 +10:30
Andrew Bettison
4062b3adbf Fix typos in 'keyring' test suite 2014-02-17 17:13:58 +10:30
Jeremy Lakeman
0b404b0260 Implement id list command 2013-11-13 12:00:46 +10:30
Jeremy Lakeman
ff1f1ff093 Allow tag primitives to be used outside of keyring entries 2013-11-13 12:00:05 +10:30
Jeremy Lakeman
9680b24f23 Add support for adding and updating tags in the keyring 2013-11-13 11:59:21 +10:30
Jeremy Lakeman
534b01ba2a Add explicit set did test 2013-11-13 11:52:46 +10:30
Jeremy Lakeman
d5d5737f1c Rename 'id revoke' to 'id relinquish' to match documentation 2013-10-15 14:52:07 +10:30
Jeremy Lakeman
ef7351bddc Unload identities from a running daemon 2013-10-10 14:27:00 +10:30
Jeremy Lakeman
ae7e120ed5 Pass keyring entry pin to running daemon and unlock identities 2013-10-09 15:34:41 +10:30
Andrew Bettison
7add45214c Add [keyring-pin] arg to keyring load command 2013-09-10 11:28:55 +09:30
Andrew Bettison
e74aec9354 Tests for starting daemon with keyring entry PINs 2013-09-09 14:47:02 +09:30
Andrew Bettison
d177512746 Add test for server start with --keyring-pin option 2013-09-09 14:47:02 +09:30
Andrew Bettison
18e2916cec Add more keyring load tests, fix duplicate identity bugs 2013-09-07 04:03:28 +09:30
Andrew Bettison
8a300c2520 Get new keyring dump command and test working 2013-09-05 16:34:01 +09:30
Andrew Bettison
4b0550afd1 Fix new keyring load test 2013-09-05 09:19:45 +09:30
Andrew Bettison
f95e41374b Implement keyring load command, not working yet
Write new keyring test, fails with ERROR because assertGrep -F option is
not supported.
2013-09-04 23:47:17 +09:30
Andrew Bettison
9d1c3e0cba Fix test case doc comment 2013-09-03 17:05:50 +09:30
Andrew Bettison
572d7c2b5d Add tests for new keyring environment vars 2013-08-30 11:20:19 +09:30
Andrew Bettison
cf26a77019 Use "keyring dump" command in back-compatible keyring test 2013-04-30 17:56:10 +09:30
Andrew Bettison
deed4665fe Fix keyring test copyright and header comments 2013-04-29 17:38:01 +09:30
Andrew Bettison
78b3a3a8c4 Add keyring test case (combined PINs) 2013-04-29 16:00:17 +09:30
Andrew Bettison
ae69da284f Add keyring back-compatibility test case 2013-04-29 15:11:04 +09:30
Andrew Bettison
6fd49099cb Rewrite keyring pack/unpack for extensibility
Use new rotbuf primitives to handle rotated buffers
2013-04-29 14:31:50 +09:30
Andrew Bettison
bc7c58ee3c Improve keyring test case 2013-03-06 15:29:27 +10:30
Andrew Bettison
03f38d2031 Improve keyring debugging 2013-03-06 14:15:27 +10:30
Jeremy Lakeman
9e2eb1aea4 Add keyring test for implicitly created identity 2013-02-28 16:27:53 +10:30
Andrew Bettison
f66a894a63 Improve keyring PIN handling
Replace explicit [<pin,pin...>] command-line arguments with --entry-pin=<pin>
options.  Update test scripts accordlingly.

Add --keyring-pin=<pin> option (with one test case).
2013-02-13 16:49:52 +10:30
Andrew Bettison
b2923744b0 Add 'keyring' test script with three basic tests 2013-02-11 18:41:36 +10:30