mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix: support multiple SSHPubKey records per user
There was one blazing issue with the previous implementation regardless of the multiple records: we were generating fingerprints by storing the key into a file and reading it with ssh-keygen. This is absolutely terrible and was not meant to be left around (it was forgotten, my bad). Took this opportunity to clean up a few things: - simplify pubkey validation - centralize things a bit better Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
660d57340a
commit
4c14a10b91
11 changed files with 162 additions and 108 deletions
|
@ -1,3 +1,5 @@
|
|||
from subprocess import PIPE, Popen
|
||||
|
||||
import pytest
|
||||
|
||||
from aurweb import db
|
||||
|
@ -61,8 +63,12 @@ def test_pubkey_cs(user: User):
|
|||
|
||||
|
||||
def test_pubkey_fingerprint():
|
||||
assert get_fingerprint(TEST_SSH_PUBKEY) is not None
|
||||
proc = Popen(["ssh-keygen", "-l", "-f", "-"], stdin=PIPE, stdout=PIPE)
|
||||
out, _ = proc.communicate(TEST_SSH_PUBKEY.encode())
|
||||
expected = out.decode().split()[1].split(":", 1)[1]
|
||||
assert get_fingerprint(TEST_SSH_PUBKEY) == expected
|
||||
|
||||
|
||||
def test_pubkey_invalid_fingerprint():
|
||||
assert get_fingerprint("ssh-rsa fake and invalid") is None
|
||||
with pytest.raises(ValueError):
|
||||
get_fingerprint("invalid-prefix some-fake-content")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue