22Test share storage at hubs.
33"""
44
5+ from time import sleep
56import httpx
67import pytest
8+ from common .configuration import DEFAULT_SHARE_TIMEOUT_SECS
79from . import system_test_common
810
911
@@ -19,7 +21,9 @@ def setup_and_teardown():
1921
2022def 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