holado 0.2.8__py3-none-any.whl → 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of holado might be problematic. Click here for more details.

Files changed (110) hide show
  1. holado/common/handlers/undefined.py +7 -1
  2. {holado-0.2.8.dist-info → holado-0.4.0.dist-info}/METADATA +4 -1
  3. {holado-0.2.8.dist-info → holado-0.4.0.dist-info}/RECORD +108 -101
  4. holado_ais/ais/ais_messages.py +97 -6
  5. holado_ais/tests/behave/steps/ais/ais_manager_steps.py +1 -1
  6. holado_ais/tests/behave/steps/ais/ais_messages_steps.py +45 -6
  7. holado_binary/ipc/bit_series.py +3 -3
  8. holado_binary/tests/behave/steps/ipc/binary_steps.py +1 -1
  9. holado_binary/tests/behave/steps/ipc/bit_series_steps.py +4 -3
  10. holado_context/tests/behave/steps/private/common/context_steps.py +1 -1
  11. holado_core/common/resource/persisted_data_manager.py +13 -16
  12. holado_core/common/resource/resource_manager.py +10 -10
  13. holado_core/common/tables/converters/table_converter.py +47 -9
  14. holado_core/common/tables/table_manager.py +6 -7
  15. holado_core/common/tables/table_with_header.py +6 -0
  16. holado_core/tests/behave/steps/common/common_steps.py +2 -1
  17. holado_core/tests/behave/steps/common/config_steps.py +1 -1
  18. holado_core/tests/behave/steps/common/resource_steps.py +1 -1
  19. holado_core/tests/behave/steps/common/tables_steps.py +18 -2
  20. holado_data/data/generator/generator_manager.py +39 -0
  21. holado_data/tests/behave/steps/data/generator_steps.py +1 -1
  22. holado_data/tests/behave/steps/tools/utils_steps.py +1 -2
  23. holado_db/tests/behave/steps/tools/db/db_client_steps.py +1 -1
  24. holado_db/tests/behave/steps/tools/db/postgresql_client_steps.py +1 -1
  25. holado_db/tests/behave/steps/tools/db/sqlite_client_steps.py +1 -1
  26. holado_db/tools/db/clients/base/db_client.py +81 -28
  27. holado_db/tools/db/clients/postgresql/postgresql_client.py +17 -7
  28. holado_db/tools/db/query/base/query_builder.py +58 -7
  29. holado_db/tools/db/query/pypika/pypika_query_builder.py +73 -21
  30. holado_docker/tests/behave/steps/tools/docker_steps.py +1 -1
  31. holado_grpc/tests/behave/steps/api/grpc_client_steps.py +1 -1
  32. holado_grpc/tests/behave/steps/private/api/grpc_steps.py +1 -1
  33. holado_json/tests/behave/steps/ipc/json_steps.py +1 -1
  34. holado_keycloak/tests/behave/steps/tools/keycloak_client_steps.py +1 -1
  35. holado_multitask/tests/behave/steps/multiprocessing_steps.py +1 -1
  36. holado_multitask/tests/behave/steps/multithreading_steps.py +1 -1
  37. holado_protobuf/ipc/protobuf/types/google/protobuf.py +1 -1
  38. holado_protobuf/tests/behave/steps/ipc/protobuf_steps.py +1 -1
  39. holado_python/common/tools/datetime.py +31 -12
  40. holado_python/standard_library/socket/blocking_socket.py +37 -24
  41. holado_python/standard_library/socket/message_socket.py +11 -3
  42. holado_python/standard_library/socket/non_blocking_socket.py +24 -24
  43. holado_python/standard_library/socket/socket.py +132 -19
  44. holado_python/standard_library/ssl/resources/certificates/NOTES.txt +1 -1
  45. holado_python/standard_library/ssl/resources/certificates/rootCACert.pem +24 -0
  46. holado_python/standard_library/ssl/resources/certificates/tcpbin.crt +21 -0
  47. holado_python/standard_library/ssl/resources/certificates/tcpbin.key +28 -0
  48. holado_python/standard_library/ssl/ssl.py +138 -21
  49. holado_python/tests/behave/steps/convert_steps.py +1 -1
  50. holado_python/tests/behave/steps/iterable_steps.py +1 -1
  51. holado_python/tests/behave/steps/standard_library/csv_steps.py +1 -1
  52. holado_python/tests/behave/steps/standard_library/datetime_steps.py +1 -1
  53. holado_python/tests/behave/steps/standard_library/hashlib_steps.py +2 -2
  54. holado_python/tests/behave/steps/standard_library/multiprocessing_steps.py +1 -1
  55. holado_python/tests/behave/steps/standard_library/queue_steps.py +1 -1
  56. holado_python/tests/behave/steps/standard_library/socket_steps.py +132 -18
  57. holado_python/tests/behave/steps/standard_library/ssl_steps.py +87 -16
  58. holado_rabbitmq/tests/behave/steps/tools/rabbitmq_client_steps.py +48 -20
  59. holado_rabbitmq/tests/behave/steps/tools/rabbitmq_server_steps.py +1 -1
  60. holado_rabbitmq/tools/rabbitmq/rabbitmq_client.py +19 -13
  61. holado_rabbitmq/tools/rabbitmq/rabbitmq_manager.py +2 -29
  62. holado_redis/tests/behave/steps/tools/redis_client_steps.py +1 -1
  63. holado_rest/api/rest/rest_client.py +18 -1
  64. holado_rest/api/rest/rest_manager.py +5 -0
  65. holado_rest/tests/behave/steps/api/rest_client_steps.py +52 -11
  66. holado_rest/tests/behave/steps/private/api/rest_steps.py +1 -1
  67. holado_s3/tests/behave/steps/private/tools/s3_steps.py +1 -1
  68. holado_s3/tests/behave/steps/tools/s3_client_steps.py +1 -1
  69. holado_s3/tests/behave/steps/tools/s3_server_steps.py +1 -1
  70. holado_scripting/tests/behave/steps/common/tools/variable_convert_steps.py +3 -2
  71. holado_scripting/tests/behave/steps/common/tools/variable_new_steps.py +1 -1
  72. holado_scripting/tests/behave/steps/common/tools/variable_steps.py +1 -1
  73. holado_scripting/tests/behave/steps/common/tools/variable_verify_steps.py +1 -1
  74. holado_scripting/tests/behave/steps/scenario/function_steps.py +1 -1
  75. holado_scripting/tests/behave/steps/scenario/if_steps.py +1 -1
  76. holado_scripting/tests/behave/steps/scenario/loop_steps.py +1 -1
  77. holado_sftp/tests/behave/steps/private/tools/sftp_steps.py +1 -1
  78. holado_sftp/tests/behave/steps/tools/sftp_client_steps.py +1 -1
  79. holado_sftp/tests/behave/steps/tools/sftp_server_steps.py +1 -1
  80. holado_swagger/tests/behave/steps/swagger_hub/mockserver_steps.py +1 -1
  81. holado_system/system/command/command.py +14 -9
  82. holado_system/tests/behave/steps/system/commands_steps.py +1 -1
  83. holado_system/tests/behave/steps/system/file_steps.py +1 -1
  84. holado_system/tests/behave/steps/system/system_steps.py +1 -1
  85. holado_test/scenario/step_tools.py +1 -1
  86. holado_test/scenario/tester_tools.py +6 -3
  87. holado_test/tests/behave/steps/scenario/exception_steps.py +1 -1
  88. holado_test/tests/behave/steps/scenario/scenario_steps.py +1 -1
  89. holado_test/tests/behave/steps/scenario/tester_steps.py +4 -4
  90. holado_value/common/tables/converters/value_table_converter.py +52 -8
  91. holado_value/common/tables/value_table_manager.py +0 -10
  92. holado_ws/tests/behave/steps/api/web_service_steps.py +1 -1
  93. holado_yaml/tests/behave/steps/yaml_steps.py +1 -1
  94. holado_yaml/yaml/yaml_manager.py +2 -2
  95. test_holado/features/NonReg/common/tables/table.feature +30 -24
  96. test_holado/features/NonReg/holado_ais/ais_message-bitarray_to_nmea.feature +1 -1
  97. test_holado/features/NonReg/holado_python/standard_library/socket/local_echo_server/socket_reset.feature +191 -0
  98. test_holado/features/NonReg/holado_python/standard_library/{socket_with_ssl.feature → socket/local_echo_server/socket_with_tls_and_verify.feature} +53 -30
  99. test_holado/features/NonReg/holado_python/standard_library/socket/local_echo_server/socket_with_tls_without_verify.feature +299 -0
  100. test_holado/features/NonReg/holado_python/standard_library/{socket.feature → socket/local_echo_server/socket_without_tls.feature} +2 -2
  101. test_holado/features/NonReg/holado_python/standard_library/socket/tcpbin.com/socket_with_mtls.feature +214 -0
  102. test_holado/features/NonReg/holado_python/standard_library/socket/tcpbin.com/socket_with_tls.feature +184 -0
  103. test_holado/features/NonReg/holado_python/standard_library/socket/tcpbin.com/socket_without_tls.feature +169 -0
  104. test_holado/features/NonReg/tools/RabbitMQ.feature +9 -9
  105. test_holado/features/NonReg/tools/RabbitMQ_steps.feature +8 -8
  106. test_holado/logging.conf +5 -3
  107. holado_core/common/transport/__init__.py +0 -0
  108. holado_core/common/transport/crc.py +0 -40
  109. {holado-0.2.8.dist-info → holado-0.4.0.dist-info}/WHEEL +0 -0
  110. {holado-0.2.8.dist-info → holado-0.4.0.dist-info}/licenses/LICENSE +0 -0
