mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 04:01:27 +00:00
test(ssh): user key storage test: removing
This commit is contained in:
parent
0669dc117b
commit
7377c6375a
|
@ -373,30 +373,31 @@ def test_adding_user_key_writes_json(generic_userdata, username):
|
||||||
assert set(data["users"][user_index]["sshKeys"]) == set([key1, key2])
|
assert set(data["users"][user_index]["sshKeys"]) == set([key1, key2])
|
||||||
|
|
||||||
|
|
||||||
# @pytest.mark.parametrize("username", regular_users)
|
@pytest.mark.parametrize("username", regular_users)
|
||||||
# def test_removing_user_key_writes_json(generic_userdata, username):
|
def test_removing_user_key_writes_json(generic_userdata, username):
|
||||||
# # generic userdata has a a single root key
|
# generic userdata has a a single root key
|
||||||
# admin_name = "tester"
|
|
||||||
|
|
||||||
# admin_keys = get_user_by_username(admin_name).ssh_keys
|
user_keys = get_user_by_username(username).ssh_keys
|
||||||
# assert len(admin_keys) == 1
|
assert len(user_keys) == 1
|
||||||
# key1 = admin_keys[0]
|
key1 = user_keys[0]
|
||||||
# key2 = "ssh-rsa MYSUPERKEY admin@pc"
|
key2 = "ssh-rsa MYSUPERKEY admin@pc"
|
||||||
|
|
||||||
# create_ssh_key(admin_name, key2)
|
create_ssh_key(username, key2)
|
||||||
# admin_keys = get_user_by_username(admin_name).ssh_keys
|
user_keys = get_user_by_username(username).ssh_keys
|
||||||
# assert len(admin_keys) == 2
|
assert len(user_keys) == 2
|
||||||
|
|
||||||
# remove_ssh_key(admin_name, key2)
|
remove_ssh_key(username, key2)
|
||||||
|
|
||||||
# with ReadUserData() as data:
|
with ReadUserData() as data:
|
||||||
# assert "sshKeys" in data
|
user_index = find_user_index_in_json_users(data["users"], username)
|
||||||
# assert data["sshKeys"] == [key1]
|
assert "sshKeys" in data["users"][user_index]
|
||||||
|
assert data["users"][user_index]["sshKeys"] == [key1]
|
||||||
|
|
||||||
# remove_ssh_key(admin_name, key1)
|
remove_ssh_key(username, key1)
|
||||||
# with ReadUserData() as data:
|
with ReadUserData() as data:
|
||||||
# assert "sshKeys" in data
|
user_index = find_user_index_in_json_users(data["users"], username)
|
||||||
# assert data["sshKeys"] == []
|
assert "sshKeys" in data["users"][user_index]
|
||||||
|
assert data["users"][user_index]["sshKeys"] == []
|
||||||
|
|
||||||
|
|
||||||
# @pytest.mark.parametrize("username", regular_users)
|
# @pytest.mark.parametrize("username", regular_users)
|
||||||
|
|
Loading…
Reference in a new issue