2019-02-15 15:18:15 -08:00
|
|
|
# Copyright 2018 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.
|
|
|
|
|
|
|
|
|
2019-07-23 20:25:47 +00:00
|
|
|
testinfra_hosts = ['gitea99.opendev.org']
|
2019-02-15 15:18:15 -08:00
|
|
|
|
|
|
|
|
|
|
|
def test_gitea_listening(host):
|
2019-02-15 15:59:26 -08:00
|
|
|
gitea_https = host.socket("tcp://0.0.0.0:3000")
|
2019-02-15 15:18:15 -08:00
|
|
|
assert gitea_https.is_listening
|
2019-02-15 15:59:26 -08:00
|
|
|
gitea_http = host.socket("tcp://0.0.0.0:3080")
|
2019-02-15 15:18:15 -08:00
|
|
|
assert gitea_http.is_listening
|
|
|
|
gitea_ssh = host.socket("tcp://0.0.0.0:222")
|
|
|
|
assert gitea_ssh.is_listening
|
2020-07-01 11:47:33 +10:00
|
|
|
gitea_proxy = host.socket("tcp://0.0.0.0:3081")
|
|
|
|
assert gitea_proxy.is_listening
|
2019-04-22 14:53:55 -07:00
|
|
|
|
|
|
|
def test_ulimit(host):
|
2020-04-13 08:58:17 -07:00
|
|
|
cmd = host.run("docker exec gitea-docker_gitea-web_1 prlimit")
|
2019-04-22 14:53:55 -07:00
|
|
|
expected = ("STACK max stack size "
|
|
|
|
"16777216 9223372036854775807 bytes")
|
|
|
|
assert expected in cmd.stdout.split('\n')
|
2019-08-06 13:42:25 -07:00
|
|
|
|
2020-07-01 05:49:19 +10:00
|
|
|
def test_robots(host):
|
|
|
|
cmd = host.run('curl --insecure '
|
|
|
|
'--resolve gitea99.opendev.org:3000:127.0.0.1 '
|
|
|
|
'https://gitea99.opendev.org:3000/robots.txt')
|
|
|
|
assert 'Disallow: /' in cmd.stdout
|
2020-07-01 11:47:33 +10:00
|
|
|
|
|
|
|
def test_proxy(host):
|
|
|
|
cmd = host.run('curl --insecure '
|
|
|
|
'--resolve gitea99.opendev.org:3081:127.0.0.1 '
|
|
|
|
'https://gitea99.opendev.org:3081/')
|
|
|
|
assert 'Git with a cup of tea' in cmd.stdout
|
2020-07-01 12:54:00 +10:00
|
|
|
|
|
|
|
def test_proxy_ua_blacklist(host):
|
|
|
|
cmd = host.run('curl --insecure -A '
|
|
|
|
'" Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler 4.0)" '
|
|
|
|
'--resolve gitea99.opendev.org:3081:127.0.0.1 '
|
|
|
|
'https://gitea99.opendev.org:3081/')
|
|
|
|
assert '403 Forbidden' in cmd.stdout
|
2020-10-08 10:55:19 +11:00
|
|
|
|
|
|
|
def test_ondisk_logs(host):
|
|
|
|
mariadb_log = host.file('/var/log/containers/docker-mariadb.log')
|
|
|
|
assert mariadb_log.exists
|
|
|
|
|
|
|
|
gitea_log = host.file('/var/log/containers/docker-gitea.log')
|
|
|
|
assert gitea_log.exists
|
|
|
|
|
|
|
|
gitea_ssh_log = host.file('/var/log/containers/docker-gitea-ssh.log')
|
|
|
|
assert gitea_ssh_log.exists
|
|
|
|
assert gitea_ssh_log.contains("Server listening on :: port 222.")
|