mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-10 01:49:32 +00:00
test(ssh): try disabling ssh
This commit is contained in:
parent
66561308bf
commit
f179cff0b4
|
@ -6,7 +6,7 @@ from selfprivacy_api.graphql.mutations.system_mutations import SystemMutations
|
||||||
from selfprivacy_api.graphql.queries.system import System
|
from selfprivacy_api.graphql.queries.system import System
|
||||||
|
|
||||||
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, get_data
|
from tests.test_graphql.common import assert_empty, assert_ok, get_data
|
||||||
|
|
||||||
|
|
||||||
class ProcessMock:
|
class ProcessMock:
|
||||||
|
@ -63,9 +63,9 @@ mutation addSshKey($sshInput: SshMutationInput!) {
|
||||||
"""
|
"""
|
||||||
|
|
||||||
API_SET_SSH_SETTINGS = """
|
API_SET_SSH_SETTINGS = """
|
||||||
mutation enableSsh($sshInput: SSHSettingsInput!) {
|
mutation enableSsh($settings: SSHSettingsInput!) {
|
||||||
system {
|
system {
|
||||||
changeSshSettings(sshInput: $sshInput) {
|
changeSshSettings(settings: $settings) {
|
||||||
success
|
success
|
||||||
message
|
message
|
||||||
code
|
code
|
||||||
|
@ -97,8 +97,26 @@ def api_ssh_settings(authorized_client):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def test_graphql_ssh_enabled_by_default(authorized_client, some_users):
|
def api_set_ssh_settings(authorized_client, enable: bool, password_auth: bool):
|
||||||
# TODO: Should it be enabled by default though if there are no keys anyway?
|
response = authorized_client.post(
|
||||||
|
"/graphql",
|
||||||
|
json={
|
||||||
|
"query": API_SET_SSH_SETTINGS,
|
||||||
|
"variables": {
|
||||||
|
"settings": {
|
||||||
|
"enable": enable,
|
||||||
|
"passwordAuthentication": password_auth,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
data = get_data(response)
|
||||||
|
result = data["system"]["changeSshSettings"]
|
||||||
|
assert result is not None
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def test_graphql_ssh_query(authorized_client, some_users):
|
||||||
settings = api_ssh_settings(authorized_client)
|
settings = api_ssh_settings(authorized_client)
|
||||||
assert settings["enable"] is True
|
assert settings["enable"] is True
|
||||||
assert settings["passwordAuthentication"] is True
|
assert settings["passwordAuthentication"] is True
|
||||||
|
@ -122,6 +140,13 @@ def test_graphql_change_ssh_settings_unauthorized(
|
||||||
assert_empty(response)
|
assert_empty(response)
|
||||||
|
|
||||||
|
|
||||||
|
def test_graphql_disable_ssh(authorized_client, some_users, mock_subprocess_popen):
|
||||||
|
output = api_set_ssh_settings(authorized_client, enable=False, password_auth=False)
|
||||||
|
assert_ok(output)
|
||||||
|
assert output["enable"] == False
|
||||||
|
assert output["passwordAuthentication"] == False
|
||||||
|
|
||||||
|
|
||||||
def test_graphql_add_ssh_key_unauthorized(client, some_users, mock_subprocess_popen):
|
def test_graphql_add_ssh_key_unauthorized(client, some_users, mock_subprocess_popen):
|
||||||
response = client.post(
|
response = client.post(
|
||||||
"/graphql",
|
"/graphql",
|
||||||
|
|
Loading…
Reference in a new issue