Update login helpers to handle email removal
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
parent
129ad8ea0c
commit
cfff433744
3 changed files with 28 additions and 26 deletions
|
@ -32,35 +32,44 @@ function basic_auth_version_check() {
|
|||
fi
|
||||
}
|
||||
|
||||
email="a@nowhere.com"
|
||||
|
||||
# docker_t_login calls login with email depending on version
|
||||
function docker_t_login() {
|
||||
# Only pass email field pre 1.11, no deprecation warning
|
||||
parse_version "$GOLEM_DIND_VERSION"
|
||||
v=$version
|
||||
parse_version "1.11.0"
|
||||
if [ "$v" -lt "$version" ]; then
|
||||
run docker_t login -e $email $@
|
||||
else
|
||||
run docker_t login $@
|
||||
fi
|
||||
}
|
||||
|
||||
# login issues a login to docker to the provided server
|
||||
# uses user, password, and email variables set outside of function
|
||||
# requies bats
|
||||
function login() {
|
||||
rm -f /root/.docker/config.json
|
||||
|
||||
# Only pass email field pre 1.11, no deprecation warning
|
||||
docker_t_login -u $user -p $password $1
|
||||
if [ "$status" -ne 0 ]; then
|
||||
echo $output
|
||||
fi
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
# Handle different deprecation warnings
|
||||
parse_version "$GOLEM_DIND_VERSION"
|
||||
v=$version
|
||||
parse_version "1.11.0"
|
||||
if [ "$v" -lt "$version" ]; then
|
||||
run docker_t login -u $user -p $password -e $email $1
|
||||
if [ "$status" -ne 0 ]; then
|
||||
echo $output
|
||||
fi
|
||||
[ "$status" -eq 0 ]
|
||||
# First line is WARNING about credential save or email deprecation (maybe both)
|
||||
[ "${lines[2]}" = "Login Succeeded" -o "${lines[1]}" = "Login Succeeded" ]
|
||||
else
|
||||
run docker_t login -u $user -p $password $1
|
||||
if [ "$status" -ne 0 ]; then
|
||||
echo $output
|
||||
fi
|
||||
echo $output
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${lines[0]}" = "Login Succeeded" ]
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
function login_oauth() {
|
||||
|
@ -109,7 +118,7 @@ function docker_t() {
|
|||
docker exec dockerdaemon docker $@
|
||||
}
|
||||
|
||||
# build reates a new docker image id from another image
|
||||
# build creates a new docker image id from another image
|
||||
function build() {
|
||||
docker exec -i dockerdaemon docker build --no-cache -t $1 - <<DOCKERFILE
|
||||
FROM $2
|
||||
|
|
|
@ -12,7 +12,6 @@ image="${base}:latest"
|
|||
# Login information, should match values in nginx/test.passwd
|
||||
user=${TEST_USER:-"testuser"}
|
||||
password=${TEST_PASSWORD:-"passpassword"}
|
||||
email="distribution@docker.com"
|
||||
|
||||
function setup() {
|
||||
tempImage $image
|
||||
|
|
|
@ -6,23 +6,17 @@ load helpers
|
|||
|
||||
user="testuser"
|
||||
password="testpassword"
|
||||
email="a@nowhere.com"
|
||||
base="hello-world"
|
||||
|
||||
@test "Test token server login" {
|
||||
run docker_t login -u $user -p $password -e $email localregistry:5554
|
||||
echo $output
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
# First line is WARNING about credential save or email deprecation
|
||||
[ "${lines[2]}" = "Login Succeeded" -o "${lines[1]}" = "Login Succeeded" ]
|
||||
login localregistry:5554
|
||||
}
|
||||
|
||||
@test "Test token server bad login" {
|
||||
run docker_t login -u "testuser" -p "badpassword" -e $email localregistry:5554
|
||||
docker_t_login -u "testuser" -p "badpassword" localregistry:5554
|
||||
[ "$status" -ne 0 ]
|
||||
|
||||
run docker_t login -u "baduser" -p "testpassword" -e $email localregistry:5554
|
||||
docker_t_login -u "baduser" -p "testpassword" localregistry:5554
|
||||
[ "$status" -ne 0 ]
|
||||
}
|
||||
|
||||
|
@ -58,10 +52,10 @@ base="hello-world"
|
|||
@test "Test oauth token server bad login" {
|
||||
version_check docker "$GOLEM_DIND_VERSION" "1.11.0"
|
||||
|
||||
run docker_t login -u "testuser" -p "badpassword" -e $email localregistry:5557
|
||||
docker_t_login -u "testuser" -p "badpassword" -e $email localregistry:5557
|
||||
[ "$status" -ne 0 ]
|
||||
|
||||
run docker_t login -u "baduser" -p "testpassword" -e $email localregistry:5557
|
||||
docker_t_login -u "baduser" -p "testpassword" -e $email localregistry:5557
|
||||
[ "$status" -ne 0 ]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue