From 11d36560215acd592038c5d64b9d3a2a3b69e11c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florent=20Thi=C3=A9ry?= <florent.thiery@ubicast.eu>
Date: Thu, 23 Feb 2017 12:21:03 +0100
Subject: [PATCH] add apt cache test, refs #20589

---
 tests/test_apt_proxy.py | 44 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100755 tests/test_apt_proxy.py

diff --git a/tests/test_apt_proxy.py b/tests/test_apt_proxy.py
new file mode 100755
index 00000000..6be5d671
--- /dev/null
+++ b/tests/test_apt_proxy.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2017, Florent Thiery
+'''
+Criticality: Normal
+Checks that packages mirror works for capture systems 
+'''
+import os
+import sys
+import requests
+import imp
+
+GREEN = '\033[92m'
+RED = '\033[91m'
+DEF = '\033[0m'
+
+os.chdir(os.path.dirname(__file__))
+if not os.path.isfile('../utils.py'):
+    print('conf.sh not found')
+    sys.exit(1)
+
+es_utils = imp.load_source('es_utils', '../utils.py')
+conf = es_utils.load_conf()
+
+all_ok = True
+
+conf_servers = (
+    'CM_SERVER_NAME',
+)
+
+for s in conf_servers:
+    v = conf.get(s)
+    try:
+        url = "https://%s/old-releases.ubuntu.com/ubuntu/dists/lucid/Release.gpg" % v
+        print('Checking url certificate %s' % url)
+        d = requests.get(url, verify=False)
+        if not "BEGIN PGP SIGNATURE" in d:
+            all_ok = False
+            print('Unexpected content: %s' % d)
+    except Exception:
+        print('Package mirror not working')
+        all_ok = False
+
+sys.exit(int(not all_ok))
-- 
GitLab