Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arch Linux
aurweb
Commits
ff92e95f
Verified
Commit
ff92e95f
authored
Nov 21, 2022
by
Leonidas Spyropoulos
Browse files
fix: delete associated ssh public keys with account deletion
Signed-off-by:
Leonidas Spyropoulos
<
artafinde@archlinux.org
>
parent
bce5b81a
Pipeline
#39783
passed with stages
in 2 minutes and 10 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
aurweb/models/ssh_pub_key.py
View file @
ff92e95f
...
...
@@ -13,7 +13,7 @@ class SSHPubKey(Base):
User
=
relationship
(
"User"
,
backref
=
backref
(
"ssh_pub_keys"
,
lazy
=
"dynamic"
),
backref
=
backref
(
"ssh_pub_keys"
,
lazy
=
"dynamic"
,
cascade
=
"all, delete"
),
foreign_keys
=
[
__table__
.
c
.
UserID
],
)
...
...
test/test_accounts_routes.py
View file @
ff92e95f
...
...
@@ -2032,6 +2032,37 @@ def test_account_delete_self(client: TestClient, user: User):
assert
record
is
None
def
test_account_delete_self_with_ssh_public_key
(
client
:
TestClient
,
user
:
User
):
username
=
user
.
Username
with
db
.
begin
():
db
.
create
(
SSHPubKey
,
User
=
user
,
Fingerprint
=
"testFingerprint"
,
PubKey
=
"testPubKey"
)
# Confirm that we can view our own account deletion page
cookies
=
{
"AURSID"
:
user
.
login
(
Request
(),
"testPassword"
)}
endpoint
=
f
"/account/
{
username
}
/delete"
with
client
as
request
:
resp
=
request
.
get
(
endpoint
,
cookies
=
cookies
)
assert
resp
.
status_code
==
HTTPStatus
.
OK
# Supply everything correctly and delete ourselves
with
client
as
request
:
resp
=
request
.
post
(
endpoint
,
data
=
{
"passwd"
:
"testPassword"
,
"confirm"
:
True
},
cookies
=
cookies
,
)
assert
resp
.
status_code
==
HTTPStatus
.
SEE_OTHER
# Check that our User record no longer exists in the database
user_record
=
db
.
query
(
User
).
filter
(
User
.
Username
==
username
).
first
()
assert
user_record
is
None
sshpubkey_record
=
db
.
query
(
SSHPubKey
).
filter
(
SSHPubKey
.
User
==
user
).
first
()
assert
sshpubkey_record
is
None
def
test_account_delete_as_tu
(
client
:
TestClient
,
tu_user
:
User
):
with
db
.
begin
():
user
=
create_user
(
"user2"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment