From 7df09ecef53a5ab2d997f86ee4770314e087ebb3 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Mon, 27 Sep 2021 13:28:26 -0700 Subject: [PATCH] Properly copy gerrit static files Dockerfile's COPY directive only copies the contents of a directory when src is a directory. It does not copy the directory itself. This meant the copy we were using to copy static files put them in /var/gerrit and not /var/gerrit/static where we need them to be. Update the Dockerfile to copy to /var/gerrit/static/ to fix this and add some resource fetching tests to ensure they are served correctly. Change-Id: I3bb4c06f3d7a57dcfccbbdb27cb8405586949949 --- docker/gerrit/bazel/Dockerfile | 3 ++- testinfra/test_gerrit.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docker/gerrit/bazel/Dockerfile b/docker/gerrit/bazel/Dockerfile index 7d57eae165..5c1db52c55 100644 --- a/docker/gerrit/bazel/Dockerfile +++ b/docker/gerrit/bazel/Dockerfile @@ -23,6 +23,7 @@ RUN mkdir /var/gerrit/plugins && \ # NOTE(ianw) : copied into build context by playbooks/zuul/gerrit/run.yaml COPY plugins/opendevtheme.html /var/gerrit/plugins/opendevtheme.html -COPY static/ /var/gerrit/ +# Copy copies only the contents of a directory not the directory itself. +COPY static/ /var/gerrit/static/ COPY bazel-bin/plugins/zuul-results-summary/zuul-results-summary.jar /var/gerrit/plugins/zuul-results-summary.jar diff --git a/testinfra/test_gerrit.py b/testinfra/test_gerrit.py index c18a0759d1..fd9218bb19 100644 --- a/testinfra/test_gerrit.py +++ b/testinfra/test_gerrit.py @@ -50,3 +50,18 @@ def test_gerrit_screenshot(host): ) take_screenshots(host, shots) + +def test_opendev_logo(host): + cmd = host.run('curl --head --insecure ' + '--resolve review.opendev.org:443:127.0.0.1 ' + 'https://review.opendev.org/static/opendev-sm.png') + assert '200 OK' in cmd.stdout + assert 'Content-Type: image/png' in cmd.stdout + +def test_openstack_cla(host): + cmd = host.run('curl --include --insecure ' + '--resolve review.opendev.org:443:127.0.0.1 ' + 'https://review.opendev.org/static/cla.html') + assert '200 OK' in cmd.stdout + assert 'Content-Type: text/html' in cmd.stdout + assert 'OpenStack Project Individual Contributor License Agreement' in cmd.stdout