Commit Graph

666 Commits

Author SHA1 Message Date
Sergi Delgado Segura
7e6a4849e6 Adds register unit tests, missing add and get appointment tests and sets MAX_APPOINTMENTS to 100 for testing 2020-03-27 14:58:35 +01:00
Sergi Delgado Segura
772f634d1f Sets MAX_APPOINTMENTS for Watcher unit tests to a small testable value (100) 2020-03-27 14:57:19 +01:00
Sergi Delgado Segura
3946599f91 Sets a more realistic valut for max_appointments and add default_slots in config 2020-03-27 14:57:19 +01:00
Sergi Delgado Segura
4c21326974 Moves slots added on register from gatekeeper to config 2020-03-27 14:57:11 +01:00
Sergi Delgado Segura
50c35a5ac1 Makes sure the received data in posts have the proper format and content 2020-03-27 14:04:37 +01:00
Sergi Delgado Segura
a19e4f2c2e Updates docs and comments in api 2020-03-27 13:11:27 +01:00
Sergi Delgado Segura
f9a3315cec Updates API unit tests 2020-03-27 12:08:04 +01:00
Sergi Delgado Segura
9e798916d1 Fixes API return HTTP return types and messages 2020-03-27 12:07:26 +01:00
Sergi Delgado Segura
2fcdc7eacc Removes public key from add_appointment requests 2020-03-26 19:06:39 +01:00
Sergi Delgado Segura
5d46049f31 Adapts Watcher unit tests to the new uuid apporach 2020-03-26 19:06:38 +01:00
Sergi Delgado Segura
a6f9cbf44e Prevents adding the same uuid twice in the map (appointment update) 2020-03-26 19:06:38 +01:00
Sergi Delgado Segura
4a8bd92144 Addapt Inspector unit tests to handle exceptions 2020-03-26 19:06:38 +01:00
Sergi Delgado Segura
3d8c0a9498 Applies new uuid apporach to the Watcher 2020-03-26 19:06:38 +01:00
Sergi Delgado Segura
460a98d42f Improves and simplifies the API by using the exceptions provided from the Inspector and Gatekeeper.
- Refactors and simplifies `add_appointment`
- Modifies `get_appointment` as a POST interface and to require user signatures.
- Defines a new way of creating uuids to avoid storing user_pu:uuids maps.
	- The uuids are now defined as RIPMED160(locator|user_pk) instead of using `uuid4`.
- Add missing docs and fixes the existing ones
2020-03-26 19:06:31 +01:00
Sergi Delgado Segura
9bc3bf2e6e Refactors and improves the gatekeeper
Following the same apporach as the Inspector, the gatekeeper now raises exceptions depending on the error encountered.
Also generalises `identify_user` so it can be used with any kind of user-signed message.
Finally lifts the restriction of having available slots on `identify_user` (that only applied to `add_appointent`).
2020-03-26 17:21:18 +01:00
Sergi Delgado Segura
bbe93ae3f1 Adds RIPMED160 hash function 2020-03-26 17:13:38 +01:00
Sergi Delgado Segura
b3d67b4ce3 Refactors Inspector so it returns exceptions for invalid data instead of error codes
Defines InspectionFailed, and exception that it's raised for invalid parameters. The design looks much cleaner now.
2020-03-26 17:10:16 +01:00
Sergi Delgado Segura
4fad6b7b6f Fixes docstring 2020-03-26 17:09:15 +01:00
Sergi Delgado Segura
f7260bc1ce Improves and simplifies add_appointment 2020-03-25 21:16:50 +01:00
Sergi Delgado Segura
83b3913cb5 Adds basic authentication logic.
+ Users need to be registered in order to send appointments (free registration for now)
+ The tower gives them a number of appointments to work with
+ Non-registered users and users with no enough appoitnemnts slots return the same error (to avoid proving)

- Authentication does not cover get_* requests yet
- No tests
- No docs
2020-03-25 17:13:35 +01:00
Sergi Delgado Segura
519caec29a Adds basic register logic
- Adds register endpoint in the API
- Adds the Gatekeeper to keep track of registered user and allow/reject access
- Adds registration errors
- Updates API unit tests
- Refactors some methods of the API to reduce code replication
2020-03-25 12:14:12 +01:00
Sergi Delgado Segura
dd53ad68fb Fixes bug when dealing with empty JSON requests or empty appointment field
When posting a request via requests.post the json field was dumped to json, but it shouldn't have been since requests deals with this internally. That meant that the requests made by the code didn't match proper JSON.
In line with this, the API was only parsing this type POST requests correctly, making add_appointment to fail if a proper formatted JSON was passed.

