Skip to content

Commit

Permalink
Protect the Swupd_Root.pem certificate file
Browse files Browse the repository at this point in the history
This test creates an alternate swupd root certificate. If one already
exists, back it up, and restore it when the test is done. Previously,
this test just blindly deleted the certificate if it existed.
  • Loading branch information
bwarden authored and bryteise committed Aug 27, 2024
1 parent 9da2dc6 commit 695417d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/functional/only_in_ci_system/api-3rd-party-add.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

load "../testlib"

SWUPD_ROOT_CERT=/usr/share/clear/update-ca/Swupd_Root.pem

test_setup() {

# Skip this test for local development because we write the certificate on /
Expand All @@ -16,9 +18,11 @@ test_setup() {

create_test_environment "$TEST_NAME"

sudo rm -f /usr/share/clear/update-ca/Swupd_Root.pem
# Backup the original certificate
[[ -f ${SWUPD_ROOT_CERT} ]] &&
mv ${SWUPD_ROOT_CERT} ${SWUPD_ROOT_CERT}.orig
sudo mkdir -p /usr/share/clear/update-ca
sudo cp test/functional/only_in_ci_system/pemfile /usr/share/clear/update-ca/Swupd_Root.pem
sudo cp test/functional/only_in_ci_system/pemfile ${SWUPD_ROOT_CERT}

create_third_party_repo "$TEST_NAME" 10 staging repo1
export repo1="$ABS_TP_URL"
Expand All @@ -31,7 +35,10 @@ test_teardown() {
return
fi

sudo rm -f /usr/share/clear/update-ca/Swupd_Root.pem
sudo rm -f ${SWUPD_ROOT_CERT}
# Restore the original certificate
[[ -f ${SWUPD_ROOT_CERT}.orig ]] &&
mv ${SWUPD_ROOT_CERT}.orig ${SWUPD_ROOT_CERT}

}

Expand Down

0 comments on commit 695417d

Please sign in to comment.