...

Text file src/github.com/docker/distribution/contrib/docker-integration/tls.bats

Documentation: github.com/docker/distribution/contrib/docker-integration

     1#!/usr/bin/env bats
     2
     3# Registry host name, should be set to non-localhost address and match
     4# DNS name in nginx/ssl certificates and what is installed in /etc/docker/cert.d
     5
     6load helpers
     7
     8hostname="localregistry"
     9base="hello-world"
    10image="${base}:latest"
    11
    12# Login information, should match values in nginx/test.passwd
    13user=${TEST_USER:-"testuser"}
    14password=${TEST_PASSWORD:-"passpassword"}
    15
    16function setup() {
    17	tempImage $image
    18}
    19
    20@test "Test valid certificates" {
    21	docker_t tag $image $hostname:5440/$image
    22	run docker_t push $hostname:5440/$image
    23	[ "$status" -eq 0 ]
    24	has_digest "$output"
    25}
    26
    27@test "Test basic auth" {
    28	basic_auth_version_check
    29	login $hostname:5441
    30	docker_t tag $image $hostname:5441/$image
    31	run docker_t push $hostname:5441/$image
    32	[ "$status" -eq 0 ]
    33	has_digest "$output"
    34}
    35
    36@test "Test basic auth with build" {
    37	basic_auth_version_check
    38	login $hostname:5441
    39
    40	image1=$hostname:5441/$image-build
    41	image2=$hostname:5441/$image-build-2
    42
    43	tempImage $image1
    44
    45	run docker_t push $image1
    46	[ "$status" -eq 0 ]
    47	has_digest "$output"
    48
    49	docker_t rmi $image1
    50
    51	run build $image2 $image1
    52	echo $output
    53	[ "$status" -eq 0 ]
    54
    55	run docker_t push $image2
    56	echo $output
    57	[ "$status" -eq 0 ]
    58	has_digest "$output"
    59}
    60
    61@test "Test TLS client auth" {
    62	docker_t tag $image $hostname:5442/$image
    63	run docker_t push $hostname:5442/$image
    64	[ "$status" -eq 0 ]
    65	has_digest "$output"
    66}
    67
    68@test "Test TLS client with invalid certificate authority fails" {
    69	docker_t tag $image $hostname:5443/$image
    70	run docker_t push $hostname:5443/$image
    71	[ "$status" -ne 0 ]
    72}
    73
    74@test "Test basic auth with TLS client auth" {
    75	basic_auth_version_check
    76	login $hostname:5444
    77	docker_t tag $image $hostname:5444/$image
    78	run docker_t push $hostname:5444/$image
    79	[ "$status" -eq 0 ]
    80	has_digest "$output"
    81}
    82
    83@test "Test unknown certificate authority fails" {
    84	docker_t tag $image $hostname:5445/$image
    85	run docker_t push $hostname:5445/$image
    86	[ "$status" -ne 0 ]
    87}
    88
    89@test "Test basic auth with unknown certificate authority fails" {
    90	run login $hostname:5446
    91	[ "$status" -ne 0 ]
    92	docker_t tag $image $hostname:5446/$image
    93	run docker_t push $hostname:5446/$image
    94	[ "$status" -ne 0 ]
    95}
    96
    97@test "Test TLS client auth to server with unknown certificate authority fails" {
    98	docker_t tag $image $hostname:5447/$image
    99	run docker_t push $hostname:5447/$image
   100	[ "$status" -ne 0 ]
   101}
   102
   103@test "Test failure to connect to server fails to fallback to SSLv3" {
   104	docker_t tag $image $hostname:5448/$image
   105	run docker_t push $hostname:5448/$image
   106	[ "$status" -ne 0 ]
   107}
   108

View as plain text