diff --git a/tests/test_graphql/test_ssh.py b/tests/test_graphql/test_ssh.py index 766b059..dc436cb 100644 --- a/tests/test_graphql/test_ssh.py +++ b/tests/test_graphql/test_ssh.py @@ -9,7 +9,7 @@ from selfprivacy_api.graphql.queries.system import System from selfprivacy_api.actions.ssh import remove_ssh_key, get_ssh_settings from tests.common import read_json, generate_system_query -from tests.test_graphql.common import assert_empty, assert_ok, get_data +from tests.test_graphql.common import assert_empty, assert_ok, get_data, assert_errorcode class ProcessMock: @@ -369,6 +369,13 @@ def test_graphql_add_root_ssh_key_one_more(authorized_client, no_rootkeys): assert output["user"]["sshKeys"] == expected_keys assert api_rootkeys(authorized_client) == expected_keys +def test_graphql_add_root_ssh_key_same(authorized_client, no_rootkeys): + key = "ssh-rsa KEY test_key@pc" + output = api_add_ssh_key(authorized_client, "root", key) + assert output["user"]["sshKeys"] == [key] + + output = api_add_ssh_key(authorized_client, "root", key) + assert_errorcode(output, 409) def test_graphql_add_main_ssh_key(authorized_client, some_users, mock_subprocess_popen): response = authorized_client.post( diff --git a/tests/test_rest_endpoints/services/test_ssh.py b/tests/test_rest_endpoints/services/test_ssh.py index 5045149..56a4020 100644 --- a/tests/test_rest_endpoints/services/test_ssh.py +++ b/tests/test_rest_endpoints/services/test_ssh.py @@ -92,20 +92,6 @@ def some_users(mocker, datadir): return datadir -## PUT ON /ssh/key/send ###################################################### - -def test_add_existing_root_key(authorized_client, root_and_admin_have_keys): - response = authorized_client.put( - "/services/ssh/key/send", json={"public_key": "ssh-ed25519 KEY test@pc"} - ) - assert response.status_code == 409 - assert read_json(root_and_admin_have_keys / "root_and_admin_have_keys.json")["ssh"][ - "rootKeys" - ] == [ - "ssh-ed25519 KEY test@pc", - ] - - ## /ssh/keys/{user} ######################################################