# 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.region.provider.opendev.org']


def test_apache(host):
    apache = host.service('apache2')
    assert apache.is_running

def test_mirror_indexes(host):
    cmd = host.run("wget --no-check-certificate -qO- https://localhost/")
    assert '<a href="debian/">' in cmd.stdout

    cmd = host.run("wget -qO- http://localhost/")
    assert '<a href="debian/">' in cmd.stdout

# NOTE(ianw): further testing idea for anyone interested; get the
# actual IP address of the mirror node and connect via that, and then
# also poke at the other proxy ports