mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 13:31:27 +00:00
test(ssh): dealing with undefined users
This commit is contained in:
parent
42d96bcd6d
commit
946413615b
|
@ -6,7 +6,7 @@ from tests.common import (
|
|||
generate_users_query,
|
||||
read_json,
|
||||
)
|
||||
from tests.test_graphql.common import assert_empty
|
||||
from tests.test_graphql.common import assert_empty, assert_errorcode
|
||||
|
||||
invalid_usernames = [
|
||||
"messagebus",
|
||||
|
@ -170,6 +170,23 @@ def test_graphql_get_no_users(authorized_client, no_users, mock_subprocess_popen
|
|||
]
|
||||
|
||||
|
||||
def test_graphql_get_users_undefined(authorized_client, undefined_settings):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
json={
|
||||
"query": generate_users_query([API_USERS_INFO]),
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert response.json().get("data") is not None
|
||||
|
||||
assert len(response.json()["data"]["users"]["allUsers"]) == 1
|
||||
assert response.json()["data"]["users"]["allUsers"][0]["username"] == "tester"
|
||||
assert response.json()["data"]["users"]["allUsers"][0]["sshKeys"] == [
|
||||
"ssh-rsa KEY test@pc"
|
||||
]
|
||||
|
||||
|
||||
API_GET_USERS = """
|
||||
query TestUsers($username: String!) {
|
||||
users {
|
||||
|
@ -216,6 +233,23 @@ def test_graphql_get_one_user(authorized_client, one_user, mock_subprocess_popen
|
|||
]
|
||||
|
||||
|
||||
def test_graphql_get_some_user_undefined(authorized_client, undefined_settings):
|
||||
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
json={
|
||||
"query": API_GET_USERS,
|
||||
"variables": {
|
||||
"username": "user1",
|
||||
},
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert response.json().get("data") is not None
|
||||
|
||||
assert response.json()["data"]["users"]["getUser"] is None
|
||||
|
||||
|
||||
def test_graphql_get_some_user(authorized_client, some_users, mock_subprocess_popen):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
|
|
|
@ -95,11 +95,6 @@ def some_users(mocker, datadir):
|
|||
## /ssh/keys/{user} ######################################################
|
||||
|
||||
|
||||
def test_get_keys_of_undefined_users(authorized_client, undefined_settings):
|
||||
response = authorized_client.get("/services/ssh/keys/user1")
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
@pytest.mark.parametrize("user", [1, 2, 3])
|
||||
def test_add_user_key(authorized_client, some_users, user):
|
||||
response = authorized_client.post(
|
||||
|
|
Loading…
Reference in a new issue