On top of that, empty appointments were not checked in the Inspector before trying to get data from them, making it crash if a JSON was posted to add_appointment not containing the `appointment` field. Unit tests for this should be added.
2020-03-24 20:17:03 +01:00
Sergi Delgado Segura
6ee04bd303 Sets add_appointment_endpoint from / to /add_appointment for consistency
Also passes the base_url to add_appointment and get_appointment and builds the full endpoint inside (also for consistency)
2020-03-24 19:03:41 +01:00
Sergi Delgado Segura
307fd7dabf Merge pull request #113 from bjarnemagnussen/master
cli: fixes testing for `ConnectionError` in `get_appointment`
2020-03-24 19:00:37 +01:00
Sergi Delgado Segura
7a3996e916 Merge branch 'master' into master 2020-03-24 18:31:54 +01:00
Sergi Delgado Segura
9056f95f5c Merge pull request #115 from talaia-labs/commit-signing-contributing
Adds commit signing section on CONTRIBUTING
2020-03-24 18:29:44 +01:00
Sergi Delgado Segura
284c0314e7 Adds commit signing section on CONTRIBUTING 2020-03-24 18:26:39 +01:00
Bjarne Magnussen
8ef7b44fd0 cli: fixes testing for ConnectionError in get_appointment 2020-03-24 18:25:32 +01:00
Sergi Delgado Segura
8d2c17884a Merge pull request #112 from talaia-labs/111-docs-typo
Fixes path typo on README
2020-03-24 09:41:05 +01:00
Sergi Delgado Segura
973b8e7d1d close #111 2020-03-24 09:34:23 +01:00
Sergi Delgado Segura
541020dff7 Merge pull request #109 from talaia-labs/100-improve-config
Improves config file format
2020-03-23 17:39:45 +01:00
Sergi Delgado Segura
6096fe5dc5 Fixes config templates
Removes quotation marks ("") from strings in the template config files
2020-03-23 17:25:52 +01:00
Sergi Delgado Segura
d2fbcf61e3 Updates READMEs with the new config file apporach 2020-03-23 17:15:46 +01:00
Sergi Delgado Segura
d21e947e05 Moves cli show_usage to help.py 2020-03-23 17:15:46 +01:00
Sergi Delgado Segura
3c6f7cf15f Adds teosd command line help 2020-03-23 17:15:46 +01:00
Sergi Delgado Segura
4071a689af Updates e2e to match 635da6447d887d7df9387e1eda63eda2e9a7d577 2020-03-23 17:15:46 +01:00
Sergi Delgado Segura
f5edaf1bf0 Fixes default HOST to remove the schema from config
The schema now defaults to http if none is defined. Also improves some of the cli docstrings
2020-03-23 17:15:43 +01:00
Sergi Delgado Segura
02eefd5807 Moves extend paths from tools to ConfigLoader 2020-03-23 13:04:50 +01:00
Sergi Delgado Segura
e2ce7ae1a4 Adds missing ConfigLoader unit tests 2020-03-23 12:35:29 +01:00
Sergi Delgado Segura
bc9c1a37f2 Properly sets conf for e2e on bitcoin-cli
bitcoin-cli on e2e tests was getting the conf straight from the default, but on circle-cli it should be data from the conf file. Setting it right.
2020-03-23 12:06:49 +01:00
Sergi Delgado Segura
8316892ef2 Uses path.join for safely join paths on common/tools 2020-03-23 12:05:39 +01:00
Sergi Delgado Segura
d622827de8 Changes e2e teos config file format and updates circleci conf 2020-03-23 11:33:35 +01:00
Sergi Delgado Segura
09f32b09aa Creates data_dir when generating keys if it does not exist 2020-03-23 11:16:49 +01:00
Sergi Delgado Segura
01ad0d4cdf Adds some ConfigLoader unit tests 2020-03-23 11:16:32 +01:00
Sergi Delgado Segura
27e249e665 Adds missing try/catch when casting data from config file in ConfigLoader 2020-03-22 19:09:48 +01:00
Sergi Delgado Segura
e9f442d419 Refactors e2e tests to match the new config approach 2020-03-21 22:52:38 +01:00
Sergi Delgado Segura
6595c2d790 Avoids global variables in teosd for better testing 2020-03-21 22:52:16 +01:00
Sergi Delgado Segura
2587e25637 Adds cli unit tests 2020-03-21 22:13:33 +01:00
Sergi Delgado Segura
3d389a92ac Refactors cli to use the new config approach. Adds template.conf 2020-03-21 22:13:22 +01:00
Sergi Delgado Segura
00a48ce6f5 Modifies ConfigParser so config file is passed as parameter (to be used by both teos and cli)
- Modifies ConfigParser
- Adapts __init__ and teosd at teos/
2020-03-21 22:02:46 +01:00