-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #983 from bklvsky/test_package_exporter
Test integration between packages_exporter and albs-sign-file
- Loading branch information
Showing
8 changed files
with
107 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
|
||
gpg_key_blueprint=$( gpg --list-keys [email protected] | head -n 2 | tail -1 ) | ||
|
||
# Generating GPG key if it doesn't exist | ||
if [ -z "$gpg_key_blueprint" ]; then | ||
echo "No GPG key found, generating a new one..." | ||
|
||
echo "Key-Type: 1 | ||
Key-Length: 2048 | ||
Subkey-Type: 1 | ||
Subkey-Length: 2048 | ||
Name-Real: Test GPG key for ALBS sign node | ||
Name-Email: \"[email protected]\" | ||
Expire-Date: 0 | ||
Passphrase: 1234567890" > gpg_key_scenario | ||
|
||
gpg --batch --gen-key gpg_key_scenario | ||
gpg_key_blueprint=$( gpg --list-keys [email protected] | head -n 2 | tail -1 ) | ||
|
||
fi | ||
|
||
gpg_key_blueprint=${gpg_key_blueprint: -16} | ||
|
||
# Setting according env variables | ||
if [ ! -f "../albs-sign-file/.env" ]; then | ||
echo "Generating .env for albs-sign-file" | ||
echo "SF_PASS_DB_DEV_PASS=\"1234567890\" | ||
SF_PASS_DB_DEV_MODE=True | ||
SF_PGP_KEYS_ID=[\"$gpg_key_blueprint\"] | ||
SF_JWT_SECRET_KEY=\"access-secret\" | ||
SF_HOST_GNUPG=\"~/.gnupg\" | ||
SF_ROOT_URL=\"/sign-file\"" > ../albs-sign-file/.env | ||
fi | ||
|
||
sed -i 's/^TEST_SIGN_KEY_ID=".*"/TEST_SIGN_KEY_ID="'"$gpg_key_blueprint"'"/' tests/test-vars.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,7 @@ PULP_DATABASE_URL="postgresql+psycopg2://postgres:password@test_db/test-almalinu | |
SQLALCHEMY_POOL_PRE_PING=True | ||
SQLALCHEMY_POOL_RECYCLE=3600 | ||
SQLALCHEMY_URL="postgresql+psycopg2://postgres:password@test_db/test-almalinux-bs" | ||
SYNC_DATABASE_URL="postgresql+psycopg2://postgres:password@test_db/test-almalinux-bs" | ||
SYNC_DATABASE_URL="postgresql+psycopg2://postgres:password@test_db/test-almalinux-bs" | ||
SIGN_SERVER_USERNAME="[email protected]" | ||
SIGN_SERVER_PASSWORD="test" | ||
TEST_SIGN_KEY_ID="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
import os | ||
import tempfile | ||
|
||
import pytest | ||
from syncer import sync | ||
|
||
from alws.config import settings | ||
from alws.models import SignKey | ||
from scripts.packages_exporter import Exporter | ||
from tests.mock_classes import BaseAsyncTestCase | ||
|
||
IN_GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") is not None | ||
|
||
|
||
@pytest.mark.skip( | ||
reason="See https://github.com/AlmaLinux/build-system/issues/204" | ||
) | ||
def test_repomd_signer(): | ||
exporter = Exporter( | ||
pulp_client=None, repodata_cache_dir='~/.cache/pulp_exporter' | ||
class TestPackagesExporter(BaseAsyncTestCase): | ||
@pytest.mark.skipif( | ||
not settings.test_sign_key_id, reason="Testing sign key is not provided" | ||
) | ||
db_keys = sync(exporter.get_sign_keys()) | ||
key_id = db_keys[0]['keyid'] | ||
with tempfile.NamedTemporaryFile() as fp: | ||
fp.write(b'Hello world!') | ||
res = sync(exporter.sign_repomd_xml(fp.name, key_id)) | ||
async def test_repomd_signer(self, sign_key: SignKey, tmp_path): | ||
exporter = Exporter( | ||
pulp_client=None, repodata_cache_dir='~/.cache/pulp_exporter' | ||
) | ||
key_id = sign_key.keyid | ||
token = await exporter.get_sign_server_token() | ||
temp_file = tmp_path / "tempfile.txt" | ||
temp_file.write_bytes(b'Hello world!') | ||
res = await exporter.sign_repomd_xml(str(temp_file), key_id, token) | ||
assert res['error'] is None |