<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7610">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">test_config: Add test for OpenSSL version<br><br>You can now test for openssl version as you do for sipp.<br><br>properties:<br> dependencies:<br> - asterisk : 'chan_pjsip'<br> - openssl :<br> version: '1.0.1'<br><br>Change-Id: Ib2a3d726a6c9bd83b2658886eb26d5ef7809fa7e<br>---<br>A lib/python/asterisk/opensslversion.py<br>M lib/python/asterisk/test_config.py<br>M sample-yaml/test-config.yaml.sample<br>3 files changed, 83 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/10/7610/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/lib/python/asterisk/opensslversion.py b/lib/python/asterisk/opensslversion.py<br>new file mode 100644<br>index 0000000..a7377ea<br>--- /dev/null<br>+++ b/lib/python/asterisk/opensslversion.py<br>@@ -0,0 +1,70 @@<br>+#!/usr/bin/env python<br>+"""OpenSSL Version String Handling<br>+<br>+Copyright (C) 2017, Digium, Inc.<br>+George Joseph <gjoseph@digium.com><br>+<br>+This program is free software, distributed under the terms of<br>+the GNU General Public License Version 2.<br>+"""<br>+<br>+import sys<br>+import unittest<br>+import re<br>+sys.path.append("lib/python")<br>+<br>+import test_suite_utils<br>+<br>+class OpenSSLVersion:<br>+ """An OpenSSL Version.<br>+<br>+ """<br>+ def __init__(self, version=None, feature=None):<br>+ """Construct a OpenSSL Version parser.<br>+<br>+ Keyword Arguments:<br>+ version The OpenSSL version string to parse.<br>+ If not supplied, the installed version is used.<br>+ """<br>+<br>+ self.version = -1<br>+<br>+ if version is None:<br>+ try:<br>+ from OpenSSL import SSL<br>+ from OpenSSL.SSL import OPENSSL_VERSION_NUMBER as ivers<br>+ except ImportError:<br>+ return<br>+<br>+ self.version = ivers<br>+ else:<br>+ self.version = self.__parse_version(version)<br>+<br>+ def __int__(self):<br>+ """Return the version as an integer value"""<br>+ return self.version<br>+<br>+ def __cmp__(self, other):<br>+ """Compare two SIPpVersion instances against each other"""<br>+ return cmp(self.version, other.version)<br>+<br>+ def __ne__(self, other):<br>+ return self.version != other.version<br>+<br>+ def __eq__(self, other):<br>+ return self.version == other.version<br>+<br>+ def __parse_version(self, version_str):<br>+ """Parse the version string"""<br>+ vv = 0<br>+ if version_str is not None:<br>+ parts = re.split("(\d+)[.](\d+)[.](\d+)([a-z]+)?(?:-(.+))?", version_str)<br>+ if parts[1]:<br>+ vv += int(parts[1]) << 28<br>+ if parts[2]:<br>+ vv += int(parts[2]) << 20<br>+ if parts[3]:<br>+ vv += int(parts[3]) << 12<br>+ if parts[4]:<br>+ vv += (ord(parts[4]) - ord('a')) << 4<br>+ return vv<br>diff --git a/lib/python/asterisk/test_config.py b/lib/python/asterisk/test_config.py<br>index 7775a62..260d292 100644<br>--- a/lib/python/asterisk/test_config.py<br>+++ b/lib/python/asterisk/test_config.py<br>@@ -24,6 +24,7 @@<br> from asterisk import Asterisk<br> from buildoptions import AsteriskBuildOptions<br> from sippversion import SIPpVersion<br>+from opensslversion import OpenSSLVersion<br> <br> <br> class TestConditionConfig(object):<br>@@ -114,6 +115,14 @@<br> self.met = True<br> except ImportError:<br> pass<br>+ elif "openssl" in dep:<br>+ self.name = "OpenSSL"<br>+ self.version = None<br>+ if 'version' in dep['openssl']:<br>+ self.version = dep['openssl']['version']<br>+ ossl_installed = OpenSSLVersion()<br>+ ossl_required = OpenSSLVersion(self.version)<br>+ self.met = ossl_installed >= ossl_required<br> elif "sipp" in dep:<br> self.name = "SIPp"<br> version = None<br>diff --git a/sample-yaml/test-config.yaml.sample b/sample-yaml/test-config.yaml.sample<br>index a8d0f69..8d78b80 100644<br>--- a/sample-yaml/test-config.yaml.sample<br>+++ b/sample-yaml/test-config.yaml.sample<br>@@ -63,6 +63,10 @@<br> - sipp:<br> version: 'v3.3'<br> <br>+ # Specifies attributes of OpenSSL that must be present for this test to execute<br>+ - openssl:<br>+ version: '1.0.1'<br>+<br> # If present, import the yappcap library as a dependency for test execution<br> - 'pcap'<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7610">change 7610</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/7610"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ib2a3d726a6c9bd83b2658886eb26d5ef7809fa7e </div>
<div style="display:none"> Gerrit-Change-Number: 7610 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>