mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-18 08:29:14 +00:00
Delete rootKeys field instead of adding empty element
This commit is contained in:
parent
4cbb08cb6e
commit
6cd896f977
|
@ -68,7 +68,7 @@ def create_app(test_config=None):
|
|||
def spec():
|
||||
if app.config["ENABLE_SWAGGER"] == "1":
|
||||
swag = swagger(app)
|
||||
swag["info"]["version"] = "1.2.1"
|
||||
swag["info"]["version"] = "1.2.2"
|
||||
swag["info"]["title"] = "SelfPrivacy API"
|
||||
swag["info"]["description"] = "SelfPrivacy API"
|
||||
swag["securityDefinitions"] = {
|
||||
|
|
|
@ -23,4 +23,4 @@ class ApiVersion(Resource):
|
|||
401:
|
||||
description: Unauthorized
|
||||
"""
|
||||
return {"version": "1.2.1"}
|
||||
return {"version": "1.2.2"}
|
||||
|
|
|
@ -357,9 +357,9 @@ class SSHKeys(Resource):
|
|||
for key in data["ssh"]["rootKeys"]:
|
||||
if key == args["public_key"]:
|
||||
data["ssh"]["rootKeys"].remove(key)
|
||||
# If rootKeys became zero length, add empty string
|
||||
# If rootKeys became zero length, delete it
|
||||
if len(data["ssh"]["rootKeys"]) == 0:
|
||||
data["ssh"]["rootKeys"].append("")
|
||||
del data["ssh"]["rootKeys"]
|
||||
return {
|
||||
"message": "SSH key deleted",
|
||||
}, 200
|
||||
|
|
2
setup.py
2
setup.py
|
@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|||
|
||||
setup(
|
||||
name="selfprivacy_api",
|
||||
version="1.2.1",
|
||||
version="1.2.2",
|
||||
packages=find_packages(),
|
||||
scripts=[
|
||||
"selfprivacy_api/app.py",
|
||||
|
|
|
@ -305,9 +305,12 @@ def test_delete_root_key(authorized_client, root_and_admin_have_keys):
|
|||
"/services/ssh/keys/root", json={"public_key": "ssh-ed25519 KEY test@pc"}
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert read_json(root_and_admin_have_keys / "root_and_admin_have_keys.json")["ssh"][
|
||||
assert (
|
||||
"rootKeys"
|
||||
] == [""]
|
||||
not in read_json(root_and_admin_have_keys / "root_and_admin_have_keys.json")[
|
||||
"ssh"
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def test_delete_root_nonexistent_key(authorized_client, root_and_admin_have_keys):
|
||||
|
|
Loading…
Reference in a new issue