Update CertServiceClient tests with new SANs types

- Add new test with all SANs types
- Add sorting SANs

Issue-ID: OOM-2559
Signed-off-by: Piotr Marcinkiewicz <piotr.marcinkiewicz@nokia.com>
Change-Id: Ic32c410109c8340b776ffc78e967106b0873ac4e
diff --git a/tests/oom-platform-cert-service/certservice/libraries/ArtifactParser.py b/tests/oom-platform-cert-service/certservice/libraries/ArtifactParser.py
index 34512cd..bc796ed 100644
--- a/tests/oom-platform-cert-service/certservice/libraries/ArtifactParser.py
+++ b/tests/oom-platform-cert-service/certservice/libraries/ArtifactParser.py
@@ -1,5 +1,7 @@
 from cryptography.x509.oid import ExtensionOID
-from cryptography import x509
+
+SANS_DELIMITER = ','
+
 
 class ArtifactParser:
 
@@ -19,14 +21,21 @@
     return dict((k, v) for k, v in list)
 
   def get_sans(self, cert):
-    extension = cert.to_cryptography().extensions.get_extension_for_oid(ExtensionOID.SUBJECT_ALTERNATIVE_NAME)
-    dnsList = extension.value.get_values_for_type(x509.DNSName)
-    return ','.join(map(lambda dns: dns.encode('ascii','ignore'), dnsList))
+    sans = cert.to_cryptography().extensions.get_extension_for_oid(ExtensionOID.SUBJECT_ALTERNATIVE_NAME).value
+    sans_strings = [str(alt_name.value) for alt_name in sans]
+    return self.get_sorted_sans(sans_strings)
 
   def get_envs_as_dict(self, list):
     envs = self.get_list_of_pairs_by_mappings(list)
+    SANS = 'SANS'
+    sans_env_strings = SANS in envs and envs[SANS].split(SANS_DELIMITER) or []
+    envs[SANS] = self.get_sorted_sans(sans_env_strings)
     return self.remove_nones_from_dict(envs)
 
+  def get_sorted_sans(self, sans_strings):
+    sans_strings.sort()
+    return SANS_DELIMITER.join(sans_strings)
+
   def remove_nones_from_dict(self, dictionary):
     return dict((k, v) for k, v in dictionary.iteritems() if k is not None)