mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-29 07:21:27 +00:00
test(ssh): adding same key
This commit is contained in:
parent
4b51f42e1b
commit
641959a083
|
@ -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 selfprivacy_api.actions.ssh import remove_ssh_key, get_ssh_settings
|
||||||
|
|
||||||
from tests.common import read_json, generate_system_query
|
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:
|
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 output["user"]["sshKeys"] == expected_keys
|
||||||
assert api_rootkeys(authorized_client) == 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):
|
def test_graphql_add_main_ssh_key(authorized_client, some_users, mock_subprocess_popen):
|
||||||
response = authorized_client.post(
|
response = authorized_client.post(
|
||||||
|
|
|
@ -92,20 +92,6 @@ def some_users(mocker, datadir):
|
||||||
return 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} ######################################################
|
## /ssh/keys/{user} ######################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue