Compare commits

...

3 Commits

4 changed files with 48 additions and 6 deletions

7
debian/changelog vendored
View File

@ -1,3 +1,10 @@
snapd-extra-utils (1.0.3) plucky; urgency=medium
* In snapd-seed-glue, remove redundant decoding/encoding for account key.
* Add an autopkgtest for snapd-seed-glue.
-- Simon Quigley <tsimonq2@ubuntu.com> Sat, 23 Nov 2024 22:11:22 -0600
snapd-extra-utils (1.0.2) plucky; urgency=medium
* Fix edge cases where the snap revision may be older in the target channel

3
debian/tests/control vendored Normal file
View File

@ -0,0 +1,3 @@
Tests: snapd-seed-glue
Depends: snapd-seed-glue
Restrictions: needs-internet

37
debian/tests/snapd-seed-glue vendored Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
set -e
# File to track command output, so we can check for successful completion
OUTPUT_FILE=$(mktemp)
# If the command output does not contain a final confirmation of success, exit 1
confirm_success () {
if grep -q "Cleanup and validation completed" "$OUTPUT_FILE"; then
rm -f "$OUTPUT_FILE"
else
exit 1
fi
}
echo "Testing snapd-seed-glue with firefox..."
/usr/bin/snapd-seed-glue --verbose --seed firefox_test firefox > >(tee -a "$OUTPUT_FILE") 2>&1
confirm_success
echo "Add krita to the same seed..."
/usr/bin/snapd-seed-glue --verbose --seed firefox_test firefox krita > >(tee -a "$OUTPUT_FILE") 2>&1
confirm_success
echo "Remove krita and replace it with Thunderbird..."
/usr/bin/snapd-seed-glue --verbose --seed firefox_test firefox thunderbird > >(tee -a "$OUTPUT_FILE") 2>&1
confirm_success
echo "Confirm that non-existent snaps will fail..."
/usr/bin/snapd-seed-glue --verbose --seed test_dir absolutelyridiculouslongnamethatwilldefinitelyneverexist > >(tee -a "$OUTPUT_FILE") 2>&1 || echo "Fail expected"
if ! grep -q "cannot install snap \"absolutelyridiculouslongnamethatwilldefinitelyneverexist\": snap not found" "$OUTPUT_FILE"; then
exit 1
fi

View File

@ -62,12 +62,7 @@ func ensureAssertions(assertionsDir string) {
if signKeySha3 == "" {
log.Fatalf("Failed to extract sign-key-sha3-384 from model assertion.")
}
decodedSignKey, err := base64.StdEncoding.DecodeString(signKeySha3)
if err != nil {
log.Fatalf("Failed to decode sign-key-sha3-384: %v", err)
}
encodedSignKey := base64.StdEncoding.EncodeToString(decodedSignKey)
output, err := exec.Command("snap", "known", "--remote", "account-key", "public-key-sha3-384="+encodedSignKey).CombinedOutput()
output, err := exec.Command("snap", "known", "--remote", "account-key", "public-key-sha3-384="+signKeySha3).CombinedOutput()
if err != nil {
log.Fatalf("Failed to fetch account-key assertion: %v, Output: %s", err, string(output))
}