Skip to content

Commit b2a009c

Browse files
committed
Test cases
1 parent 3f59161 commit b2a009c

2 files changed

Lines changed: 440 additions & 15 deletions

File tree

awscrt/aws_iot_metrics.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -249,61 +249,61 @@ def _get_encoded_feature_list(client_options):
249249
if client_options.retry_jitter_mode is not None:
250250
val = _retry_jitter_metrics_value(client_options.retry_jitter_mode)
251251
if val:
252-
features.append(f"{MetricsFeatureId.RETRY_JITTER_MODE}/{val}")
252+
features.append(f"{MetricsFeatureId.RETRY_JITTER_MODE.value}/{val}")
253253

254254
# B: session_behavior
255255
if client_options.session_behavior is not None:
256256
val = _client_session_behavior_metrics_value(client_options.session_behavior)
257257
if val:
258-
features.append(f"{MetricsFeatureId.SESSION_BEHAVIOR}/{val}")
258+
features.append(f"{MetricsFeatureId.SESSION_BEHAVIOR.value}/{val}")
259259

260260
# C: offline_queue_behavior
261261
if client_options.offline_queue_behavior is not None:
262262
val = _client_operation_queue_behavior_metrics_value(client_options.offline_queue_behavior)
263263
if val:
264-
features.append(f"{MetricsFeatureId.OFFLINE_QUEUE_BEHAVIOR}/{val}")
264+
features.append(f"{MetricsFeatureId.OFFLINE_QUEUE_BEHAVIOR.value}/{val}")
265265

266266
# D: outbound_topic_alias_behavior
267267
if client_options.topic_aliasing_options is not None:
268268
if client_options.topic_aliasing_options.outbound_behavior is not None:
269269
val = _outbound_topic_alias_behavior_metrics_value(client_options.topic_aliasing_options.outbound_behavior)
270270
if val:
271-
features.append(f"{MetricsFeatureId.OUTBOUND_TOPIC_ALIAS_BEHAVIOR}/{val}")
271+
features.append(f"{MetricsFeatureId.OUTBOUND_TOPIC_ALIAS_BEHAVIOR.value}/{val}")
272272

273273
# E: inbound_topic_alias_behavior
274274
if client_options.topic_aliasing_options is not None:
275275
if client_options.topic_aliasing_options.inbound_behavior is not None:
276276
val = _inbound_topic_alias_behavior_metrics_value(client_options.topic_aliasing_options.inbound_behavior)
277277
if val:
278-
features.append(f"{MetricsFeatureId.INBOUND_TOPIC_ALIAS_BEHAVIOR}/{val}")
278+
features.append(f"{MetricsFeatureId.INBOUND_TOPIC_ALIAS_BEHAVIOR.value}/{val}")
279279

280280
# F: protocol_version - MQTT5 always uses client options
281-
features.append(f"{MetricsFeatureId.PROTOCOL_VERSION}/{MetricsProtocolVersionValue.MQTT5}")
281+
features.append(f"{MetricsFeatureId.PROTOCOL_VERSION.value}/{MetricsProtocolVersionValue.MQTT5.value}")
282282

283283
# G: socket_implementation - Detect based on platform
284-
features.append(f"{MetricsFeatureId.SOCKET_IMPLEMENTATION}/{_detect_socket_implementation()}")
284+
features.append(f"{MetricsFeatureId.SOCKET_IMPLEMENTATION.value}/{_detect_socket_implementation().value}")
285285

286286
# H: http_proxy_type - Determine based on whether proxy uses TLS
287287
if client_options.http_proxy_options is not None:
288288
proxy_type = MetricsHttpProxyTypeValue.HTTPS if getattr(
289289
client_options.http_proxy_options,
290290
'tls_connection_options',
291291
None) is not None else MetricsHttpProxyTypeValue.HTTP
292-
features.append(f"{MetricsFeatureId.HTTP_PROXY_TYPE}/{proxy_type}")
292+
features.append(f"{MetricsFeatureId.HTTP_PROXY_TYPE.value}/{proxy_type.value}")
293293

294294
# I: certificate_source - Would need to be tracked from TLS context setup. This is set at a IoT SDK level
295295

296296
# J: tls_cipher_preference - security policy
297297
if client_options.tls_ctx is not None:
298298
val = _tls_cipher_preference_metrics_value(client_options.tls_ctx.cipher_pref)
299299
if val:
300-
features.append(f"{MetricsFeatureId.TLS_CIPHER_PREFERENCE}/{val}")
300+
features.append(f"{MetricsFeatureId.TLS_CIPHER_PREFERENCE.value}/{val}")
301301

302302
# K: minimum_tls_version - The minimum TLS version set on TLSContextOptions
303303
if client_options.tls_ctx is not None:
304304
val = _minimum_tls_version_metrics_value(client_options.tls_ctx.min_tls_ver)
305305
if val:
306-
features.append(f"{MetricsFeatureId.MINIMUM_TLS_VERSION}/{val}")
306+
features.append(f"{MetricsFeatureId.MINIMUM_TLS_VERSION.value}/{val}")
307307

308308
return ",".join(features)
309309

@@ -331,26 +331,26 @@ def _get_encoded_feature_list_mqtt3(proxy_options, tls_ctx=None):
331331
str: The encoded feature list string.
332332
"""
333333
features = [
334-
f"{MetricsFeatureId.PROTOCOL_VERSION}/{MetricsProtocolVersionValue.MQTT311}",
335-
f"{MetricsFeatureId.SOCKET_IMPLEMENTATION}/{_detect_socket_implementation()}"
334+
f"{MetricsFeatureId.PROTOCOL_VERSION.value}/{MetricsProtocolVersionValue.MQTT311.value}",
335+
f"{MetricsFeatureId.SOCKET_IMPLEMENTATION.value}/{_detect_socket_implementation().value}"
336336
]
337337
# H: http_proxy_type - Determine based on whether proxy uses TLS
338338
if proxy_options is not None:
339339
proxy_type = MetricsHttpProxyTypeValue.HTTPS if getattr(
340340
proxy_options, 'tls_connection_options', None) is not None else MetricsHttpProxyTypeValue.HTTP
341-
features.append(f"{MetricsFeatureId.HTTP_PROXY_TYPE}/{proxy_type}")
341+
features.append(f"{MetricsFeatureId.HTTP_PROXY_TYPE.value}/{proxy_type.value}")
342342

343343
# J: tls_cipher_preference - security policy
344344
if tls_ctx is not None:
345345
val = _tls_cipher_preference_metrics_value(tls_ctx.cipher_pref)
346346
if val:
347-
features.append(f"{MetricsFeatureId.TLS_CIPHER_PREFERENCE}/{val}")
347+
features.append(f"{MetricsFeatureId.TLS_CIPHER_PREFERENCE.value}/{val}")
348348

349349
# K: minimum_tls_version - the minimum TLS version set on TLSContextOptions
350350
if tls_ctx is not None:
351351
val = _minimum_tls_version_metrics_value(tls_ctx.min_tls_ver)
352352
if val:
353-
features.append(f"{MetricsFeatureId.MINIMUM_TLS_VERSION}/{val}")
353+
features.append(f"{MetricsFeatureId.MINIMUM_TLS_VERSION.value}/{val}")
354354

355355
return ",".join(features)
356356

0 commit comments

Comments
 (0)