@@ -15,16 +15,11 @@
15
15
 
16
16
  from holado_test.scenario.step_tools import StepTools
17
17
  from holado.common.context.session_context import SessionContext
18
- from holado_test.behave.behave import *
18
+ from holado_test.behave.behave import * # @UnusedWildImport
19
19
  import logging
20
+ from holado_python.standard_library.ssl.ssl import SslManager
20
21
  from holado_test.behave.scenario.behave_step_tools import BehaveStepTools
21
22
  from holado_value.common.tables.converters.value_table_converter import ValueTableConverter
22
- from holado_python.standard_library.socket.blocking_socket import TCPBlockingSocketClient
23
- from holado_python.standard_library.socket.echo_server import EchoTCPBlockingSocketServer
24
- from holado_python.standard_library.socket.message_socket import MessageTCPNonBlockingSocketClient
25
- from holado_core.common.handlers.wait import WaitFuncResultVerifying, WaitEndChange
26
- from holado_core.common.exceptions.functional_exception import FunctionalException
27
- from holado_python.standard_library.ssl.ssl import SslManager
28
23
 
29
24
  logger = logging.getLogger(__name__)
30
25
 
@@ -40,28 +35,104 @@ def __get_variable_manager():
40
35
 
41
36
 
42
37
 
43
- @Given(r"(?P<var_name>{Variable}) = certfile path for localhost")
38
+ @Given(r"(?P<var_name>{Variable}) = default CA certs file path")
44
39
  def step_impl(context, var_name):
45
- """Return path to cert file for localhost stored in internal resources.
46
- Note: It is an autosigned certificate.
40
+ """Return path to default cert file.
41
+ Note: It uses ssl.get_default_verify_paths method.
47
42
  """
48
43
  var_name = StepTools.evaluate_variable_name(var_name)
49
44
 
50
- cert_paths = SslManager.get_localhost_certificate()
45
+ default_certs = SslManager.get_default_certificates()
51
46
 
52
- __get_variable_manager().register_variable(var_name, cert_paths[0])
47
+ __get_variable_manager().register_variable(var_name, default_certs[0])
48
+
49
+
50
+ @Given(r"(?P<var_name>{Variable}) = default certs directory path")
51
+ def step_impl(context, var_name):
52
+ """Return path to default certs folder.
53
+ Note: It uses ssl.get_default_verify_paths method.
54
+ """
55
+ var_name = StepTools.evaluate_variable_name(var_name)
56
+
57
+ default_certs = SslManager.get_default_certificates()
58
+
59
+ __get_variable_manager().register_variable(var_name, default_certs[1])
53
60
 
54
61
 
55
- @Given(r"(?P<var_name>{Variable}) = keyfile path for localhost")
62
+ @Given(r"(?P<var_name>{Variable}) = CA certs file path \(from certifi package\)")
56
63
  def step_impl(context, var_name):
57
- """Return path to key file for localhost stored in internal resources.
58
- Note: It is an autosigned certificate.
64
+ """Return path to CA certs file from 'certifi' package.
59
65
  """
