Verified Commit 575d7e0c authored by Huste, Tobias's avatar Huste, Tobias
Browse files

add test for public key generation

parent 93091d3a
Pipeline #1607 passed with stage
in 12 minutes and 30 seconds
......@@ -74,7 +74,7 @@ setup_requires = [
install_requires = [
'celery>=4.0.2',
'invenio-assets>=1.0.0b2',
'invenio-assets>=1.0.0b6',
'invenio-files-rest>=1.0.0a19',
'invenio-records-files>=1.0.0a9',
'invenio-rest[cors]>=1.0.0a10',
......
......@@ -27,9 +27,10 @@ import paramiko
import pytest
from flask_login import current_user, login_user
from invenio_uploadbyurl.config import UPLOADBYURL_COMMENT
from invenio_uploadbyurl.models import RemoteServer, SSHKey
from invenio_uploadbyurl.utils import connect_user_and_server, \
delete_ssh_key, deploy_ssh_key, generate_rsa_key
delete_ssh_key, deploy_ssh_key, generate_public_keystr, generate_rsa_key
def test_deploy_key(app):
......@@ -75,3 +76,21 @@ def test_connect_user(app, client, db, user2, remote):
# check if key is also removed from db
key = SSHKey.get(user2[1].id, remote.id)
assert not key
def test_generate_public_keystr(remote, user, user2):
"""Test generation of public key string."""
# test rsa key
rsa_key = SSHKey.get(user.id, remote.id)
pub_key = generate_public_keystr(rsa_key)
with open('tests/sftp/test-rsa.pub') as key_file:
data = key_file.read().replace('\n', '')
data += ' ' + UPLOADBYURL_COMMENT
assert data == pub_key
# test ecdsa key
ecdsa_key = SSHKey.get(user2[0].id, remote.id)
pub_key = generate_public_keystr(ecdsa_key)
with open('tests/sftp/test-ecdsa.pub') as key_file:
data = key_file.read().replace('\n', '')
data += ' ' + UPLOADBYURL_COMMENT
assert data == pub_key
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment