Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test-app issue due to binary Hashicorp GPG key #68

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions tests/integration/test_apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@


import logging
from urllib.request import urlopen
import subprocess
import tempfile
from urllib.request import urlopen, urlretrieve

from charms.operator_libs_linux.v0 import apt
from helpers import get_command_path
Expand Down Expand Up @@ -42,7 +44,14 @@ def test_install_package_external_repository():
repositories = apt.RepositoryMapping()

# Get the Hashicorp GPG key
key = urlopen("https://apt.releases.hashicorp.com/gpg").read().decode()
with tempfile.NamedTemporaryFile() as key_file:
urlretrieve("https://apt.releases.hashicorp.com/gpg", filename=key_file.name)
process = subprocess.run(
["gpg", "--keyring", key_file.name, "--no-default-keyring", "--export", "-a"],
stdout=subprocess.PIPE,
encoding="utf-8",
)
key = process.stdout

# Add the hashicorp repository if it doesn't already exist
if "deb-apt.releases.hashicorp.com-focal" not in repositories:
Expand All @@ -62,7 +71,7 @@ def test_list_file_generation_external_repository():
repositories = apt.RepositoryMapping()

# Get the mongo GPG key
key = urlopen(" https://www.mongodb.org/static/pgp/server-5.0.asc").read().decode()
key = urlopen("https://www.mongodb.org/static/pgp/server-5.0.asc").read().decode()

# Add the mongo repository if it doesn't already exist
repo_name = "deb-https://repo.mongodb.org/apt/ubuntu-focal/mongodb-org/5.0"
Expand Down