Changeset b2546f0 in mod_gnutls for test/mgstest/softhsm.py
- Timestamp:
- Jan 9, 2020, 5:44:38 PM (3 years ago)
- Branches:
- asyncio, main, master, proxy-ticket
- Children:
- 20a3915
- Parents:
- 221ffe5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/mgstest/softhsm.py
r221ffe5 rb2546f0 20 20 import subprocess 21 21 import tempfile 22 from enum import Enum, auto 22 23 from pathlib import Path 23 24 … … 35 36 tokendir_re = re.compile(r'^directories\.tokendir\s*=\s*(.*)$') 36 37 37 test_key_label = 'privkey' 38 test_cert_label = 'certificate' 38 test_label = 'test_server' 39 40 class ObjectType(Enum): 41 """Types that may occur in PKCS#11 URIs (type=...). 42 43 See: https://tools.ietf.org/html/rfc7512#section-2.3 44 45 """ 46 CERT = 'cert' 47 DATA = 'data' 48 PRIVATE = 'private' 49 PUBLIC = 'public' 50 SECRET_KEY = 'secret-key' 51 52 def __init__(self, uri_type): 53 self.uri_type = uri_type 54 55 def __str__(self): 56 """ 57 >>> str(ObjectType.CERT) 58 'type=cert' 59 """ 60 return f'type={self.uri_type}' 61 62 def __repr__(self): 63 """ 64 >>> repr(ObjectType.PRIVATE) 65 'ObjectType.PRIVATE' 66 """ 67 return f'{self.__class__.__name__!s}.{self.name}' 39 68 40 69 class Token: … … 116 145 self._object_listing = None 117 146 118 def get_object_url(self, label ):147 def get_object_url(self, label, type): 119 148 """Get the PKCS#11 URL for an object in this token, selected by 120 149 label.""" … … 128 157 for line in self._object_listing: 129 158 m = object_re.fullmatch(line) 130 if m :159 if m and str(type) in m.group(1): 131 160 return m.group(1) 132 161 … … 139 168 'SOFTHSM_LIB': str(Path(self.softhsm_lib).resolve()), 140 169 'P11_PIN': self.pin, 141 'P11_CERT_URL': self.get_object_url(test_ cert_label),142 'P11_KEY_URL': self.get_object_url(test_ key_label)170 'P11_CERT_URL': self.get_object_url(test_label, ObjectType.CERT), 171 'P11_KEY_URL': self.get_object_url(test_label, ObjectType.PRIVATE) 143 172 } 144 173
Note: See TracChangeset
for help on using the changeset viewer.