1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
summary: Check that the setting proxy.store config works
details: |
Check that through the proxy.store config it is possible to
point snapd to a different store. Also verify that it is allowed
to point to the main store.
# ubuntu-14.04: systemd-run not supported
systems: [-ubuntu-core-*, -ubuntu-14.04*]
environment:
SNAP_NAME: test-snapd-tools
SNAP_VERSION_PATTERN: \d+\.\d+\+fake1
BLOB_DIR: $(pwd)/fake-store-blobdir
prepare: |
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
echo "Given a snap is installed"
snap install "$SNAP_NAME"
"$TESTSTOOLS"/store-state setup-fake-store "$BLOB_DIR"
# undo the setup through envvars
systemctl stop snapd.service snapd.socket
rm /etc/systemd/system/snapd.service.d/store.conf
systemctl daemon-reload
systemctl start snapd.socket
# prepare bundle
cat "$TESTSLIB"/assertions/testrootorg-store.account-key >fake.store
#shellcheck disable=SC2129
echo >>fake.store
cat "$TESTSLIB"/assertions/developer1.account >>fake.store
#shellcheck disable=SC2129
echo >>fake.store
cat "$TESTSLIB"/assertions/fake.store >>fake.store
echo "Ack fake store assertion"
snap ack fake.store
echo "And a new version of that snap put in the controlled store"
"$TESTSTOOLS"/store-state init-fake-refreshes "$BLOB_DIR" "$SNAP_NAME"
restore: |
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
systemctl start snapd.socket
snap set core proxy.store=
"$TESTSTOOLS"/store-state teardown-fake-store "$BLOB_DIR"
execute: |
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
echo "Configure to use the fakestore through store assertion and proxy.store"
snap set core proxy.store=fake
systemctl stop snapd snapd.socket
gojq '.data.auth.device."session-macaroon"' /var/lib/snapd/state.json|MATCH null
# XXX the fakestore currently does not support faking session creation
gojq '.data.auth.device."session-macaroon"="fake-session"' /var/lib/snapd/state.json > /var/lib/snapd/state.json.new
mv /var/lib/snapd/state.json.new /var/lib/snapd/state.json
systemctl start snapd.socket
echo "Then the new version is listed as candidate refresh"
expected="$SNAP_NAME +$SNAP_VERSION_PATTERN"
snap refresh --list | grep -Pzq "$expected"
echo "Switch back temporarely to the main store"
snap set core proxy.store=
snap refresh --list | not grep -Pzq "$expected"
echo "Ensure changing the proxy.store will clear out the session-macaroon"
gojq '.data.auth.device."session-macaroon"' /var/lib/snapd/state.json|NOMATCH fake-session
echo "Configure back to use fakestore"
snap set core proxy.store=fake
# XXX the fakestore currently does not support faking session creation
systemctl stop snapd snapd.socket
gojq '.data.auth.device."session-macaroon"="fake-session"' /var/lib/snapd/state.json > /var/lib/snapd/state.json.new
mv /var/lib/snapd/state.json.new /var/lib/snapd/state.json
systemctl start snapd.socket
echo "Now we can proceed with the refresh from the fakestore"
snap refresh "$SNAP_NAME"
echo "Then the new version is listed"
snap list | grep -Pzq "$expected"
|