fix test_accounts_routes test coverage

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-06-04 23:13:05 -07:00
parent 228bc8fe7c
commit 62e58b122f
2 changed files with 16 additions and 16 deletions

View file

@ -8,7 +8,7 @@ cache:
before_script: before_script:
- pacman -Syu --noconfirm --noprogressbar --needed --cachedir .pkg-cache - pacman -Syu --noconfirm --noprogressbar --needed --cachedir .pkg-cache
base-devel git gpgme protobuf pyalpm python-mysql-connector base-devel git gpgme protobuf pyalpm python-mysqlclient
python-pygit2 python-srcinfo python-bleach python-markdown python-pygit2 python-srcinfo python-bleach python-markdown
python-sqlalchemy python-alembic python-pytest python-werkzeug python-sqlalchemy python-alembic python-pytest python-werkzeug
python-pytest-tap python-fastapi hypercorn nginx python-authlib python-pytest-tap python-fastapi hypercorn nginx python-authlib

View file

@ -30,6 +30,20 @@ client = TestClient(app)
user = None user = None
def make_ssh_pubkey():
# Create a public key with ssh-keygen (this adds ssh-keygen as a
# dependency to passing this test).
with tempfile.TemporaryDirectory() as tmpdir:
with open("/dev/null", "w") as null:
proc = Popen(["ssh-keygen", "-f", f"{tmpdir}/test.ssh", "-N", ""],
stdout=null, stderr=null)
proc.wait()
assert proc.returncode == 0
# Read in the public key, then delete the temp dir we made.
return open(f"{tmpdir}/test.ssh.pub").read().rstrip()
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def setup(): def setup():
global user global user
@ -770,27 +784,13 @@ def test_post_account_edit_error_unauthorized():
def test_post_account_edit_ssh_pub_key(): def test_post_account_edit_ssh_pub_key():
pk = str()
# Create a public key with ssh-keygen (this adds ssh-keygen as a
# dependency to passing this test).
with tempfile.TemporaryDirectory() as tmpdir:
with open("/dev/null", "w") as null:
proc = Popen(["ssh-keygen", "-f", f"{tmpdir}/test.ssh", "-N", ""],
stdout=null, stderr=null)
proc.wait()
assert proc.returncode == 0
# Read in the public key, then delete the temp dir we made.
pk = open(f"{tmpdir}/test.ssh.pub").read().rstrip()
request = Request() request = Request()
sid = user.login(request, "testPassword") sid = user.login(request, "testPassword")
post_data = { post_data = {
"U": "test", "U": "test",
"E": "test@example.org", "E": "test@example.org",
"PK": pk, "PK": make_ssh_pubkey(),
"passwd": "testPassword" "passwd": "testPassword"
} }