Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

http_headers: Substitute Nginx version based on OS.

arpit5514f6cd6577c30
diff --git a/.circleci/config.yml b/.circleci/config.yml
index ef178c668f8..ff75b97bd3e 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -299,8 +299,7 @@ jobs:
# Must be relative path from root
paths:
- zulip-server-test.tar.gz
- - success-http-headers-bionic.txt
- - success-http-headers-focal.txt
+ - success-http-headers.template.txt
- production-install
- production-verify
- production-upgrade-pg
diff --git a/tools/ci/production-build b/tools/ci/production-build
index e08f2634680..d9eb426e8c3 100755
--- a/tools/ci/production-build
+++ b/tools/ci/production-build
@@ -32,8 +32,7 @@ fi
# .circleci/config.yml
mv /tmp/tmp.*/zulip-server-test.tar.gz /tmp/
cp -a \
- tools/ci/success-http-headers-bionic.txt \
- tools/ci/success-http-headers-focal.txt \
+ tools/ci/success-http-headers.template.txt \
tools/ci/production-install \
tools/ci/production-verify \
tools/ci/production-upgrade-pg \
diff --git a/tools/ci/production-verify b/tools/ci/production-verify
index 0625fd65ab7..f3b474e040c 100755
--- a/tools/ci/production-verify
+++ b/tools/ci/production-verify
@@ -5,11 +5,6 @@
set -e
set -x
-if [ -f /etc/os-release ]; then
- os_info="$(. /etc/os-release; printf '%s\n' "$VERSION_CODENAME")"
- { read -r os_version_codename || true; } <<< "$os_info"
-fi
-
cat >>/etc/zulip/settings.py <<EOF
# CircleCI override settings above
AUTHENTICATION_BACKENDS = ( 'zproject.backends.EmailAuthBackend', )
@@ -43,13 +38,15 @@ echo; echo "Now testing that the newly installed server's homepage loads"; echo
wget https://localhost -O /tmp/index.html --no-check-certificate -S 2> /tmp/wget-output || true # || true so we see errors.log if this 500s
grep -vi '\(Vary\|Content-Language\|expires\|issued by\|modified\|saved\|[.][.][.]\|Date\|[-][-]\)' /tmp/wget-output > /tmp/http-headers-processed
+nginx_version="$(nginx -v 2>&1 | awk '{print $3, $4}')"
+
# Simplify the diff by getting replacing 4-5 digit length numbers with <Length>.
sed -i 's|Length: [0-9]\+\( [(][0-9]\+[.][0-9]K[)]\)\?|Length: <Length>|' /tmp/http-headers-processed
-sed -i 's|Length: [0-9]\+\( [(][0-9]\+[.][0-9]K[)]\)\?|Length: <Length>|' /tmp/success-http-headers-"$os_version_codename".txt
-if ! diff -ur /tmp/http-headers-processed /tmp/success-http-headers-"$os_version_codename".txt; then
+sed -i -e 's|Length: [0-9]\+\( [(][0-9]\+[.][0-9]K[)]\)\?|Length: <Length>|' -e "s|{nginx_version_string}|$nginx_version|g" /tmp/success-http-headers.template.txt
+if ! diff -ur /tmp/http-headers-processed /tmp/success-http-headers.template.txt; then
set +x
echo
- echo "FAILURE: The HTTP Headers returned from loading the homepage on the server do not match the contents of tools/ci/success-http-headers.txt. Typically, this means that the server threw a 500 when trying to load the homepage."
+ echo "FAILURE: The HTTP Headers returned from loading the homepage on the server do not match the contents of tools/ci/success-http-headers.template.txt. Typically, this means that the server threw a 500 when trying to load the homepage."
echo "Displaying the contents of the server's error log:"
echo
cat /var/log/zulip/errors.log
diff --git a/tools/ci/success-http-headers-focal.txt b/tools/ci/success-http-headers-focal.txt
deleted file mode 100644
index 8fa7d472062..00000000000
--- a/tools/ci/success-http-headers-focal.txt
+++ /dev/null
@@ -1,28 +0,0 @@
- Self-signed certificate encountered.
- WARNING: certificate common name ‘127.0.0.1’ doesn't match requested host name ‘localhost’.
- HTTP/1.1 302 Found
- Server: nginx/1.18.0 (Ubuntu)
- Content-Type: text/html; charset=utf-8
- Content-Length: 0
- Connection: keep-alive
- Location: /login/
- Strict-Transport-Security: max-age=15768000
- X-Frame-Options: DENY
- X-Content-Type-Options: nosniff
- X-XSS-Protection: 1; mode=block
-Location: /login/ [following]
-Reusing existing connection to localhost:443.
- HTTP/1.1 200 OK
- Server: nginx/1.18.0 (Ubuntu)
- Content-Type: text/html; charset=utf-8
- Content-Length: 6361
- Connection: keep-alive
- Strict-Transport-Security: max-age=15768000
- X-Frame-Options: DENY
- X-Content-Type-Options: nosniff
- X-XSS-Protection: 1; mode=block
-Length: 6361 (6.2K) [text/html]
-Saving to: ‘/tmp/index.html’
-
-
-
diff --git a/tools/ci/success-http-headers-bionic.txt b/tools/ci/success-http-headers.template.txt
similarity index 92%
rename from tools/ci/success-http-headers-bionic.txt
rename to tools/ci/success-http-headers.template.txt
index 20c863ed5b9..113cb9da654 100644
--- a/tools/ci/success-http-headers-bionic.txt
+++ b/tools/ci/success-http-headers.template.txt
@@ -1,7 +1,7 @@
Self-signed certificate encountered.
WARNING: certificate common name ‘127.0.0.1’ doesn't match requested host name ‘localhost’.
HTTP/1.1 302 Found
- Server: nginx/1.14.0 (Ubuntu)
+ Server: {nginx_version_string}
Content-Type: text/html; charset=utf-8
Content-Length: 0
Connection: keep-alive
@@ -13,7 +13,7 @@
Location: /login/ [following]
Reusing existing connection to localhost:443.
HTTP/1.1 200 OK
- Server: nginx/1.14.0 (Ubuntu)
+ Server: {nginx_version_string}
Content-Type: text/html; charset=utf-8
Content-Length: 6361
Connection: keep-alive
diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py
index a7a9392df8d..2bf7b76b580 100644
--- a/tools/linter_lib/custom_check.py
+++ b/tools/linter_lib/custom_check.py
@@ -65,7 +65,7 @@ whitespace_rules: List["Rule"] = [
},
{'pattern': '\t',
'strip': '\n',
- 'exclude': {'tools/ci/success-http-headers-bionic.txt', 'tools/ci/success-http-headers-focal.txt'},
+ 'exclude': {'tools/ci/success-http-headers.template.txt'},
'description': 'Fix tab-based whitespace'},
]
comma_whitespace_rule: List["Rule"] = [