60
66
  var_name = StepTools.evaluate_variable_name(var_name)
61
67
 
62
- cert_paths = SslManager.get_localhost_certificate()
68
+ cacerts_path = SslManager.get_certifi_ca_certs_file_path()
63
69
 
70
+ __get_variable_manager().register_variable(var_name, cacerts_path)
71
+
72
+
73
+ # @Given(r"(?P<var_name>{Variable}) = certfile path for localhost")
74
+ # def step_impl(context, var_name):
75
+ # """Return path to cert file for localhost stored in internal resources.
76
+ # Note: It is an autosigned certificate.
77
+ # """
78
+ # var_name = StepTools.evaluate_variable_name(var_name)
79
+ #
80
+ # cert_paths = SslManager.get_localhost_certificate()
81
+ #
82
+ # __get_variable_manager().register_variable(var_name, cert_paths[0])
83
+ #
84
+ #
85
+ # @Given(r"(?P<var_name>{Variable}) = keyfile path for localhost")
86
+ # def step_impl(context, var_name):
87
+ # """Return path to key file for localhost stored in internal resources.
88
+ # Note: It is an autosigned certificate.
89
+ # """
90
+ # var_name = StepTools.evaluate_variable_name(var_name)
91
+ #
92
+ # cert_paths = SslManager.get_localhost_certificate()
93
+ #
94
+ # __get_variable_manager().register_variable(var_name, cert_paths[1])
95
+
96
+ @Given(r"generate new self-signed key files for localhost")
97
+ def step_impl(context):
98
+ """Generate public and private keys for a localhost use.
99
+ """
100
+ table = BehaveStepTools.convert_step_table_2_value_table_with_header(context.table)
101
+ kwargs = ValueTableConverter.convert_name_value_table_2_dict(table)
102
+
103
+ SslManager.generate_new_self_signed_key_files_for_localhost(**kwargs)
104
+
105
+
106
+ @Given(r"(?P<var_name>{Variable}) = certfile path for tcpbin.com")
107
+ def step_impl(context, var_name):
108
+ """Return path to cert file for tcpbin.com stored in internal resources.
109
+ Note: If certificate has expired, a new one is generated.
110
+ """
111
+ var_name = StepTools.evaluate_variable_name(var_name)
112
+
113
+ cert_paths = SslManager.get_tcpbin_certificates()
114
+
115
+ __get_variable_manager().register_variable(var_name, cert_paths[0])
116
+
117
+ @Given(r"(?P<var_name>{Variable}) = keyfile path for tcpbin.com")
118
+ def step_impl(context, var_name):
119
+ """Return path to key file for tcpbin.com stored in internal resources.
120
+ Note: If certificate has expired, a new one is generated.
121
+ """
122
+ var_name = StepTools.evaluate_variable_name(var_name)
123
+
124
+ cert_paths = SslManager.get_tcpbin_certificates()
125
+
64
126
  __get_variable_manager().register_variable(var_name, cert_paths[1])
65
127
 
128
+ @Given(r"(?P<var_name>{Variable}) = CA certfile path for tcpbin.com")
129
+ def step_impl(context, var_name):
130
+ """Return path to cert file for tcpbin.com stored in internal resources.
131
+ Note: If certificate has expired, a new one is generated.
132
+ """
133
+ var_name = StepTools.evaluate_variable_name(var_name)
134
+
135
+ cert_paths = SslManager.get_tcpbin_certificates()
66
136
 
137
+ __get_variable_manager().register_variable(var_name, cert_paths[2])
67
138
 
@@ -16,7 +16,7 @@
16
16
  from holado_value.common.tables.comparators.table_2_value_table_comparator import Table2ValueTable_Comparator
17
17
  from holado_test.scenario.step_tools import StepTools
18
18
  from holado.common.context.session_context import SessionContext
19
- from holado_test.behave.behave import *
19
+ from holado_test.behave.behave import * # @UnusedWildImport
20
20
  from holado_rabbitmq.tools.rabbitmq import rabbitmq_client
21
21
  from holado_core.common.tables.table_manager import TableManager
22
22
  from holado_core.common.exceptions.functional_exception import FunctionalException
@@ -369,43 +369,41 @@ if rabbitmq_client.RMQClient.is_available():
369
369
  rate = counter / (end - beg)
370
370
  logger.print(f"[Queue {q_name} -> Publisher {pub_name}] Mean rate: {int(rate)} msg/s ; Nb messages: {counter}")
371
371
 
372
- @When(r"wait consumer (?P<var_con>{Variable}) receives messages(?: \(timeout: (?P<timeout_sec>{Float}) s(?: ; polling: (?P<polling_sec>{Float}) s)?(?: ; )?(?:raise: (?P<do_raise>{Boolean}))?\))?")
373
- def step_impl(context, var_con, timeout_sec, polling_sec, do_raise):
372
+ @When(r"await consumer (?P<var_con>{Variable}) receives a message(?: \(timeout: (?P<timeout_sec>{Float}) s(?: ; polling: (?P<polling_sec>{Float}) s)?\))?")
373
+ def step_impl(context, var_con, timeout_sec, polling_sec):
374
374
  con = StepTools.evaluate_variable_value(var_con)
375
375
  timeout_sec = StepTools.evaluate_scenario_parameter(timeout_sec)
376
376
  polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
377
- do_raise = StepTools.evaluate_scenario_parameter(do_raise)
378
377
 
379
- __get_rabbitmq_manager().wait_message_reception([con], timeout_seconds=timeout_sec, polling_seconds=polling_sec, raise_exception=do_raise)
378
+ __get_rabbitmq_manager().await_message_reception([con], timeout_seconds=timeout_sec, polling_seconds=polling_sec)
380
379
 
381
- @When(r"wait consumers (?P<list_consumers>{List}) receive messages(?: \(timeout: (?P<timeout_sec>{Float}) s(?: ; polling: (?P<polling_sec>{Float}) s)?(?: ; )?(?:raise: (?P<do_raise>{Boolean}))?\))?")
382
- def step_impl(context, list_consumers, timeout_sec, polling_sec, do_raise):
380
+ @When(r"await consumers (?P<list_consumers>{List}) receive a message(?: \(timeout: (?P<timeout_sec>{Float}) s(?: ; polling: (?P<polling_sec>{Float}) s)?\))?")
381
+ def step_impl(context, list_consumers, timeout_sec, polling_sec):
383
382
  consumers = StepTools.evaluate_list_scenario_parameter(list_consumers, "list_consumers")
384
383
  timeout_sec = StepTools.evaluate_scenario_parameter(timeout_sec)
385
384
  polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
386
- do_raise = StepTools.evaluate_scenario_parameter(do_raise)
387
385
 
388
- __get_rabbitmq_manager().wait_message_reception(consumers, timeout_seconds=timeout_sec, polling_seconds=polling_sec, raise_exception=do_raise)
386
+ __get_rabbitmq_manager().await_message_reception(consumers, timeout_seconds=timeout_sec, polling_seconds=polling_sec)
389
387
 
390
- @When(r"wait consumer (?P<var_con>{Variable}) stops to receive messages(?: \((?:first timeout: (?P<first_timeout_sec>{Float}) s)?(?: ; )?(?:window: (?P<window_sec>{Float}) s)?(?: ; )?(?:polling: (?P<polling_sec>{Float}) s)?(?: ; )?(?:raise: (?P<do_raise>{Boolean}))?\))?")
391
- def step_impl(context, var_con, first_timeout_sec, window_sec, polling_sec, do_raise):
388
+ @When(r"await consumer (?P<var_con>{Variable}) receives (?:(?P<no_str>no) )?messages(?: \((?:first timeout: (?P<first_timeout_sec>{Float}) s)?(?: ; )?(?:window: (?P<window_sec>{Float}) s)?(?: ; )?(?:polling: (?P<polling_sec>{Float}) s)?\))?")
389
+ def step_impl(context, var_con, no_str, first_timeout_sec, window_sec, polling_sec):
392
390
  con = StepTools.evaluate_variable_value(var_con)
393
391
  first_timeout_sec = StepTools.evaluate_scenario_parameter(first_timeout_sec)
394
392
  window_sec = StepTools.evaluate_scenario_parameter(window_sec)
395
393
  polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
396
- do_raise = StepTools.evaluate_scenario_parameter(do_raise)
394
+ do_raise = no_str is None
397
395
 
398
- __get_rabbitmq_manager().wait_end_message_reception([con], first_timeout_seconds=first_timeout_sec, window_seconds=window_sec, polling_seconds=polling_sec, raise_exception=do_raise)
396
+ __get_rabbitmq_manager().await_messages_reception([con], first_timeout_seconds=first_timeout_sec, window_seconds=window_sec, polling_seconds=polling_sec, raise_exception=do_raise)
399
397
 
400
- @When(r"wait consumers (?P<list_consumers>{List}) stop to receive messages(?: \((?:first timeout: (?P<first_timeout_sec>{Float}) s)?(?: ; )?(?:window: (?P<window_sec>{Float}) s)?(?: ; )?(?:polling: (?P<polling_sec>{Float}) s)?(?: ; )?(?:raise: (?P<do_raise>{Boolean}))?\))?")
401
- def step_impl(context, list_consumers, first_timeout_sec, window_sec, polling_sec, do_raise):
398
+ @When(r"await consumers (?P<list_consumers>{List}) receive (?:(?P<no_str>no) )?messages(?: \((?:first timeout: (?P<first_timeout_sec>{Float}) s)?(?: ; )?(?:window: (?P<window_sec>{Float}) s)?(?: ; )?(?:polling: (?P<polling_sec>{Float}) s)?\))?")
399
+ def step_impl(context, list_consumers, no_str, first_timeout_sec, window_sec, polling_sec):
402
400
  consumers = StepTools.evaluate_list_scenario_parameter(list_consumers, "list_consumers")
403
401
  first_timeout_sec = StepTools.evaluate_scenario_parameter(first_timeout_sec)
404
402
  window_sec = StepTools.evaluate_scenario_parameter(window_sec)
405
403
  polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
406
- do_raise = StepTools.evaluate_scenario_parameter(do_raise)
404
+ do_raise = no_str is None
407
405
 
408
- __get_rabbitmq_manager().wait_end_message_reception(consumers, first_timeout_seconds=first_timeout_sec, window_seconds=window_sec, polling_seconds=polling_sec, raise_exception=do_raise)
406
+ __get_rabbitmq_manager().await_messages_reception(consumers, first_timeout_seconds=first_timeout_sec, window_seconds=window_sec, polling_seconds=polling_sec, raise_exception=do_raise)
409
407
 
410
408
  @Then(r"consumer (?P<var_con>{Variable}) doesn't receive any message \(timeout: (?P<timeout_sec>{Float}) s ; polling: (?P<polling_sec>{Float}) s\)")
411
409
  def step_impl(context, var_con, timeout_sec, polling_sec):
@@ -413,7 +411,7 @@ if rabbitmq_client.RMQClient.is_available():
413
411
  timeout_sec = StepTools.evaluate_scenario_parameter(timeout_sec)
414
412
  polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
415
413
 
416
- nb = __get_rabbitmq_manager().wait_message_reception([con], timeout_seconds=timeout_sec, polling_seconds=polling_sec, raise_exception=False)
414
+ nb = __get_rabbitmq_manager().await_message_reception([con], timeout_seconds=timeout_sec, polling_seconds=polling_sec, raise_exception=False)
417
415
  if nb > 0:
418
416
  raise FunctionalException(f"Consumer has received {nb} messages")
419
417
 
@@ -423,7 +421,7 @@ if rabbitmq_client.RMQClient.is_available():
423
421
  timeout_sec = StepTools.evaluate_scenario_parameter(timeout_sec)
424
422
  polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
425
423
 
426
- nb = __get_rabbitmq_manager().wait_message_reception(consumers, timeout_seconds=timeout_sec, polling_seconds=polling_sec, raise_exception=False)
424
+ nb = __get_rabbitmq_manager().await_message_reception(consumers, timeout_seconds=timeout_sec, polling_seconds=polling_sec, raise_exception=False)
427
425
  if nb > 0:
428
426
  raise FunctionalException(f"Consumer has received {nb} messages")
429
427
 
@@ -533,5 +531,35 @@ if rabbitmq_client.RMQClient.is_available():
533
531
  def step_impl(context, queue, var_client):
534
532
  queue = StepTools.evaluate_scenario_parameter(queue)
535
533
  client = StepTools.evaluate_variable_value(var_client)
536
- client.connection.channel().queue_purge(queue)
534
+ client.purge_queue(queue)
537
535
 
536
+ @Step(r"delete and recreate stream queue (?P<queue>{Str}) \(RMQ client: (?P<var_client>{Variable})\)")
537
+ def step_impl(context, queue, var_client):
538
+ queue_name = StepTools.evaluate_scenario_parameter(queue)
539
+ client = StepTools.evaluate_variable_value(var_client)
540
+ client.delete_queue(queue_name)
541
+ client._queue_declare(
542
+ channel=client.connection.channel(),
543
+ queue=queue_name,
544
+ queue_args={
545
+ 'durable': True,
546
+ "x-queue-type": "stream",
547
+ "x-stream-max-segment-size-bytes": 100000000
548
+ })
549
+
550
+ @Step(r"bind queue (?P<queue>{Str}) to exchange (?P<exchange>{Str})(?: with routine key (?P<routine_key>{Str}))? \(RMQ client: (?P<var_client>{Variable})\)")
551
+ def step_impl(context, queue, exchange, routine_key, var_client):
552
+ queue_name = StepTools.evaluate_scenario_parameter(queue)
553
+ exchange = StepTools.evaluate_scenario_parameter(exchange)
554
+ routine_key = StepTools.evaluate_scenario_parameter(routine_key)
555
+ client = StepTools.evaluate_variable_value(var_client)
556
+ bind_args={
557
+ 'routing_key': routine_key
558
+ }
559
+ client._queue_bind(
560
+ channel=client.connection.channel(),
561
+ queue=queue_name,
562
+ exchange=exchange,
563
+ bind_args=bind_args
564
+ )
565
+
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
  from holado.common.context.session_context import SessionContext
17
- from holado_test.behave.behave import *
17
+ from holado_test.behave.behave import * # @UnusedWildImport
18
18
  from holado_rabbitmq.tools.rabbitmq import rabbitmq_server
19
19
  import logging
20
20
  from holado_test.scenario.step_tools import StepTools
@@ -209,7 +209,7 @@ class RMQClient(DeleteableObject):
209
209
  def _new_publisher_with_connection(self, connection, queue, queue_args=None, exchange="", exchange_args=None, routing_key=None, nb_runners=None):
210
210
  pub_channel = connection.channel()
211
211
 
212
- queue_name = self.__prepare_queue(pub_channel, queue, queue_args, exchange, exchange_args, bind_args=None)
212
+ queue_name = self._prepare_queue(pub_channel, queue, queue_args, exchange, exchange_args, bind_args=None)
213
213
  if self.connection.publisher_confirms:
214
214
  pub_channel.set_confirm_delivery()
215
215
  else:
@@ -236,7 +236,7 @@ class RMQClient(DeleteableObject):
236
236
 
237
237
  if self.is_consuming:
238
238
  raise FunctionalException(f"[{self.name}] Not allowed to create a new consumer while consuming is started")
239
- queue_name = self.__prepare_queue(con_channel, queue, queue_args, exchange, exchange_args, bind_args)
239
+ queue_name = self._prepare_queue(con_channel, queue, queue_args, exchange, exchange_args, bind_args)
240
240
  res = RMQConsumer(self, connection, con_channel, queue_name, message_callback)
241
241
  self.__consumer_and_kwargs.append( self.__new_object_kwargs(res, queue=queue, message_callback=message_callback, queue_args=queue_args, exchange=exchange, exchange_args=exchange_args, bind_args=bind_args) )
242
242
  return res
@@ -249,7 +249,7 @@ class RMQClient(DeleteableObject):
249
249
 
250
250
  if self.is_consuming:
251
251
  raise FunctionalException(f"[{self.name}] Not allowed to create a new consumer while consuming is started")
252
- queue_name = self.__prepare_queue(con_channel, queue, queue_args, exchange, exchange_args, bind_args)
252
+ queue_name = self._prepare_queue(con_channel, queue, queue_args, exchange, exchange_args, bind_args)
253
253
  res = RMQBufferConsumer(self, connection, con_channel, queue_name)
254
254
  self.__buffer_consumer_and_kwargs.append( self.__new_object_kwargs(res, queue=queue, queue_args=queue_args, exchange=exchange, exchange_args=exchange_args, bind_args=bind_args) )
255
255
  return res
@@ -324,25 +324,31 @@ class RMQClient(DeleteableObject):
324
324
  if Tools.do_log(logger, logging.DEBUG):
325
325
  logger.debug(f"[{self.name}] Finished stop data events processing")
326
326
 
327
- def __prepare_queue(self, channel, queue, queue_args=None, exchange="", exchange_args=None, bind_args=None):
327
+ def _prepare_queue(self, channel, queue, queue_args=None, exchange="", exchange_args=None, bind_args=None):
328
328
  if exchange is not None and exchange != "":
329
- self.__exchange_declare(channel, exchange, exchange_args)
329
+ self._exchange_declare(channel, exchange, exchange_args)
330
330
 
331
331
  if queue is not None and queue != "":
332
- self.__queue_declare(channel, queue, queue_args)
332
+ self._queue_declare(channel, queue, queue_args)
333
333
  queue_name = queue
334
334
  else:
335
335
  q_args = dict(queue_args) if queue_args else {}
336
336
  q_args['exclusive'] = True
337
- result = self.__queue_declare(channel, queue, q_args)
337
+ result = self._queue_declare(channel, queue, q_args)
338
338
  queue_name = result.method.queue
339
339
 
340
340
  if exchange is not None and exchange != "":
341
- self.__queue_bind(channel, queue_name, exchange, bind_args)
341
+ self._queue_bind(channel, queue_name, exchange, bind_args)
342
342
 
343
343
  return queue_name
344
-
345
- def __exchange_declare(self, channel, exchange, exchange_args=None):
344
+
345
+ def delete_queue(self, queue):
346
+ self.connection.channel().queue_delete(queue=queue)
347
+
348
+ def purge_queue(self, queue):
349
+ self.connection.channel().queue_purge(queue)
350
+
351
+ def _exchange_declare(self, channel, exchange, exchange_args=None):
346
352
  kwargs = {}
347
353
  arguments = None
348
354
  if exchange_args:
@@ -352,7 +358,7 @@ class RMQClient(DeleteableObject):
352
358
  kwargs[name] = arguments.pop(name)
353
359
  return channel.exchange_declare(exchange, arguments=arguments, **kwargs)
354
360
 
355
- def __queue_declare(self, channel, queue, queue_args=None):
361
+ def _queue_declare(self, channel, queue, queue_args=None):
356
362
  kwargs = {}
357
363
  arguments = None
358
364
  if queue_args:
@@ -362,7 +368,7 @@ class RMQClient(DeleteableObject):
362
368
  kwargs[name] = arguments.pop(name)
363
369
  return channel.queue_declare(queue, arguments=arguments, **kwargs)
364
370
 
365
- def __queue_bind(self, channel, queue, exchange, bind_args=None):
371
+ def _queue_bind(self, channel, queue, exchange, bind_args=None):
366
372
  kwargs = {}
367
373
  arguments = None
368
374
  if bind_args:
@@ -374,7 +380,7 @@ class RMQClient(DeleteableObject):
374
380
 
375
381
  def get_queue_message_count(self, queue):
376
382
  channel = self.connection.channel()
377
- status = self.__queue_declare(channel, queue, {'passive':True})
383
+ status = self._queue_declare(channel, queue, {'passive':True})
378
384
  return status.method.message_count
379
385
 
380
386
  def is_queue_empty(self, queue, raise_exception=False):
@@ -36,39 +36,12 @@ class RMQManager:
36
36
  return res
37
37
 
38
38
 
39
- def wait_message_reception(self, consumers, timeout_seconds=None, polling_seconds=None, raise_exception=True):
39
+ def await_message_reception(self, consumers, timeout_seconds=None, polling_seconds=None, raise_exception=True):
40
40
  """Wait until one of the buffer consumers has received a message.
41
41
  @param consumers: list of buffer consumers
42
42
  @param timeout_seconds: wait timeout
43
43
  @param polling_seconds: time to wait between pollings of received messages of all consumers
44
44
  """
45
- # res = 0
46
- #
47
- # if timeout_seconds is None:
48
- # timeout_seconds = Config.timeout_seconds
49
- # if polling_seconds is None:
50
- # polling_seconds = timeout_seconds / 1000
51
- # if polling_seconds > 0.01:
52
- # polling_seconds = 0.01
53
- #
54
- # # Wait first message
55
- # dt_begin = datetime.now()
56
- # dt_last_poll = dt_begin
57
- # while (dt_last_poll - dt_begin).total_seconds() < timeout_seconds:
58
- # nb_msg_by_consumer = {c.name: c.nb_messages for c in consumers if c.nb_messages > 0}
59
- # dt_last_poll = datetime.now()
60
- # if len(nb_msg_by_consumer) > 0:
61
- # if Tools.do_log(logger, logging.DEBUG):
62
- # logger.debug(f"Received messages: " + " ; ".join(f"{k}:{v}" for k,v in nb_msg_by_consumer.items()))
63
- # res = sum(nb_msg_by_consumer.values())
64
- # if res > 0:
65
- # break
66
- # time.sleep(polling_seconds)
67
- #
68
- # if res == 0 and raise_exception:
69
- # names = ",".join([c.name for c in consumers])
70
- # raise FunctionalException(f"[{names}] No message was received (timeout: {timeout_seconds} seconds)")
71
- # return res
72
45
  if raise_exception is None:
73
46
  raise_exception = True
74
47
 
@@ -90,7 +63,7 @@ class RMQManager:
90
63
 
91
64
  #TODO EKL: add a first_accepted_seconds and a accepted_window_seconds to be able to raise an exception that first or next message arrived but too late
92
65
  #TODO EKL: change use of polling_seconds to something like a timer, rather than waiting polling_seconds
