Add integration tests for apache-git-http-backend container
This change adds tests to test the functionality of the
apache-git-http-backend container, by sending http- and git-requests to
the container and evaluating the response.
Change-Id: I945d96ec928e07ae375cc266f806edf2d46b5828
diff --git a/LICENSE b/LICENSE
index 3b12405..d087f95 100644
--- a/LICENSE
+++ b/LICENSE
@@ -220,16 +220,32 @@
All rights reserved. \
3-Clause BSD License (https://github.com/gitpython-developers/GitPython/blob/master/LICENSE)
+Passlib \
+https://bitbucket.org/ecollins/passlib/wiki/Home \
+Copyright (c) 2008-2017 Assurance Technologies, LLC.
+All rights reserved. \
+3-Clause BSD License (https://passlib.readthedocs.io/en/stable/copyright.html)
+
PyMySQL \
https://github.com/PyMySQL/PyMySQL \
Copyright (c) 2010, 2013 PyMySQL contributors \
MIT License (https://github.com/PyMySQL/PyMySQL/blob/master/LICENSE)
+pyOpenSSL \
+https://github.com/pyca/pyopenssl \
+Copyright (c) 2001 The pyOpenSSL developers \
+Apache 2 license (https://github.com/pyca/pyopenssl/blob/master/LICENSE)
+
PyTest \
https://github.com/pytest-dev/pytest \
Copyright (c) 2004-2017 Holger Krekel and others \
MIT License (https://github.com/pytest-dev/pytest/blob/master/LICENSE)
+Requests \
+https://github.com/requests/requests \
+Copyright 2018 Kenneth Reitz \
+Apache 2 license (https://github.com/requests/requests/blob/master/LICENSE)
+
SQLAlchemy \
https://github.com/sqlalchemy/sqlalchemy/ \
Copyright (c) 2005-2019 Michael Bayer and contributors.
diff --git a/Pipfile b/Pipfile
index 1e65319..5a76d6b 100644
--- a/Pipfile
+++ b/Pipfile
@@ -9,6 +9,9 @@
docker = "~=3.5.1"
gitpython = "~=2.1.11"
pytest = "~=4.1"
+passlib = "~=1.7.1"
+pyopenssl = "~=18.0.0"
+requests = "~=2.21.0"
[requires]
python_version = "3.7"
diff --git a/Pipfile.lock b/Pipfile.lock
index 9d2e652..ded8661 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "18176217a070f600694b2169e71d07b6ea68f97805670f2cdd13c846a8329444"
+ "sha256": "93afa239ed3bd403789f0372de7573ca0023b2606bacbf43c8e1e9ba4a215a14"
},
"pipfile-spec": 6,
"requires": {
@@ -16,6 +16,13 @@
]
},
"default": {
+ "asn1crypto": {
+ "hashes": [
+ "sha256:2f1adbb7546ed199e3c90ef23ec95c5cf3585bac7d11fb7eb562a3fe89c64e87",
+ "sha256:9d5c20441baf0cb60a4ac34cc447c6c189024b6b4c6cd7877034f4965c464e49"
+ ],
+ "version": "==0.24.0"
+ },
"atomicwrites": {
"hashes": [
"sha256:0312ad34fcad8fac3704d441f7b317e50af620823353ec657a53e981f92920c0",
@@ -37,6 +44,43 @@
],
"version": "==2018.11.29"
},
+ "cffi": {
+ "hashes": [
+ "sha256:151b7eefd035c56b2b2e1eb9963c90c6302dc15fbd8c1c0a83a163ff2c7d7743",
+ "sha256:1553d1e99f035ace1c0544050622b7bc963374a00c467edafac50ad7bd276aef",
+ "sha256:1b0493c091a1898f1136e3f4f991a784437fac3673780ff9de3bcf46c80b6b50",
+ "sha256:2ba8a45822b7aee805ab49abfe7eec16b90587f7f26df20c71dd89e45a97076f",
+ "sha256:3bb6bd7266598f318063e584378b8e27c67de998a43362e8fce664c54ee52d30",
+ "sha256:3c85641778460581c42924384f5e68076d724ceac0f267d66c757f7535069c93",
+ "sha256:3eb6434197633b7748cea30bf0ba9f66727cdce45117a712b29a443943733257",
+ "sha256:495c5c2d43bf6cebe0178eb3e88f9c4aa48d8934aa6e3cddb865c058da76756b",
+ "sha256:4c91af6e967c2015729d3e69c2e51d92f9898c330d6a851bf8f121236f3defd3",
+ "sha256:57b2533356cb2d8fac1555815929f7f5f14d68ac77b085d2326b571310f34f6e",
+ "sha256:770f3782b31f50b68627e22f91cb182c48c47c02eb405fd689472aa7b7aa16dc",
+ "sha256:79f9b6f7c46ae1f8ded75f68cf8ad50e5729ed4d590c74840471fc2823457d04",
+ "sha256:7a33145e04d44ce95bcd71e522b478d282ad0eafaf34fe1ec5bbd73e662f22b6",
+ "sha256:857959354ae3a6fa3da6651b966d13b0a8bed6bbc87a0de7b38a549db1d2a359",
+ "sha256:87f37fe5130574ff76c17cab61e7d2538a16f843bb7bca8ebbc4b12de3078596",
+ "sha256:95d5251e4b5ca00061f9d9f3d6fe537247e145a8524ae9fd30a2f8fbce993b5b",
+ "sha256:9d1d3e63a4afdc29bd76ce6aa9d58c771cd1599fbba8cf5057e7860b203710dd",
+ "sha256:a36c5c154f9d42ec176e6e620cb0dd275744aa1d804786a71ac37dc3661a5e95",
+ "sha256:a6a5cb8809091ec9ac03edde9304b3ad82ad4466333432b16d78ef40e0cce0d5",
+ "sha256:ae5e35a2c189d397b91034642cb0eab0e346f776ec2eb44a49a459e6615d6e2e",
+ "sha256:b0f7d4a3df8f06cf49f9f121bead236e328074de6449866515cea4907bbc63d6",
+ "sha256:b75110fb114fa366b29a027d0c9be3709579602ae111ff61674d28c93606acca",
+ "sha256:ba5e697569f84b13640c9e193170e89c13c6244c24400fc57e88724ef610cd31",
+ "sha256:be2a9b390f77fd7676d80bc3cdc4f8edb940d8c198ed2d8c0be1319018c778e1",
+ "sha256:ca1bd81f40adc59011f58159e4aa6445fc585a32bb8ac9badf7a2c1aa23822f2",
+ "sha256:d5d8555d9bfc3f02385c1c37e9f998e2011f0db4f90e250e5bc0c0a85a813085",
+ "sha256:e55e22ac0a30023426564b1059b035973ec82186ddddbac867078435801c7801",
+ "sha256:e90f17980e6ab0f3c2f3730e56d1fe9bcba1891eeea58966e89d352492cc74f4",
+ "sha256:ecbb7b01409e9b782df5ded849c178a0aa7c906cf8c5a67368047daab282b184",
+ "sha256:ed01918d545a38998bfa5902c7c00e0fee90e957ce036a4000a88e3fe2264917",
+ "sha256:edabd457cd23a02965166026fd9bfd196f4324fe6032e866d0f3bd0301cd486f",
+ "sha256:fdf1c1dc5bafc32bc5d08b054f94d659422b05aba244d6be4ddc1c72d9aa70fb"
+ ],
+ "version": "==1.11.5"
+ },
"chardet": {
"hashes": [
"sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
@@ -44,6 +88,30 @@
],
"version": "==3.0.4"
},
+ "cryptography": {
+ "hashes": [
+ "sha256:05a6052c6a9f17ff78ba78f8e6eb1d777d25db3b763343a1ae89a7a8670386dd",
+ "sha256:0eb83a24c650a36f68e31a6d0a70f7ad9c358fa2506dc7b683398b92e354a038",
+ "sha256:0ff4a3d6ea86aa0c9e06e92a9f986de7ee8231f36c4da1b31c61a7e692ef3378",
+ "sha256:1699f3e916981df32afdd014fb3164db28cdb61c757029f502cb0a8c29b2fdb3",
+ "sha256:1b1f136d74f411f587b07c076149c4436a169dc19532e587460d9ced24adcc13",
+ "sha256:21e63dd20f5e5455e8b34179ac43d95b3fb1ffa54d071fd2ed5d67da82cfe6dc",
+ "sha256:2454ada8209bbde97065453a6ca488884bbb263e623d35ba183821317a58b46f",
+ "sha256:3cdc5f7ca057b2214ce4569e01b0f368b3de9d8ee01887557755ccd1c15d9427",
+ "sha256:418e7a5ec02a7056d3a4f0c0e7ea81df374205f25f4720bb0e84189aa5fd2515",
+ "sha256:471a097076a7c4ab85561d7fa9a1239bd2ae1f9fd0047520f13d8b340bf3210b",
+ "sha256:5ecaf9e7db3ca582c6de6229525d35db8a4e59dc3e8a40a331674ed90e658cbf",
+ "sha256:63b064a074f8dc61be81449796e2c3f4e308b6eba04a241a5c9f2d05e882c681",
+ "sha256:6afe324dfe6074822ccd56d80420df750e19ac30a4e56c925746c735cf22ae8b",
+ "sha256:70596e90398574b77929cd87e1ac6e43edd0e29ba01e1365fed9c26bde295aa5",
+ "sha256:70c2b04e905d3f72e2ba12c58a590817128dfca08949173faa19a42c824efa0b",
+ "sha256:8908f1db90be48b060888e9c96a0dee9d842765ce9594ff6a23da61086116bb6",
+ "sha256:af12dfc9874ac27ebe57fc28c8df0e8afa11f2a1025566476b0d50cdb8884f70",
+ "sha256:b4fc04326b2d259ddd59ed8ea20405d2e695486ab4c5e1e49b025c484845206e",
+ "sha256:da5b5dda4aa0d5e2b758cc8dfc67f8d4212e88ea9caad5f61ba132f948bab859"
+ ],
+ "version": "==2.4.2"
+ },
"docker": {
"hashes": [
"sha256:31421f16c01ffbd1ea7353c7e7cd7540bf2e5906d6173eb51c8fea4e0ea38b19",
@@ -89,6 +157,14 @@
],
"version": "==5.0.0"
},
+ "passlib": {
+ "hashes": [
+ "sha256:3d948f64138c25633613f303bcc471126eae67c04d5e3f6b7b8ce6242f8653e0",
+ "sha256:43526aea08fa32c6b6dbbbe9963c4c767285b78147b7437597f992812f69d280"
+ ],
+ "index": "pypi",
+ "version": "==1.7.1"
+ },
"pluggy": {
"hashes": [
"sha256:8ddc32f03971bfdf900a81961a48ccf2fb677cf7715108f85295c67405798616",
@@ -103,6 +179,20 @@
],
"version": "==1.7.0"
},
+ "pycparser": {
+ "hashes": [
+ "sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3"
+ ],
+ "version": "==2.19"
+ },
+ "pyopenssl": {
+ "hashes": [
+ "sha256:26ff56a6b5ecaf3a2a59f132681e2a80afcc76b4f902f612f518f92c2a1bf854",
+ "sha256:6488f1423b00f73b7ad5167885312bb0ce410d3312eb212393795b53c8caa580"
+ ],
+ "index": "pypi",
+ "version": "==18.0.0"
+ },
"pytest": {
"hashes": [
"sha256:41568ea7ecb4a68d7f63837cf65b92ce8d0105e43196ff2b26622995bb3dc4b2",
@@ -116,6 +206,7 @@
"sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e",
"sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b"
],
+ "index": "pypi",
"version": "==2.21.0"
},
"six": {
diff --git a/README.md b/README.md
index 8f2d72b..68d5ea8 100644
--- a/README.md
+++ b/README.md
@@ -143,6 +143,16 @@
pipenv run pytest
```
+Some tests will need to create files in a temporary directory. Some of these
+files will be mounted into docker containers by tests. For this to work make
+either sure that the system temporary directory is accessible by the Docker
+daemon or set the base temporary directory to a directory accessible by Docker
+by executing:
+
+```sh
+pipenv run pytest --basetemp=/tmp/k8sgerrit
+```
+
To run specific tests, execute one of the following:
```sh
diff --git a/tests/container-images/apache-git-http-backend/conftest.py b/tests/container-images/apache-git-http-backend/conftest.py
new file mode 100644
index 0000000..48955cc
--- /dev/null
+++ b/tests/container-images/apache-git-http-backend/conftest.py
@@ -0,0 +1,127 @@
+# pylint: disable=W0613
+
+# Copyright (C) 2018 The Android Open Source Project
+#
+# 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.
+
+import os.path
+import random
+import string
+import time
+
+from OpenSSL import crypto
+from passlib.apache import HtpasswdFile
+
+import pytest
+
+@pytest.fixture(scope="module")
+def container_run_factory(
+ docker_client, apache_git_http_backend_image, apache_credentials_dir):
+
+ def run_container(env=None):
+ return docker_client.containers.run(
+ image=apache_git_http_backend_image.id,
+ ports={
+ "80":"8080",
+ "443":"8443"
+ },
+ volumes={
+ str(apache_credentials_dir): {
+ "bind": "/var/apache/credentials",
+ "mode": "ro"}
+ },
+ environment=env,
+ detach=True,
+ auto_remove=True
+ )
+
+ return run_container
+
+@pytest.fixture(scope="module")
+def container_run(request, container_run_factory):
+ container_run = container_run_factory()
+ time.sleep(3)
+
+ def stop_container():
+ container_run.stop(timeout=1)
+
+ request.addfinalizer(stop_container)
+ return container_run
+
+@pytest.fixture(scope="module")
+def basic_auth_creds():
+ return {
+ "user": "git",
+ "password": "secret"
+ }
+
+@pytest.fixture(scope="module")
+def credentials_dir(tmp_path_factory):
+ return tmp_path_factory.mktemp("apache_creds")
+
+@pytest.fixture(scope="module")
+def mock_certificates(credentials_dir):
+ key = crypto.PKey()
+ key.generate_key(crypto.TYPE_RSA, 1024)
+
+ cert = crypto.X509()
+ cert.get_subject().C = "DE"
+ cert.get_subject().O = "Gerrit"
+ cert.get_subject().CN = "localhost"
+ cert.add_extensions(
+ [crypto.X509Extension(b"subjectAltName", False, b"DNS:localhost")])
+ cert.gmtime_adj_notBefore(0)
+ cert.gmtime_adj_notAfter(10*365*24*60*60)
+ cert.set_issuer(cert.get_subject())
+ cert.set_pubkey(key)
+ cert.sign(key, "sha1")
+
+ open(os.path.join(credentials_dir, "server.crt"), "wb").write(
+ crypto.dump_certificate(crypto.FILETYPE_PEM, cert))
+ open(os.path.join(credentials_dir, "server.key"), "wb").write(
+ crypto.dump_privatekey(crypto.FILETYPE_PEM, key))
+
+@pytest.fixture(scope="module")
+def mock_htpasswd(credentials_dir, basic_auth_creds):
+ htpasswd_file = HtpasswdFile(os.path.join(credentials_dir, ".htpasswd"), new=True)
+ htpasswd_file.set_password(
+ basic_auth_creds["user"],
+ basic_auth_creds["password"])
+ htpasswd_file.save()
+
+@pytest.fixture(scope="module")
+def apache_credentials_dir(credentials_dir, mock_certificates, mock_htpasswd):
+ return credentials_dir
+
+@pytest.fixture(scope="module", params=["http", "https"])
+def container_connection_data(request):
+ port = 8080 if request.param == "http" else 8443
+ return {
+ "protocol": request.param,
+ "port": port
+ }
+
+@pytest.fixture(scope="module")
+def base_url(container_connection_data):
+ return "{protocol}://localhost:{port}".format(
+ protocol=container_connection_data["protocol"],
+ port=container_connection_data["port"])
+
+@pytest.fixture(scope="function")
+def random_repo_name():
+ return "".join(
+ [random.choice(string.ascii_letters + string.digits) for n in range(8)])
+
+@pytest.fixture(scope="function")
+def repo_creation_url(base_url, random_repo_name):
+ return "%s/new/%s" % (base_url, random_repo_name)
diff --git a/tests/container-images/apache-git-http-backend/test_container_disable_protocol_apache_git_http_backend.py b/tests/container-images/apache-git-http-backend/test_container_disable_protocol_apache_git_http_backend.py
new file mode 100755
index 0000000..66dbbd4
--- /dev/null
+++ b/tests/container-images/apache-git-http-backend/test_container_disable_protocol_apache_git_http_backend.py
@@ -0,0 +1,67 @@
+# Copyright (C) 2018 The Android Open Source Project
+#
+# 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.
+
+import time
+
+import os.path
+import pytest
+import requests
+
+@pytest.fixture(scope="function", params=["NONE", "DISABLE_HTTP", "DISABLE_HTTPS"])
+def container_run_with_disabled_protocol(request, container_run_factory):
+ if request.param == "NONE":
+ container_run = container_run_factory()
+ else:
+ env = {request.param : "true"}
+ container_run = container_run_factory(env)
+
+ time.sleep(3)
+
+ def stop_container():
+ container_run.stop(timeout=1)
+
+ request.addfinalizer(stop_container)
+
+ return container_run, request.param
+
+def test_apache_git_http_backend_disable_protocol(
+ container_run_with_disabled_protocol,
+ container_connection_data,
+ apache_credentials_dir,
+ basic_auth_creds,
+ repo_creation_url):
+ _, disabled = container_run_with_disabled_protocol
+
+ def execute_request():
+ return requests.get(
+ repo_creation_url,
+ auth=requests.auth.HTTPBasicAuth(
+ basic_auth_creds["user"],
+ basic_auth_creds["password"]),
+ verify=os.path.join(apache_credentials_dir, "server.crt"))
+
+ if disabled == "DISABLE_HTTP":
+ request = execute_request()
+ assert request.status_code == \
+ 201 if container_connection_data["protocol"] == "https" else 500
+ elif disabled == "DISABLE_HTTPS":
+ if container_connection_data["protocol"] == "http":
+ request = execute_request()
+ assert request.status_code == 201
+ elif container_connection_data["protocol"] == "https":
+ with pytest.raises(requests.exceptions.SSLError):
+ request = execute_request()
+ else:
+ request = execute_request()
+ assert request.status_code == 201
diff --git a/tests/container-images/apache-git-http-backend/test_container_integration_apache_git_http_backend.py b/tests/container-images/apache-git-http-backend/test_container_integration_apache_git_http_backend.py
new file mode 100755
index 0000000..e86419a
--- /dev/null
+++ b/tests/container-images/apache-git-http-backend/test_container_integration_apache_git_http_backend.py
@@ -0,0 +1,111 @@
+# pylint: disable=W0613
+
+# Copyright (C) 2018 The Android Open Source Project
+#
+# 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.
+
+from pathlib import Path
+
+import os.path
+
+import git
+import pytest
+import requests
+
+@pytest.fixture(scope="module", params=["http", "https"])
+def base_url(request):
+ port = 8080 if request.param == "http" else 8443
+ return "{protocol}://localhost:{port}".format(
+ protocol=request.param,
+ port=port)
+
+@pytest.fixture(scope="function")
+def repo_dir(tmp_path_factory, random_repo_name):
+ return tmp_path_factory.mktemp(random_repo_name)
+
+@pytest.fixture(scope="function")
+def mock_repo(repo_dir):
+ repo = git.Repo.init(repo_dir)
+ file_name = os.path.join(repo_dir, "test.txt")
+ Path(file_name).touch()
+ repo.index.add([file_name])
+ repo.index.commit("initial commit")
+ return repo
+
+def test_apache_git_http_backend_apache_running(
+ container_run, base_url, apache_credentials_dir):
+ request = requests.get(
+ base_url,
+ verify=os.path.join(apache_credentials_dir, "server.crt"))
+ assert request.status_code == 200
+
+def test_apache_git_http_backend_repo_creation(
+ container_run, apache_credentials_dir, basic_auth_creds, repo_creation_url):
+ request = requests.get(
+ repo_creation_url,
+ auth=requests.auth.HTTPBasicAuth(
+ basic_auth_creds["user"],
+ basic_auth_creds["password"]),
+ verify=os.path.join(apache_credentials_dir, "server.crt"))
+ assert request.status_code == 201
+
+def test_apache_git_http_backend_repo_creation_fails_without_credentials(
+ container_run,
+ apache_credentials_dir,
+ repo_creation_url):
+ request = requests.get(
+ repo_creation_url,
+ verify=os.path.join(apache_credentials_dir, "server.crt"))
+ assert request.status_code == 401
+
+def test_apache_git_http_backend_repo_creation_fails_wrong_fs_permissions(
+ container_run,
+ apache_credentials_dir,
+ basic_auth_creds,
+ repo_creation_url):
+ container_run.exec_run("chown -R root:root /var/gerrit/git")
+ request = requests.get(
+ repo_creation_url,
+ auth=requests.auth.HTTPBasicAuth(
+ basic_auth_creds["user"],
+ basic_auth_creds["password"]),
+ verify=os.path.join(apache_credentials_dir, "server.crt"))
+ container_run.exec_run("chown -R gerrit:users /var/gerrit/git")
+ assert request.status_code == 500
+
+def test_apache_git_http_backend_repo_creation_push_repo(
+ container_run,
+ base_url,
+ apache_credentials_dir,
+ basic_auth_creds,
+ mock_repo,
+ random_repo_name):
+ container_run.exec_run(
+ "su -c 'git init --bare /var/gerrit/git/%s.git' gerrit" % random_repo_name)
+ url = "%s/git/%s.git" % (base_url, random_repo_name)
+ url = url.replace("//", "//%s:%s@" % (
+ basic_auth_creds["user"],
+ basic_auth_creds["password"]))
+ origin = mock_repo.create_remote("origin", url)
+ assert origin.exists()
+ with mock_repo.git.custom_environment(GIT_SSL_NO_VERIFY="true"):
+ origin.fetch()
+ result = origin.push(refspec="master:master")
+ assert result
+ remote_refs = {}
+ git_cmd = git.cmd.Git()
+ with git_cmd.custom_environment(GIT_SSL_NO_VERIFY="true"):
+ for ref in git_cmd.ls_remote(url).split("\n"):
+ hash_ref_list = ref.split("\t")
+ remote_refs[hash_ref_list[1]] = hash_ref_list[0]
+ assert remote_refs["HEAD"] == mock_repo.head.object.hexsha
diff --git a/tests/container-images/apache-git-http-backend/test_container_structure_apache_git_http_backend.py b/tests/container-images/apache-git-http-backend/test_container_structure_apache_git_http_backend.py
index 1315ea2..8ef3290 100755
--- a/tests/container-images/apache-git-http-backend/test_container_structure_apache_git_http_backend.py
+++ b/tests/container-images/apache-git-http-backend/test_container_structure_apache_git_http_backend.py
@@ -12,29 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import pytest
-
-@pytest.fixture(scope="module")
-def container_run(request, docker_client, apache_git_http_backend_image):
- print("Starting apache-git-http-backend-container...")
- container_run = docker_client.containers.run(
- image=apache_git_http_backend_image.id,
- entrypoint="/bin/bash",
- command=["-c", "tail -f /dev/null"],
- user="gerrit",
- detach=True,
- auto_remove=True
- )
-
- def stop_container():
- print("Stopping apache-git-http-backend-container...")
- container_run.stop(timeout=1)
-
- request.addfinalizer(stop_container)
-
- return container_run
-
-
def test_apache_git_http_backend_inherits_from_base(apache_git_http_backend_image):
contains_tag = False
for layer in apache_git_http_backend_image.history():