Skip to content

Commit cb0a5aa

Browse files
committed
Final update of TODOs before moving on.
1 parent 7f5c065 commit cb0a5aa

5 files changed

Lines changed: 41 additions & 34 deletions

File tree

TODO

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
1-
TODO: Stop all nodes after each test (to make sure they are stopped if test case fails)
1+
TODO: Stop all nodes after each test (to make sure they are stopped if test case fails).
22

3-
TODO: Type annotations everywhere
3+
TODO: Type annotations everywhere; check type annotations in check script.
44

5-
TODO: Check type annotations (in check script and in VSC)
5+
TODO: Better OpenAPI (Swagger) documentation:
6+
- Better type information
7+
- Better explanations
8+
- All error responses
69

7-
TODO: OpenAPI (Swagger) documentation should show proper type for request and response data
8-
9-
TODO: Add test case: start hub later than client (registration retry logic in client)
10-
11-
TODO: Forbid extra query parameters for API calls
12-
For example foobar in:
13-
curl 'http://127.0.0.1:8105/client/carol/etsi/api/v1/keys/curtis/enc_keys?foobar=256'
14-
See https://fastapi.tiangolo.com/tutorial/query-param-models/#forbid-extra-query-parameters
15-
16-
TODO: nr_required_shares -> required_nr_shares or min_nr_shares
17-
18-
TODO: I noticed that the response to a POST key-share is the string null; that's not right
19-
20-
TODO: Testcase for invalid signature
21-
- Bad allocation string
22-
- Signature is incorrect
23-
- Make sure bytes taken from pool are returned (to defend against DOS attack)
24-
25-
TODO: Test case for: if signature validation fails, return fragment to pool
26-
27-
TODO: Test cases for delete share after timeout
10+
TODO: Additional test cases (coverage closer to 100%):
11+
- Start hub later than client
12+
- Invalid signatures (also return allocation to pool)
13+
- Pool allocations after give-backs

common/tests/test_fragment.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ def test_from_api_bad_block_uuid():
114114
_fragment = Fragment.from_api(api_fragment, pool)
115115

116116

117-
# TODO: Add test case: start outside of block
118-
# TODO: Add test case: size too large for block
119-
120-
121117
def test_to_enc_str():
122118
"""
123119
Create an encoded string from a Fragment.

common/tests/test_pool.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ def test_allocate_success_empty_pool_first_block_full_second_block_full():
125125
assert pool.nr_used_bytes == 9
126126

127127

128-
# TODO: Also test re-allocation after giving back
129-
130-
131128
def test_allocate_failure_insufficient_space():
132129
"""
133130
Attempt to allocate an allocation from a pool. There is not enough unused data in the pool.

common/tests/test_shamir.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,3 @@ def test_shamir_split_reconstruct_all_scenarios():
3939
(10, 3),
4040
]:
4141
shamir_split_reconstruct_scenario(size, nr_shares, min_shares)
42-
43-
# TODO: Key length 3 (< MIN_KEY_LENGTH) raises exception

system_tests/test_share_storage.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
Test share storage at hubs.
33
"""
44

5+
from time import sleep
56
import httpx
67
import pytest
8+
from common.configuration import DEFAULT_SHARE_TIMEOUT_SECS
79
from . import system_test_common
810

911

@@ -19,7 +21,9 @@ def setup_and_teardown():
1921

2022
def test_shares_on_hubs():
2123
"""
22-
Test that getting a key on the master client results in shares being created on the hubs.
24+
Test that getting a key on the master client results in shares being created on the hubs,
25+
and that getting a with with key IDs on the slave client removes the shares (normally, unless
26+
the slave SAE ID is incorrect).
2327
"""
2428
# Pylint complains this looks too much like test_etsi_qkd
2529
# pylint: disable=duplicate-code
@@ -57,3 +61,29 @@ def test_shares_on_hubs():
5761
assert "shares" in status
5862
shares = status["shares"]
5963
assert len(shares) == 0
64+
65+
66+
def test_shares_on_hubs_timeout():
67+
"""
68+
Test that shares are removed from hubs after their timeout expires (i.e. the slave client
69+
does not get the key with key IDs in time).
70+
"""
71+
# Get key on master client
72+
key_id = system_test_common.get_key("sam", "sunny")
73+
# There should be a share stored one each hub (we only check hank)
74+
status = system_test_common.status_node("hub", "hank")
75+
assert "shares" in status
76+
shares = status["shares"]
77+
assert len(shares) == 1
78+
share = shares[0]
79+
assert share["key_id"] == key_id
80+
assert share["master_sae_id"] == "sam"
81+
assert share["slave_sae_id"] == "sunny"
82+
assert share["share_index"] == 0
83+
# Wait for share to timeout
84+
sleep(DEFAULT_SHARE_TIMEOUT_SECS + 10)
85+
# The share should be removed from the hub
86+
status = system_test_common.status_node("hub", "hank")
87+
assert "shares" in status
88+
shares = status["shares"]
89+
assert len(shares) == 0

0 commit comments

Comments
 (0)