93
- def wait_end_message_reception(self, consumers, first_timeout_seconds=None, window_seconds=None, polling_seconds=None, raise_exception=True):
66
+ def await_messages_reception(self, consumers, first_timeout_seconds=None, window_seconds=None, polling_seconds=None, raise_exception=True):
94
67
  """Wait until buffer consumers stop to receive messages.
95
68
  It begins by waiting a first message in any consumer, since their creation or last reset.
96
69
  If no consumer receives a first message during first_timeout_seconds period, wait stops.
@@ -15,7 +15,7 @@
15
15
 
16
16
  from holado_test.scenario.step_tools import StepTools
17
17
  from holado.common.context.session_context import SessionContext
18
- from holado_test.behave.behave import *
18
+ from holado_test.behave.behave import * # @UnusedWildImport
19
19
  from holado_core.common.exceptions.technical_exception import TechnicalException
20
20
  from holado_scripting.text.interpreter.text_interpreter import TextInterpreter
21
21
  from holado_scripting.common.tools.variable_manager import VariableManager
@@ -15,6 +15,7 @@ from holado_core.common.exceptions.functional_exception import FunctionalExcepti
15
15
  from holado_core.common.exceptions.technical_exception import TechnicalException
16
16
  import logging
17
17
  from holado_core.common.tools.tools import Tools
18
+ import json
18
19
 
19
20
  logger = logging.getLogger(__name__)
20
21
 
@@ -56,6 +57,13 @@ class RestClient(object):
56
57
  if Tools.do_log(logger, logging.DEBUG):
57
58
  logger.debug(f"[{self.name}] Authenticate with token type '{token_type}' and access token '{access_token}'")
58
59
  self.__headers['Authorization'] = f'{token_type} {access_token}'
60
+
61
+ def with_ssl(self, ssl_kwargs):
62
+ unexpected_keys = set(ssl_kwargs.keys()).difference(['verify', 'cert'])
63
+ if len(unexpected_keys) > 0:
64
+ raise TechnicalException(f"Unmanaged SSL arguments: {unexpected_keys}")
65
+
66
+ self.__kwargs.update(ssl_kwargs)
59
67
 
60
68
  def response_result(self, response, status_ok=200):
61
69
  if response.status_code != status_ok:
@@ -63,8 +71,10 @@ class RestClient(object):
63
71
 
64
72
  if "application/json" in response.headers['Content-Type']:
65
73
  return response.json()
66
- else:
74
+ elif response.headers['Content-Type'].startswith('text'):
67
75
  return response.text
76
+ else:
77
+ return response.content
68
78
 
69
79
  def request(self, method, path, **kwargs):
70
80
  url = self.__build_url(path=path)
@@ -104,6 +114,13 @@ class RestClient(object):
104
114
  if self.__headers:
105
115
  res['headers'] = self.__headers
106
116
  if request_kwargs:
117
+ # Ensure data is in json string format
118
+ if 'data' in request_kwargs:
119
+ data = request_kwargs.pop('data')
120
+ if not isinstance(data, str):
121
+ data = json.dumps(data)
122
+ res['data'] = data
123
+
107
124
  for key in list(request_kwargs.keys()):
108
125
  if key in res and isinstance(res[key], dict):
109
126
  res[key].update(request_kwargs.pop(key))
@@ -33,6 +33,7 @@ class RestManager(object):
33
33
  url = kwargs.pop("url")
34
34
  headers = Tools.pop_sub_kwargs(kwargs, "headers.")
35
35
  authentication = Tools.pop_sub_kwargs(kwargs, "authentication.")
36
+ ssl_kwargs = Tools.pop_sub_kwargs(kwargs, "ssl.")
36
37
  if len(kwargs) > 0:
37
38
  raise TechnicalException(f"Unmanaged arguments: {kwargs}")
38
39
 
@@ -53,6 +54,10 @@ class RestManager(object):
53
54
  else:
54
55
  raise TechnicalException(f"Unmanaged authentication type '{authentication.keys()}' (possible authentication types: 'user', 'token'")
55
56
 
57
+ # Manage ssl if needed
58
+ if len(ssl_kwargs) > 0:
59
+ res.with_ssl(ssl_kwargs)
60
+
56
61
  return res
57
62
 
58
63
  def _new_rest_client(self, name, url, headers):
@@ -15,7 +15,7 @@
15
15
 
16
16
  from holado_test.scenario.step_tools import StepTools
17
17
  from holado.common.context.session_context import SessionContext
18
- from holado_test.behave.behave import *
18
+ from holado_test.behave.behave import * # @UnusedWildImport
19
19
  from holado_core.common.exceptions.technical_exception import TechnicalException
20
20
  from holado_rest.api.rest.rest_client import RestClient
21
21
  import json
@@ -63,21 +63,62 @@ if RestClient.is_available():
63
63
  var_name = StepTools.evaluate_variable_name(var_name)
64
64
  path = StepTools.evaluate_scenario_parameter(path)
65
65
  client = StepTools.evaluate_variable_value(var_client)
66
+
67
+ # Manage request arguments as step table
68
+ request_kwargs = {}
69
+ if hasattr(context, "table") and context.table is not None:
70
+ table = BehaveStepTools.convert_step_table_2_value_table_with_header(context.table)
71
+ request_kwargs = ValueTableConverter.convert_name_value_table_2_json_object(table)
72
+
73
+ # Manage request arguments as json text
74
+ # Manage data as json text
75
+ text = BehaveStepTools.get_step_multiline_text(context, raise_exception_if_none=False)
76
+ if text is not None:
77
+ if len(request_kwargs) > 0:
78
+ raise TechnicalException(f"Request kwargs are already set to {request_kwargs}")
79
+ request_kwargs = json.loads(text)
80
+
81
+ # Process request
82
+ res = client.request(request_method, path, **request_kwargs)
83
+
84
+ # Store result
85
+ if Tools.do_log(logger, logging.DEBUG):
86
+ res_table = TableManager.convert_object_attributes_2_name_value_table(res)
87
+ logger.debug(f"Response of {request_method} {path}:\n{res_table.represent(4)}")
88
+ __get_variable_manager().register_variable(var_name, res)
89
+
90
+ @Step(r"(?P<var_name>{Variable}) = (?P<request_method>delete|get|patch|post|put) (?P<path>{Str}) \(REST client: (?P<var_client>{Variable})\)")
91
+ def step_impl(context, var_name, request_method, path, var_client):
92
+ var_name = StepTools.evaluate_variable_name(var_name)
93
+ client = StepTools.evaluate_variable_value(var_client)
66
94
 
67
- # Manage data as table
95
+ execute_steps(format_step_with_context(context,
96
+ u"__RESPONSE__@ = response of {request_method} {path} (REST client: {var_client})"
97
+ .format(request_method=request_method, path=path, var_client=var_client) ))
98
+
99
+ response = __get_variable_manager().get_variable_value("__RESPONSE__@")
100
+ res = client.response_result(response)
101
+
102
+ __get_variable_manager().register_variable(var_name, res)
103
+
104
+ @Step(r"(?P<var_name>{Variable}) = response of (?P<request_method>delete|get|patch|post|put) (?P<path>{Str}) with data \(REST client: (?P<var_client>{Variable})\)")
105
+ def step_impl(context, var_name, request_method, path, var_client):
106
+ var_name = StepTools.evaluate_variable_name(var_name)
107
+ path = StepTools.evaluate_scenario_parameter(path)
108
+ client = StepTools.evaluate_variable_value(var_client)
109
+
68
110
  data = None
111
+
112
+ # Manage request arguments as step table
69
113
  if hasattr(context, "table") and context.table is not None:
70
114
  table = BehaveStepTools.convert_step_table_2_value_table_with_header(context.table)
71
- data_obj = ValueTableConverter.convert_name_value_table_2_json_object(table)
72
- data = json.dumps(data_obj)
73
- if Tools.do_log(logger, logging.TRACE): # @UndefinedVariable
74
- logger.trace(f"Transformed parameters to JSON is: {data}")
75
-
115
+ json_obj = ValueTableConverter.convert_name_value_table_2_json_object(table)
116
+ data = json.dumps(json_obj)
117
+
118
+ # Manage request arguments as json text
76
119
  # Manage data as json text
77
120
  text = BehaveStepTools.get_step_multiline_text(context, raise_exception_if_none=False)
78
121
  if text is not None:
79
- if request_method in ['delete', 'get']:
80
- raise TechnicalException(f"Unexpected json text for request method '{request_method}'")
81
122
  if data is not None:
82
123
  raise TechnicalException(f"Data is already set to [{data}]")
83
124
  data = text
@@ -91,13 +132,13 @@ if RestClient.is_available():
91
132
  logger.debug(f"Response of {request_method} {path}:\n{res_table.represent(4)}")
92
133
  __get_variable_manager().register_variable(var_name, res)
93
134
 
94
- @When(r"(?P<var_name>{Variable}) = (?P<request_method>delete|get|patch|post|put) (?P<path>{Str}) \(REST client: (?P<var_client>{Variable})\)")
135
+ @Step(r"(?P<var_name>{Variable}) = (?P<request_method>delete|get|patch|post|put) (?P<path>{Str}) with data \(REST client: (?P<var_client>{Variable})\)")
95
136
  def step_impl(context, var_name, request_method, path, var_client):
96
137
  var_name = StepTools.evaluate_variable_name(var_name)
97
138
  client = StepTools.evaluate_variable_value(var_client)
98
139
 
99
140
  execute_steps(format_step_with_context(context,
100
- u"__RESPONSE__@ = response of {request_method} {path} (REST client: {var_client})"
141
+ u"__RESPONSE__@ = response of {request_method} {path} with data (REST client: {var_client})"
101
142
  .format(request_method=request_method, path=path, var_client=var_client) ))
102
143
 
103
144
  response = __get_variable_manager().get_variable_value("__RESPONSE__@")
@@ -13,7 +13,7 @@
13
13
  #################################################
14
14
 
15
15
  from holado.common.context.session_context import SessionContext
16
- from holado_test.behave.behave import *
16
+ from holado_test.behave.behave import * # @UnusedWildImport
17
17
  import os.path
18
18
  import logging
19
19
  from holado_test.scenario.step_tools import StepTools
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
  from holado.common.context.session_context import SessionContext
17
- from holado_test.behave.behave import *
17
+ from holado_test.behave.behave import * # @UnusedWildImport
18
18
  from holado_scripting.common.tools.variable_manager import VariableManager
19
19
  import logging
20
20
  from holado_test.scenario.step_tools import StepTools
@@ -15,7 +15,7 @@
15
15
 
16
16
  from holado_test.scenario.step_tools import StepTools
17
17
  from holado.common.context.session_context import SessionContext
18
- from holado_test.behave.behave import *
18
+ from holado_test.behave.behave import * # @UnusedWildImport
19
19
  from holado_core.common.exceptions.functional_exception import FunctionalException
20
20
  from holado_core.common.exceptions.technical_exception import TechnicalException
21
21
  from holado_scripting.common.tools.variable_manager import VariableManager
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
  from holado.common.context.session_context import SessionContext
17
- from holado_test.behave.behave import *
17
+ from holado_test.behave.behave import * # @UnusedWildImport
18
18
  from holado_s3.tools.s3.moto_server import MotoServer
19
19
  import logging
20
20
  from holado_test.behave.scenario.behave_step_tools import BehaveStepTools
@@ -15,7 +15,7 @@
15
15
 
16
16
  from holado_test.scenario.step_tools import StepTools
17
17
  from holado.common.context.session_context import SessionContext
18
- from holado_test.behave.behave import *
18
+ from holado_test.behave.behave import * # @UnusedWildImport
19
19
  from holado_core.common.exceptions.functional_exception import FunctionalException
20
20
  from holado_core.common.exceptions.technical_exception import TechnicalException
21
21
  import base64
@@ -26,6 +26,7 @@ from holado_value.common.tables.value_table_with_header import ValueTableWithHea
26
26
  from holado_value.common.tables.value_table import ValueTable
27
27
  from holado_core.common.tools.tools import Tools
28
28
  from holado_python.standard_library.typing import Typing
29
+ from holado_value.common.tables.value_table_manager import ValueTableManager
29
30
 
30
31
  logger = logging.getLogger(__name__)
31
32
 
@@ -98,7 +99,7 @@ def step_impl(context, var_name, object_value):
98
99
  row = None
99
100
 
100
101
  if row is not None:
101
- if isinstance(table, ValueTable) or isinstance(table, ValueTableWithHeader):
102
+ if ValueTableManager.is_value_table(table):
102
103
  res = [c.value for c in row]
103
104
  else:
104
105
  res = [c.content for c in row]