2016-03-30 20:55:24 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
2015-06-05 20:19:50 +00:00
|
|
|
# Registry host name, should be set to non-localhost address and match
|
|
|
|
# DNS name in nginx/ssl certificates and what is installed in /etc/docker/cert.d
|
|
|
|
|
2016-03-30 20:55:24 +00:00
|
|
|
load helpers
|
|
|
|
|
|
|
|
hostname="localregistry"
|
|
|
|
base="hello-world"
|
|
|
|
image="${base}:latest"
|
2015-06-05 20:19:50 +00:00
|
|
|
|
|
|
|
# Login information, should match values in nginx/test.passwd
|
2016-03-30 20:55:24 +00:00
|
|
|
user=${TEST_USER:-"testuser"}
|
|
|
|
password=${TEST_PASSWORD:-"passpassword"}
|
2015-06-05 20:19:50 +00:00
|
|
|
email="distribution@docker.com"
|
|
|
|
|
|
|
|
function setup() {
|
2016-03-30 20:55:24 +00:00
|
|
|
tempImage $image
|
2015-07-28 01:08:04 +00:00
|
|
|
}
|
|
|
|
|
2016-03-30 20:55:24 +00:00
|
|
|
@test "Test valid certificates" {
|
|
|
|
docker_t tag -f $image $hostname:5440/$image
|
|
|
|
run docker_t push $hostname:5440/$image
|
2015-06-05 20:19:50 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2016-03-30 20:55:24 +00:00
|
|
|
has_digest "$output"
|
2015-06-05 20:19:50 +00:00
|
|
|
}
|
|
|
|
|
2016-03-30 20:55:24 +00:00
|
|
|
@test "Test basic auth" {
|
|
|
|
basic_auth_version_check
|
|
|
|
login $hostname:5441
|
|
|
|
docker_t tag -f $image $hostname:5441/$image
|
|
|
|
run docker_t push $hostname:5441/$image
|
2015-06-05 20:19:50 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2015-07-28 01:32:02 +00:00
|
|
|
has_digest "$output"
|
2015-06-05 20:19:50 +00:00
|
|
|
}
|
|
|
|
|
2016-03-30 20:55:24 +00:00
|
|
|
@test "Test basic auth with build" {
|
2015-07-28 01:08:04 +00:00
|
|
|
basic_auth_version_check
|
2015-06-05 20:19:50 +00:00
|
|
|
login $hostname:5441
|
2016-03-30 20:55:24 +00:00
|
|
|
|
|
|
|
image1=$hostname:5441/$image-build
|
|
|
|
image2=$hostname:5441/$image-build-2
|
|
|
|
|
|
|
|
tempImage $image1
|
|
|
|
|
|
|
|
run docker_t push $image1
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
has_digest "$output"
|
|
|
|
|
|
|
|
docker_t rmi $image1
|
|
|
|
|
|
|
|
run build $image2 $image1
|
|
|
|
echo $output
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
run docker_t push $image2
|
|
|
|
echo $output
|
2015-06-05 20:19:50 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2015-07-28 01:32:02 +00:00
|
|
|
has_digest "$output"
|
2015-06-05 20:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "Test TLS client auth" {
|
2016-03-30 20:55:24 +00:00
|
|
|
docker_t tag -f $image $hostname:5442/$image
|
|
|
|
run docker_t push $hostname:5442/$image
|
2015-06-05 20:19:50 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2015-07-28 01:32:02 +00:00
|
|
|
has_digest "$output"
|
2015-06-05 20:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "Test TLS client with invalid certificate authority fails" {
|
2016-03-30 20:55:24 +00:00
|
|
|
docker_t tag -f $image $hostname:5443/$image
|
|
|
|
run docker_t push $hostname:5443/$image
|
2015-06-05 20:19:50 +00:00
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Test basic auth with TLS client auth" {
|
2015-07-28 01:08:04 +00:00
|
|
|
basic_auth_version_check
|
2015-06-05 20:19:50 +00:00
|
|
|
login $hostname:5444
|
2016-03-30 20:55:24 +00:00
|
|
|
docker_t tag -f $image $hostname:5444/$image
|
|
|
|
run docker_t push $hostname:5444/$image
|
2015-06-05 20:19:50 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2015-07-28 01:32:02 +00:00
|
|
|
has_digest "$output"
|
2015-06-05 20:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "Test unknown certificate authority fails" {
|
2016-03-30 20:55:24 +00:00
|
|
|
docker_t tag -f $image $hostname:5445/$image
|
|
|
|
run docker_t push $hostname:5445/$image
|
2015-06-05 20:19:50 +00:00
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Test basic auth with unknown certificate authority fails" {
|
|
|
|
run login $hostname:5446
|
|
|
|
[ "$status" -ne 0 ]
|
2016-03-30 20:55:24 +00:00
|
|
|
docker_t tag -f $image $hostname:5446/$image
|
|
|
|
run docker_t push $hostname:5446/$image
|
2015-06-05 20:19:50 +00:00
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Test TLS client auth to server with unknown certificate authority fails" {
|
2016-03-30 20:55:24 +00:00
|
|
|
docker_t tag -f $image $hostname:5447/$image
|
|
|
|
run docker_t push $hostname:5447/$image
|
2015-06-05 20:19:50 +00:00
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Test failure to connect to server fails to fallback to SSLv3" {
|
2016-03-30 20:55:24 +00:00
|
|
|
docker_t tag -f $image $hostname:5448/$image
|
|
|
|
run docker_t push $hostname:5448/$image
|
2015-06-05 20:19:50 +00:00
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
}
|
|
|
|
|