-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add spread tests for registries
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#! /bin/bash | ||
|
||
registries_file="$1" | ||
|
||
# flip-flop between 'access' being read and write | ||
if grep -q "^ *access:.*read" "$registries_file"; then | ||
access="write" | ||
else | ||
access="read" | ||
fi | ||
|
||
sed -i "s/^\([[:space:]]*\)access:.*/\1access: $access/g" "$registries_file" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
summary: test the registries commands | ||
|
||
environment: | ||
SNAPCRAFT_ASSERTION_KEY: "$(HOST: echo ${SNAPCRAFT_ASSERTION_KEY})" | ||
SNAPCRAFT_STORE_CREDENTIALS: "$(HOST: echo ${SNAPCRAFT_STORE_CREDENTIALS_STAGING})" | ||
|
||
prepare: | | ||
if [[ -z "$SNAPCRAFT_STORE_CREDENTIALS" ]]; then | ||
ERROR "No credentials set in env SNAPCRAFT_STORE_CREDENTIALS" | ||
fi | ||
if [[ -z "$SNAPCRAFT_ASSERTION_KEY" ]]; then | ||
ERROR "No gpg key set in env SNAPCRAFT_ASSERTION_KEY" | ||
fi | ||
# setup snap gpg dir | ||
mkdir -p "$HOME/.snap/gnupg" | ||
chmod 700 "$HOME/.snap/gnupg" | ||
# import a registered key | ||
echo "$SNAPCRAFT_ASSERTION_KEY" | base64 --decode > store-key.txt | ||
gpg --homedir "$HOME/.snap/gnupg" --import store-key.txt | ||
rm -f store-key.txt | ||
snap install yq | ||
# registries only available in edge | ||
snap refresh snapd --edge | ||
execute: | | ||
# ensure snapcraft is logged in and can access the store | ||
snapcraft whoami | ||
# snapcraft will use a fake file editor | ||
export EDITOR="$PWD/editor.sh" | ||
snapcraft edit-registries "$(snapcraft whoami | yq .id)" testset --key-name testspreadkey | ||
snapcraft list-registries | MATCH testset | ||
restore: | | ||
rm -rf "$HOME/.snap/gnupg" | ||
snap remove --purge yq | ||
snap refresh snapd --stable |