Commit Graph

795 Commits

Author SHA1 Message Date
Sergi Delgado Segura
a46bab6b20 Adds user database and modifies registered_user content to be a dict instead of an int
Future additional data may be stored, so it's better if we store it as something that can hold it
2020-04-01 18:25:14 +02:00
Sergi Delgado Segura
4a3f4bc522 Addapts tests to match 7031b552f7. Improves DBManager tests. 2020-04-01 17:19:41 +02:00
Sergi Delgado Segura
7031b552f7 Splits DBManager in parent and child classes so a UserDBManager can be implemented
- DBManager preserves the basic methods, while the appointment related ones have been moved to AppointmentDBM.
- AppointmentDBM handles json loads and dumps for appointments and trackers, so the corresponding methods can be removed from their classes.
- Updates docs.
2020-04-01 17:18:37 +02:00
Sergi Delgado Segura
0e392d1f2a Cryptographer.sigrec_decode assumed signatures where properly encoded.
- Fixes a bug in sigrec_decode where the decoding function assumend that the first by was formatted as 31 + SigRec. Non properly encoded signatures made the function to crash due to an overflow (int_to_bytes(x) for negative x)
2020-04-01 17:04:33 +02:00
Sergi Delgado Segura
2d67fe8638 rpc_passwd -> rpc_password. The former can be confusing since the bitcoind parameter is rpcpassword. Avoiding that. 2020-04-01 11:14:20 +02:00
Sergi Delgado Segura
18e9a0fe5f Removes 2kib restriction from readmes 2020-03-31 17:51:19 +02:00
Sergi Delgado Segura
94be7acceb Defines minimal version of both openssl and python3 in DEPENDENCIES. Close #116. 2020-03-31 17:47:07 +02:00
Sergi Delgado Segura
0364dba5ca Fixes e2e tests to match the user authentication apporach
Last two tests are patched, user data must be stored between restarts
2020-03-31 16:56:52 +02:00
Sergi Delgado Segura
bf0ae36940 Removes old commented code 2020-03-31 16:55:40 +02:00
Sergi Delgado Segura
3e32d8a85e Fixes typo in variable and inconsistent return type 2020-03-31 16:54:52 +02:00
Sergi Delgado Segura
502f507b21 Adds missing size field in Builder when loading data from the database 2020-03-31 15:00:30 +02:00
Sergi Delgado Segura
b56123055d Adds flake8 and fixes style issues 2020-03-31 13:06:44 +02:00
Sergi Delgado Segura
03c8ad8c87 Improves API testing. Mocks data moving from Watcher/Responder instead of running them in the background. Closes #77. 2020-03-31 11:07:01 +02:00
Sergi Delgado Segura
31a25f3f60 Adds unit tests for register, and adaps existing tests to match the changes in the commands 2020-03-30 22:24:20 +02:00
Sergi Delgado Segura
f8cc099696 Adds register command to cli, modifies get_appointment to work with POST, refactors cli to improve modularity and cleaning the code
- Adds register command
- Modifies get_appointment command to work with POST + adds signature
- Avoids passing config dict to functions if not necessary (passing single parameters instead)
- Moves key loading to main since most of the commands will need the keys now
- Refactors post_appointment and process_post_appointment_request to work with any post request, so it can be reused for both register and get_appointment
- Functions have been rearanged in a more logical order
- Error handling has been improved
2020-03-30 22:20:01 +02:00
Sergi Delgado Segura
746a78542f Adds missing tests to API and improves API testing by properly mocking the requests. Closes #77 2020-03-30 22:16:39 +02:00
Sergi Delgado Segura
354724075e Moves route assignment to API constructor so it can be properly tested 2020-03-30 22:16:22 +02:00
Sergi Delgado Segura
9ecf98e0c5 Adds tests for appointments updates of different sizes 2020-03-30 22:16:21 +02:00
Sergi Delgado Segura
c9b3bb625f Fixes slots difference calculation 2020-03-30 22:15:59 +02:00
Sergi Delgado Segura
93a389508e Adds checks of decreasing slots for added appointments 2020-03-30 16:35:45 +02:00
Sergi Delgado Segura
f55e37b0fc Adds unit test for watcher.get_appointment_summary 2020-03-30 16:22:52 +02:00
Sergi Delgado Segura
495ea3800e Fixes get_appointment response structure: {"locator": l, "status": s, "data": appointment_data} 2020-03-30 16:22:38 +02:00
Sergi Delgado Segura
709a40dc64 Fixes gatekeeper and common/tools tests according to 33966e59e1 2020-03-30 13:08:24 +02:00
Sergi Delgado Segura
c0ada5f818 Improves logging messages 2020-03-30 13:06:35 +02:00
Sergi Delgado Segura
33966e59e1 Moves (and renames) check_user_pk to common so cli can use it too. Fixes the regex so it only accepts {02, 03} as prefix 2020-03-30 13:06:01 +02:00
Sergi Delgado Segura
e924b57efc Appointment updates only do not decrease slots if not necessary
- For a given appointment, checks if it is an update and computes the difference of sizes if so.
- Additional slots are only filled if the new version is bigger. Slots are freed if the update is smaller.
- Adds get_appoiment_summary to get information in memory information of an appointment (so the API can check if a request is an update)
	- The API computes the uuid and requests it to the tower.
	- Size field has been added to all in memory appointments
2020-03-30 12:49:53 +02:00
Sergi Delgado Segura
02fd2e5149 Adds gatekeeper unit tests 2020-03-27 17:28:12 +01:00
Sergi Delgado Segura
6547e75a19 Adds user exist restriction to fill/free slots and update comments/docs 2020-03-27 17:28:07 +01:00
Sergi Delgado Segura
ae68cd33da Captures TypeErrors in Cryptographer.get_compressed_pk and adds unit tests 2020-03-27 16:50:47 +01:00
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