def test_key_in_secret(fs, monkeypatch): env = { "GROUP1_TOR_SERVICE_HOSTS": "80:service1:80", "GROUP2_TOR_SERVICE_HOSTS": "80:service2:80", "GROUP3_TOR_SERVICE_HOSTS": "80:service3:80", "GROUP3_TOR_SERVICE_VERSION": "3", } monkeypatch.setattr(os, "environ", env) key_v2, onion_url_v2 = get_key_and_onion() key_v3, onion_url_v3 = get_key_and_onion(version=3) fs.create_file("/run/secrets/group1", contents=key_v2) fs.create_file("/run/secrets/group3", contents=b64decode(key_v3)) onion = Onions() onion._get_setup_from_env() onion._load_keys_in_services() group1 = onion.find_group_by_name("group1") group2 = onion.find_group_by_name("group2") group3 = onion.find_group_by_name("group3") assert group1.onion_url == onion_url_v2 assert group2.onion_url not in [onion_url_v2, onion_url_v3] assert group3.onion_url == onion_url_v3
def test_key_in_secret(fs, monkeypatch): env = { 'GROUP1_TOR_SERVICE_HOSTS': '80:service1:80', 'GROUP2_TOR_SERVICE_HOSTS': '80:service2:80', 'GROUP3_TOR_SERVICE_HOSTS': '80:service3:80', 'GROUP3_TOR_SERVICE_VERSION': '3', } monkeypatch.setattr(os, 'environ', env) key_v2, onion_url_v2 = get_key_and_onion() key_v3, onion_url_v3 = get_key_and_onion(version=3) fs.create_file('/run/secrets/group1', contents=key_v2) fs.create_file('/run/secrets/group3', contents=b64decode(key_v3)) onion = Onions() onion._get_setup_from_env() onion._load_keys_in_services() group1 = onion.find_group_by_name('group1') group2 = onion.find_group_by_name('group2') group3 = onion.find_group_by_name('group3') assert group1.onion_url == onion_url_v2 assert group2.onion_url not in [onion_url_v2, onion_url_v3] assert group3.onion_url == onion_url_v3
def test_key_in_secret(fs, monkeypatch): env = { 'SERVICE1_SERVICE_NAME': 'group1', 'SERVICE2_SERVICE_NAME': 'group1', 'SERVICE3_SERVICE_NAME': 'group2', 'SERVICE1_PORTS': '80:80', 'SERVICE2_PORTS': '81:80,82:8000', 'SERVICE3_PORTS': '80:unix://unix.socket', } monkeypatch.setattr(os, 'environ', env) key, onion_url = get_key_and_onion() fs.CreateFile('/run/secrets/group1', contents=key) onion = Onions() onion._get_setup_from_env() group1 = onion.find_group_by_name('group1') group2 = onion.find_group_by_name('group2') # assert group._priv_key == key assert group1.onion_url == onion_url assert group2.onion_url != onion_url