Skip to content

Commit

Permalink
chore: use 'candidate' fetch-service
Browse files Browse the repository at this point in the history
  • Loading branch information
tigarmo committed Oct 27, 2024
1 parent f618700 commit 1c0fa3d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
run: |
echo "::group::Begin snap install"
echo "Installing snaps in the background while running apt and pip..."
sudo snap install --no-wait --channel=beta fetch-service
sudo snap install --no-wait --channel=candidate fetch-service
echo "::endgroup::"
echo "::group::apt-get"
sudo apt update
Expand Down
22 changes: 1 addition & 21 deletions craft_application/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,34 +142,14 @@ def start_service() -> subprocess.Popen[str] | None:
"The 'fetch-service' snap is not installed.",
resolution=(
"Install the fetch-service snap via "
"'snap install --channel=beta fetch-service'."
"'snap install --channel=candidate fetch-service'."
),
)

cmd = [_FETCH_BINARY]

env = {"FETCH_SERVICE_AUTH": _DEFAULT_CONFIG.auth}

# Add the public key for the Ubuntu archives
archive_keyring = (
"/snap/fetch-service/current/usr/share/keyrings/ubuntu-archive-keyring.gpg"
)
archive_key_id = "F6ECB3762474EDA9D21B7022871920D1991BC93C"
archive_key = subprocess.check_output(
[
"gpg",
"--export",
"--armor",
"--no-default-keyring",
"--keyring",
archive_keyring,
archive_key_id,
],
text=True,
stderr=subprocess.PIPE,
)
env["FETCH_APT_RELEASE_PUBLIC_KEY"] = archive_key

# Add the ports
cmd.append(f"--control-port={_DEFAULT_CONFIG.control}")
cmd.append(f"--proxy-port={_DEFAULT_CONFIG.proxy}")
Expand Down
21 changes: 3 additions & 18 deletions tests/unit/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ def test_start_service(mocker, tmp_path):
mock_get_status = mocker.patch.object(
fetch, "get_service_status", return_value={"uptime": 10}
)
mock_archive_key = mocker.patch.object(
subprocess, "check_output", return_value="DEADBEEF"
)

fake_cert, fake_key = tmp_path / "cert.crt", tmp_path / "key.pem"
mock_obtain_certificate = mocker.patch.object(
Expand All @@ -106,20 +103,6 @@ def test_start_service(mocker, tmp_path):
assert mock_is_online.called
assert mock_base_dir.called
assert mock_get_status.called
mock_archive_key.assert_called_once_with(
[
"gpg",
"--export",
"--armor",
"--no-default-keyring",
"--keyring",
"/snap/fetch-service/current/usr/share/keyrings/ubuntu-archive-keyring.gpg",
"F6ECB3762474EDA9D21B7022871920D1991BC93C",
],
text=True,
stderr=subprocess.PIPE,
)

assert mock_obtain_certificate.called

popen_call = mock_popen.mock_calls[0]
Expand All @@ -142,7 +125,9 @@ def test_start_service(mocker, tmp_path):
)
+ f" > {fetch._get_log_filepath()}",
],
env={"FETCH_SERVICE_AUTH": AUTH, "FETCH_APT_RELEASE_PUBLIC_KEY": "DEADBEEF"},
env={
"FETCH_SERVICE_AUTH": AUTH,
},
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
Expand Down

0 comments on commit 1c0fa3d

Please sign in to comment.