# Copyright 2019 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
testinfra_hosts = ['mirror01.openafs.provider.opendev.org',
'mirror02.openafs.provider.opendev.org']
def test_apache(host):
apache = host.service('apache2')
assert apache.is_running
def test_base_mirror(host):
# BaseMirror
cmd = host.run("wget --no-check-certificate -qO- https://localhost/")
assert '' in cmd.stdout
cmd = host.run("wget -qO- http://localhost/")
assert '' in cmd.stdout
def test_proxy_mirror(host):
# ProxyMirror
cmd = host.run("wget --no-check-certificate -qO- "
"https://localhost:4443/pypi/simple/setuptools")
assert 'setuptools' in cmd.stdout
cmd = host.run("wget -qO- http://localhost:8080/pypi/simple/setuptools")
assert 'setuptools' in cmd.stdout
def test_dockerv1_mirror(host):
# Dockerv1Mirror
cmd = host.run("wget --no-check-certificate -O- "
"https://localhost:4444/registry-1.docker")
# TODO assert that this proxy cache is working more properly
assert '403 Forbidden' in cmd.stderr
cmd = host.run("wget -O- http://localhost:8081/registry-1.docker")
# TODO assert that this proxy cache is working more properly
assert '403 Forbidden' in cmd.stderr
def test_dockerv2_mirror(host):
# Dockerv2Mirror
cmd = host.run("wget --no-check-certificate -O- "
"https://localhost:4445/v2/")
assert '401 Unauthorized' in cmd.stderr
cmd = host.run("wget -O- http://localhost:8082/v2/")
assert '401 Unauthorized' in cmd.stderr
# TODO test RHRegistryMirror and QuayMirror
# NOTE(ianw): further testing idea for anyone interested; get the
# actual IP address of the mirror node and connect via that