Skip to content

Commit 191b52d

Browse files
authored
Added unit test to setup Mqtt Connect through EC-based certificate and key (#403)
* add ecc unit test * fix format * set key to utf-8 * revert local test changes * test with aws-c-io * make CI only run xos for testing * update c-io for mac ecc key * update io changes * update io changes * update c-io, not release key data too early * update c-io, fix key error * update c io, remove print error * update io: remove key chain * io: update commits * io: error test * io: add back default key_chain * io: test with log * io test * io: ignore failure of key creation * io: update error code * test secitemadd * cleanup memory leak * cleanup memory leak * update the builder script to get ecc test key in binary * fix ecckey file ext * Updated common/io for ecc support. And now we use PEM for ecc keys for macos. * crt/aws-c-io * revert github ci config * update aws-c-io * c-io test * update c-io * update c-io for ecc test * update io lib * c-common * update crt_python format * remove binary options for get_secret
1 parent c88e3f1 commit 191b52d

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

.builder/actions/aws_crt_python.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ def run(self, env):
4848
self._setenv_tmpfile_from_secret('AWS_TEST_TLS_CERT_PATH', 'unit-test/certificate', 'certificate.pem')
4949
self._setenv_tmpfile_from_secret('AWS_TEST_TLS_KEY_PATH', 'unit-test/privatekey', 'privatekey.pem')
5050

51+
self._setenv_tmpfile_from_secret('AWS_TEST_ECC_CERT_PATH', 'ecc-test/certificate', 'ECCcertificate.pem')
52+
self._setenv_tmpfile_from_secret('AWS_TEST_ECC_KEY_PATH', 'ecc-test/privatekey', 'ECCprivatekey.pem')
53+
5154
# enable S3 tests
5255
env.shell.setenv('AWS_TEST_S3', '1')
5356

test/test_mqtt.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_lifetime(self):
2323
client = Client(bootstrap)
2424

2525

26-
AuthType = enum.Enum('AuthType', ['CERT_AND_KEY', 'PKCS11'])
26+
AuthType = enum.Enum('AuthType', ['CERT_AND_KEY', 'PKCS11', 'ECC_CERT_AND_KEY'])
2727

2828

2929
class Config:
@@ -32,6 +32,12 @@ def __init__(self, auth_type):
3232
self.cert_path = self._get_env('AWS_TEST_TLS_CERT_PATH')
3333
self.cert = pathlib.Path(self.cert_path).read_text().encode('utf-8')
3434

35+
if auth_type == AuthType.ECC_CERT_AND_KEY:
36+
self.key_path = self._get_env('AWS_TEST_ECC_KEY_PATH')
37+
self.key = pathlib.Path(self.key_path).read_text().encode('utf-8')
38+
self.cert_path = self._get_env('AWS_TEST_ECC_CERT_PATH')
39+
self.cert = pathlib.Path(self.cert_path).read_text().encode('utf-8')
40+
3541
if auth_type == AuthType.CERT_AND_KEY:
3642
self.key_path = self._get_env('AWS_TEST_TLS_KEY_PATH')
3743
self.key = pathlib.Path(self.key_path).read_text().encode('utf-8')
@@ -60,7 +66,7 @@ class MqttConnectionTest(NativeResourceTest):
6066
def _create_connection(self, auth_type=AuthType.CERT_AND_KEY, use_static_singletons=False):
6167
config = Config(auth_type)
6268

63-
if auth_type == AuthType.CERT_AND_KEY:
69+
if auth_type == AuthType.CERT_AND_KEY or auth_type == AuthType.ECC_CERT_AND_KEY:
6470
tls_opts = TlsContextOptions.create_client_with_mtls_from_path(config.cert_path, config.key_path)
6571
tls = ClientTlsContext(tls_opts)
6672

@@ -106,6 +112,11 @@ def test_connect_disconnect(self):
106112
connection.connect().result(TIMEOUT)
107113
connection.disconnect().result(TIMEOUT)
108114

115+
def test_ecc_connect_disconnect(self):
116+
connection = self._create_connection(AuthType.ECC_CERT_AND_KEY)
117+
connection.connect().result(TIMEOUT)
118+
connection.disconnect().result(TIMEOUT)
119+
109120
def test_pkcs11(self):
110121
connection = self._create_connection(AuthType.PKCS11)
111122
connection.connect().result(TIMEOUT)

0 commit comments

Comments
 (0)