Update has digest test in scripts
Make has_digest function more robust for testing 1.8 and newer Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
parent
be404d7557
commit
9efc11ac9d
1 changed files with 6 additions and 11 deletions
|
@ -16,13 +16,8 @@ function setup() {
|
||||||
# has_digest enforces the last output line is "Digest: sha256:..."
|
# has_digest enforces the last output line is "Digest: sha256:..."
|
||||||
# the input is the name of the array containing the output lines
|
# the input is the name of the array containing the output lines
|
||||||
function has_digest() {
|
function has_digest() {
|
||||||
name=$1[@]
|
filtered=$(echo "$1" |sed -rn '/[dD]igest\: sha(256|384|512)/ p')
|
||||||
lines=("${!name}")
|
[ "$filtered" != "" ]
|
||||||
length=${#lines[@]}
|
|
||||||
digest_idx=$((length-1))
|
|
||||||
value=${lines[$digest_idx]}
|
|
||||||
result=$(echo "$value"|cut -d':' -f1,2)
|
|
||||||
[ "$result" = "Digest: sha256" ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function login() {
|
function login() {
|
||||||
|
@ -36,7 +31,7 @@ function login() {
|
||||||
docker tag -f $image $hostname:5440/$image
|
docker tag -f $image $hostname:5440/$image
|
||||||
run docker push $hostname:5440/$image
|
run docker push $hostname:5440/$image
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
has_digest lines
|
has_digest "$output"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "Test basic auth" {
|
@test "Test basic auth" {
|
||||||
|
@ -44,14 +39,14 @@ function login() {
|
||||||
docker tag -f $image $hostname:5441/$image
|
docker tag -f $image $hostname:5441/$image
|
||||||
run docker push $hostname:5441/$image
|
run docker push $hostname:5441/$image
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
has_digest lines
|
has_digest "$output"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "Test TLS client auth" {
|
@test "Test TLS client auth" {
|
||||||
docker tag -f $image $hostname:5442/$image
|
docker tag -f $image $hostname:5442/$image
|
||||||
run docker push $hostname:5442/$image
|
run docker push $hostname:5442/$image
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
has_digest lines
|
has_digest "$output"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "Test TLS client with invalid certificate authority fails" {
|
@test "Test TLS client with invalid certificate authority fails" {
|
||||||
|
@ -65,7 +60,7 @@ function login() {
|
||||||
docker tag -f $image $hostname:5444/$image
|
docker tag -f $image $hostname:5444/$image
|
||||||
run docker push $hostname:5444/$image
|
run docker push $hostname:5444/$image
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
has_digest lines
|
has_digest "$output"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "Test unknown certificate authority fails" {
|
@test "Test unknown certificate authority fails" {
|
||||||
|
|
Loading…
Reference in a new issue