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