22Test share storage at hubs.
33"""
44
5+ import httpx
56import pytest
67from . import system_test_common
78
@@ -16,17 +17,41 @@ def setup_and_teardown():
1617 system_test_common .stop_topology ()
1718
1819
19- def test_get_key_creates_shares_on_hubs ():
20+ def test_shares_on_hubs ():
2021 """
2122 Test that getting a key on the master client results in shares being created on the hubs.
2223 """
23- key_id = system_test_common .get_key ("sam" , "sofia" )
24+ # Get key on master client
25+ key_id = system_test_common .get_key ("sam" , "sunny" )
26+ # There should be a share stored one each hub (we only check hank)
2427 status = system_test_common .status_node ("hub" , "hank" )
2528 assert "shares" in status
2629 shares = status ["shares" ]
2730 assert len (shares ) == 1
2831 share = shares [0 ]
2932 assert share ["key_id" ] == key_id
3033 assert share ["master_sae_id" ] == "sam"
31- assert share ["slave_sae_id" ] == "sofia "
34+ assert share ["slave_sae_id" ] == "sunny "
3235 assert share ["share_index" ] == 0
36+ # Incorrect get key with key IDS on slave client (wrong master SAE ID)
37+ curtis_port = 8109
38+ url = (
39+ f"http://127.0.0.1:{ curtis_port } "
40+ f"/client/curtis/etsi/api/v1/keys/sam/dec_keys?" # All correct
41+ f"key_ID={ key_id } "
42+ )
43+ result = httpx .get (url , headers = {"Authorization" : "susan" }) # Wrong slave SAE ID
44+ assert result .status_code == 400
45+ assert "Slave SAE ID does not match" in result .text
46+ # Share was not removed
47+ status = system_test_common .status_node ("hub" , "hank" )
48+ assert "shares" in status
49+ shares = status ["shares" ]
50+ assert len (shares ) == 1
51+ # Correct get key with key IDS on slave client
52+ system_test_common .get_key_with_key_ids ("sam" , "sunny" , key_id )
53+ # The share should be removed from the hub
54+ status = system_test_common .status_node ("hub" , "hank" )
55+ assert "shares" in status
56+ shares = status ["shares" ]
57+ assert len (shares ) == 0
0 commit comments