ruby_rabbitmq_janus 3.0.0.pre.336 → 3.0.0.pre.351

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +80 -29
  3. data/bin/ruby_rabbitmq_janus +1 -1
  4. data/config/default.yml +1 -3
  5. data/config/requests/admin/allow_token.json +2 -1
  6. data/config/requests/admin/disallow_token.json +2 -1
  7. data/config/requests/admin/set_session_timeout.json +2 -3
  8. data/config/requests/peer/trickles.json +7 -0
  9. data/lib/rrj/admin.rb +0 -2
  10. data/lib/rrj/errors/error.rb +7 -2
  11. data/lib/rrj/errors/janus/janus.rb +3 -17
  12. data/lib/rrj/errors/janus/messages/message.rb +1 -1
  13. data/lib/rrj/errors/janus/responses/admin.rb +67 -23
  14. data/lib/rrj/errors/janus/responses/base.rb +15 -0
  15. data/lib/rrj/errors/janus/responses/code.rb +41 -0
  16. data/lib/rrj/errors/janus/responses/event.rb +23 -28
  17. data/lib/rrj/errors/janus/responses/standard.rb +43 -32
  18. data/lib/rrj/errors/janus/transactions/transaction.rb +1 -1
  19. data/lib/rrj/errors/process/concurency.rb +1 -1
  20. data/lib/rrj/errors/rabbit/listener/base.rb +8 -1
  21. data/lib/rrj/init.rb +5 -8
  22. data/lib/rrj/janus/janus.rb +6 -6
  23. data/lib/rrj/janus/messages/admin.rb +1 -5
  24. data/lib/rrj/janus/messages/message.rb +0 -10
  25. data/lib/rrj/janus/messages/standard.rb +0 -4
  26. data/lib/rrj/janus/responses/admin.rb +50 -9
  27. data/lib/rrj/janus/responses/error.rb +159 -0
  28. data/lib/rrj/janus/responses/event.rb +14 -14
  29. data/lib/rrj/janus/responses/response.rb +43 -13
  30. data/lib/rrj/janus/responses/standard.rb +46 -14
  31. data/lib/rrj/janus/transactions/admin.rb +0 -6
  32. data/lib/rrj/janus/transactions/handle.rb +0 -10
  33. data/lib/rrj/janus/transactions/session.rb +0 -6
  34. data/lib/rrj/janus/transactions/transaction.rb +0 -2
  35. data/lib/rrj/models/concerns/instances.rb +0 -4
  36. data/lib/rrj/process/concurrency.rb +0 -2
  37. data/lib/rrj/process/event.rb +0 -4
  38. data/lib/rrj/process/event_admin.rb +0 -4
  39. data/lib/rrj/rabbit/base_event.rb +0 -2
  40. data/lib/rrj/rabbit/connect.rb +0 -12
  41. data/lib/rrj/rabbit/listener/base.rb +10 -8
  42. data/lib/rrj/rabbit/listener/from.rb +0 -3
  43. data/lib/rrj/rabbit/listener/from_admin.rb +0 -3
  44. data/lib/rrj/rabbit/propertie.rb +7 -9
  45. data/lib/rrj/rabbit/publisher/admin.rb +0 -4
  46. data/lib/rrj/rabbit/publisher/base.rb +0 -4
  47. data/lib/rrj/rabbit/publisher/exclusive.rb +0 -4
  48. data/lib/rrj/rabbit/publisher/keepalive.rb +0 -4
  49. data/lib/rrj/rabbit/publisher/non_exclusive.rb +0 -4
  50. data/lib/rrj/task.rb +0 -2
  51. data/lib/rrj/tools/bin/config.rb +2 -1
  52. data/lib/rrj/tools/gem/cluster.rb +0 -4
  53. data/lib/rrj/tools/gem/config/queues.rb +0 -5
  54. data/lib/rrj/tools/gem/{log.rb → logger.rb} +0 -0
  55. data/lib/rrj/tools/gem/option.rb +1 -6
  56. data/lib/rrj/tools/gem/requests.rb +0 -2
  57. data/lib/rrj/tools/replaces/admin.rb +2 -5
  58. data/lib/rrj/tools/replaces/handle.rb +0 -6
  59. data/lib/rrj/tools/replaces/replace.rb +0 -10
  60. data/lib/rrj/tools/replaces/session.rb +0 -4
  61. data/lib/rrj/tools/replaces/type.rb +5 -4
  62. data/spec/config/database.rb +1 -2
  63. data/spec/config/initializer.rb +5 -5
  64. data/spec/rrj/ruby_rabbitmq_janus_spec.rb +1 -1
  65. data/spec/ruby_rabbitmq_janus/janus/responses/admin_handles_spec.rb +22 -0
  66. data/spec/ruby_rabbitmq_janus/janus/responses/admin_info_spec.rb +22 -0
  67. data/spec/ruby_rabbitmq_janus/janus/responses/admin_level_spec.rb +22 -0
  68. data/spec/ruby_rabbitmq_janus/janus/responses/admin_libnice_debug_spec.rb +22 -0
  69. data/spec/ruby_rabbitmq_janus/janus/responses/admin_locking_debug_spec.rb +22 -0
  70. data/spec/ruby_rabbitmq_janus/janus/responses/admin_log_colors_spec.rb +22 -0
  71. data/spec/ruby_rabbitmq_janus/janus/responses/admin_log_timestamps_spec.rb +22 -0
  72. data/spec/ruby_rabbitmq_janus/janus/responses/admin_max_nack_queue_spec.rb +22 -0
  73. data/spec/ruby_rabbitmq_janus/janus/responses/admin_no_media_timer_spec.rb +22 -0
  74. data/spec/ruby_rabbitmq_janus/janus/responses/admin_sessions_spec.rb +22 -0
  75. data/spec/ruby_rabbitmq_janus/janus/responses/admin_spec.rb +1 -34
  76. data/spec/ruby_rabbitmq_janus/janus/responses/admin_timeout_spec.rb +22 -0
  77. data/spec/ruby_rabbitmq_janus/janus/responses/event_data_spec.rb +22 -0
  78. data/spec/ruby_rabbitmq_janus/janus/responses/event_event_spec.rb +22 -0
  79. data/spec/ruby_rabbitmq_janus/janus/responses/event_jsep_spec.rb +22 -0
  80. data/spec/ruby_rabbitmq_janus/janus/responses/event_keys_spec.rb +28 -0
  81. data/spec/ruby_rabbitmq_janus/janus/responses/response_spec.rb +27 -15
  82. data/spec/ruby_rabbitmq_janus/janus/responses/standard_data_spec.rb +22 -0
  83. data/spec/ruby_rabbitmq_janus/janus/responses/standard_plugin_data_spec.rb +28 -0
  84. data/spec/ruby_rabbitmq_janus/janus/responses/standard_plugin_spec.rb +22 -0
  85. data/spec/ruby_rabbitmq_janus/janus/responses/standard_sdp_spec.rb +28 -0
  86. data/spec/ruby_rabbitmq_janus/janus/responses/standard_sender_spec.rb +28 -0
  87. data/spec/ruby_rabbitmq_janus/janus/responses/standard_session_id_spec.rb +22 -0
  88. data/spec/ruby_rabbitmq_janus/janus/responses/standard_session_spec.rb +28 -0
  89. data/spec/ruby_rabbitmq_janus/models/janus_instance_spec.rb +7 -2
  90. data/spec/ruby_rabbitmq_janus/rabbit/connect_spec.rb +0 -4
  91. data/spec/ruby_rabbitmq_janus/rabbit/propertie_instance_classic_spec.rb +12 -0
  92. data/spec/ruby_rabbitmq_janus/rabbit/propertie_instance_token_spec.rb +12 -0
  93. data/spec/ruby_rabbitmq_janus/rrj_admin_add_token_spec.rb +31 -0
  94. data/spec/ruby_rabbitmq_janus/rrj_admin_allow_token_spec.rb +43 -0
  95. data/spec/ruby_rabbitmq_janus/rrj_admin_disallow_token_spec.rb +43 -0
  96. data/spec/ruby_rabbitmq_janus/rrj_admin_handle_info_spec.rb +32 -0
  97. data/spec/ruby_rabbitmq_janus/rrj_admin_list_handles_spec.Rb +32 -0
  98. data/spec/ruby_rabbitmq_janus/rrj_admin_list_sessions_spec.rb +25 -0
  99. data/spec/ruby_rabbitmq_janus/rrj_admin_list_tokens_spec.rb +33 -0
  100. data/spec/ruby_rabbitmq_janus/rrj_admin_remove_token_spec.rb +43 -0
  101. data/spec/ruby_rabbitmq_janus/rrj_admin_set_libnice_debug_spec.rb +20 -0
  102. data/spec/ruby_rabbitmq_janus/rrj_admin_set_locking_debug_spec.rb +20 -0
  103. data/spec/ruby_rabbitmq_janus/rrj_admin_set_log_colors_spec.rb +20 -0
  104. data/spec/ruby_rabbitmq_janus/rrj_admin_set_log_level_spec.rb +75 -0
  105. data/spec/ruby_rabbitmq_janus/rrj_admin_set_log_timestamps_spec.rb +20 -0
  106. data/spec/ruby_rabbitmq_janus/rrj_admin_set_max_nack_queue_spec.rb +56 -0
  107. data/spec/ruby_rabbitmq_janus/rrj_admin_set_no_media_timer_spec.rb +47 -0
  108. data/spec/ruby_rabbitmq_janus/rrj_admin_set_session_timeout_spec.rb +47 -0
  109. data/spec/ruby_rabbitmq_janus/rrj_admin_start_pcap_spec.rb +38 -0
  110. data/spec/ruby_rabbitmq_janus/rrj_admin_start_text2pcap_spec.rb +38 -0
  111. data/spec/ruby_rabbitmq_janus/rrj_admin_stop_pcap_spec.rb +43 -0
  112. data/spec/ruby_rabbitmq_janus/rrj_admin_stop_text2pcap_spec.rb +43 -0
  113. data/spec/ruby_rabbitmq_janus/rrj_answer_spec.rb +79 -0
  114. data/spec/ruby_rabbitmq_janus/rrj_attach_spec.rb +56 -0
  115. data/spec/ruby_rabbitmq_janus/rrj_create_spec.rb +25 -0
  116. data/spec/ruby_rabbitmq_janus/rrj_destroy_spec.rb +56 -0
  117. data/spec/ruby_rabbitmq_janus/rrj_detach_spec.rb +56 -0
  118. data/spec/ruby_rabbitmq_janus/rrj_info_spec.rb +36 -0
  119. data/spec/ruby_rabbitmq_janus/rrj_keepalive_spec.rb +56 -0
  120. data/spec/ruby_rabbitmq_janus/rrj_offer_spec.rb +57 -0
  121. data/spec/ruby_rabbitmq_janus/rrj_trickle_spec.rb +41 -0
  122. data/spec/ruby_rabbitmq_janus/rrj_trickles_spec.rb +43 -0
  123. data/spec/ruby_rabbitmq_janus/tools/cluster_spec.rb +12 -7
  124. data/spec/ruby_rabbitmq_janus/tools/config_gem_spec.rb +94 -0
  125. data/spec/ruby_rabbitmq_janus/tools/config_janus_spec.rb +44 -0
  126. data/spec/ruby_rabbitmq_janus/tools/config_queues_spec.rb +34 -0
  127. data/spec/ruby_rabbitmq_janus/tools/config_rabbit_spec.rb +28 -0
  128. data/spec/ruby_rabbitmq_janus/tools/config_spec.rb +4 -77
  129. data/spec/ruby_rabbitmq_janus/tools/replaces/admin_spec.rb +13 -12
  130. data/spec/ruby_rabbitmq_janus/tools/replaces/handle_spec.rb +12 -11
  131. data/spec/ruby_rabbitmq_janus/tools/replaces/replace_spec.rb +15 -14
  132. data/spec/ruby_rabbitmq_janus/tools/replaces/session_spec.rb +12 -11
  133. data/spec/ruby_rabbitmq_janus/tools/type_spec.rb +20 -1
  134. data/spec/spec_helper.rb +23 -8
  135. data/spec/support/examples_admin.rb +43 -0
  136. data/spec/support/examples_base.rb +65 -0
  137. data/spec/support/examples_config.rb +4 -2
  138. data/spec/support/examples_message.rb +4 -2
  139. data/spec/support/initialize_janus_instance.rb +80 -0
  140. data/spec/support/schemas/config/{rabbit_options_admin.json → rabbit_options_admin_instance_classic.json} +0 -0
  141. data/spec/support/schemas/config/{rabbit_options_admin2.json → rabbit_options_admin_instance_token.json} +0 -0
  142. data/spec/support/schemas/config/{rabbit_options.json → rabbit_options_instance_classic.json} +0 -0
  143. data/spec/support/schemas/config/{rabbit_options2.json → rabbit_options_instance_token.json} +0 -0
  144. data/spec/support/schemas/request/admin/set_libnice_debug.json +13 -0
  145. data/spec/support/schemas/request/admin/set_log_colors.json +13 -0
  146. data/spec/support/schemas/request/admin/set_log_level.json +4 -2
  147. data/spec/support/schemas/request/admin/set_log_timestamps.json +13 -0
  148. data/spec/support/schemas/request/admin/set_max_nack_queue.json +13 -0
  149. data/spec/support/schemas/request/admin/set_no_media_timer.json +13 -0
  150. data/spec/support/schemas/request/admin/set_session_timeout.json +13 -0
  151. data/spec/support/schemas/request/peer/trickles.json +13 -0
  152. data/spec/support/sdp.rb +2 -0
  153. data/spec/support/type.rb +9 -7
  154. metadata +93 -55
  155. data/lib/rrj/errors/janus/responses/response.rb +0 -44
  156. data/spec/config/instance.rb +0 -63
  157. data/spec/request/admin/request_add_token_spec.rb +0 -29
  158. data/spec/request/admin/request_allow_token_spec.rb +0 -21
  159. data/spec/request/admin/request_disallow_token_spec.rb +0 -21
  160. data/spec/request/admin/request_handle_info_spec.rb +0 -21
  161. data/spec/request/admin/request_list_handles_spec.rb +0 -20
  162. data/spec/request/admin/request_list_sessions_spec.rb +0 -21
  163. data/spec/request/admin/request_list_tokens_spec.rb +0 -18
  164. data/spec/request/admin/request_remove_token_spec.rb +0 -18
  165. data/spec/request/admin/request_set_libnice_debug_spec.rb +0 -28
  166. data/spec/request/admin/request_set_locking_debug_spec.rb +0 -28
  167. data/spec/request/admin/request_set_log_colors_spec.rb +0 -28
  168. data/spec/request/admin/request_set_log_level_spec.rb +0 -70
  169. data/spec/request/admin/request_set_log_timestamps_spec.rb +0 -28
  170. data/spec/request/admin/request_set_max_nack_queue_spec.rb +0 -28
  171. data/spec/request/admin/request_set_no_media_timer_spec.rb +0 -28
  172. data/spec/request/admin/request_set_session_timeout_spec.rb +0 -35
  173. data/spec/request/admin/request_start_pcap_spec.rb +0 -28
  174. data/spec/request/admin/request_start_text2pcap_spec.rb +0 -27
  175. data/spec/request/admin/request_stop_pcap_spec.rb +0 -21
  176. data/spec/request/admin/request_stop_text2pcap_spec.rb +0 -28
  177. data/spec/request/base/request_attach_spec.rb +0 -27
  178. data/spec/request/base/request_create_spec.rb +0 -22
  179. data/spec/request/base/request_destroy_spec.rb +0 -23
  180. data/spec/request/base/request_detach_spec.rb +0 -27
  181. data/spec/request/base/request_info_spec.rb +0 -22
  182. data/spec/request/base/request_keepalive_spec.rb +0 -23
  183. data/spec/request/peer/request_offer_spec.rb +0 -27
  184. data/spec/request/peer/request_trickle_spec.rb +0 -30
  185. data/spec/request/peer/request_trickles_spec.rb +0 -30
  186. data/spec/responses/admin_handle_info.json +0 -32
  187. data/spec/responses/admin_list_handles.json +0 -4
  188. data/spec/responses/admin_list_sessions.json +0 -4
  189. data/spec/responses/admin_set_libnice_debug.json +0 -4
  190. data/spec/responses/admin_set_locking_debug.json +0 -4
  191. data/spec/responses/admin_set_log_colors.json +0 -4
  192. data/spec/responses/admin_set_log_level.json +0 -4
  193. data/spec/responses/base_info.json +0 -5
  194. data/spec/ruby_rabbitmq_janus/janus/responses/event_spec.rb +0 -26
  195. data/spec/ruby_rabbitmq_janus/janus/responses/standard_spec.rb +0 -44
  196. data/spec/ruby_rabbitmq_janus/rabbit/propertie_2_spec.rb +0 -28
  197. data/spec/ruby_rabbitmq_janus/rabbit/propertie_spec.rb +0 -29
  198. data/spec/ruby_rabbitmq_janus/tools/logger_spec.rb +0 -84
  199. data/spec/support/admin_requester.rb +0 -48
  200. data/spec/support/aruba.rb +0 -3
  201. data/spec/support/examples_request.rb +0 -65
  202. data/spec/support/examples_response.rb +0 -30
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # LCO: tagged broken 2018/01/26 for v2.3.0
4
- # see: https://travis-ci.org/dazzl-tv/ruby-rabbitmq-janus/builds/333359315
5
-
6
- require 'spec_helper'
7
-
8
- describe 'RubyRabbitmqJanus::RRJ -- message type trickles' do
9
- before do
10
- clear
11
- attach_base
12
-
13
- @type = 'peer::trickle'
14
- candidate = { 'sdpMid' => '..', 'sdpMLineIndex' => 1, 'candidate' => '..' }
15
- @options.merge!('candidates' => [candidate, candidate, candidate])
16
- end
17
-
18
- describe '#handle_endpoint_public', type: :request,
19
- level: :base,
20
- broken: true,
21
- name: :trickles do
22
- context 'when queue is exclusive' do
23
- include_examples 'transaction handle should match json schema'
24
- end
25
-
26
- context 'when queue is not exclusive' do
27
- include_examples 'transaction handle should match json empty'
28
- end
29
- end
30
- end
@@ -1,32 +0,0 @@
1
- {
2
- "janus" : "success",
3
- "transaction" : "<same as the request>",
4
- "session_id" : 12345678,
5
- "handle_id" : 98765432,
6
- "info" : {
7
- "session_id" : 12345678,
8
- "session_last_activity": 7927759122,
9
- "session_transport": "janus.transport.websockets",
10
- "handle_id" : 98765432,
11
- "opaque_id": "echotest-YZcsLRCI4uSV",
12
- "loop-running": true,
13
- "created": 18695669309,
14
- "current_time": 18706199704,
15
- "plugin": "janus.plugin.echotest",
16
- "plugin_specific": {
17
- },
18
- "flags": {
19
- },
20
- "agent-created": 18696092523,
21
- "ice-mode": "full",
22
- "ice-role": "controlled",
23
- "sdps": {
24
- "profile": "UDP/TLS/RTP/SAVPF",
25
- "local": "v=0[..]",
26
- "remote": "v=0[..]"
27
- },
28
- "queued-packets": 0,
29
- "streams": [
30
- ]
31
- }
32
- }
@@ -1,4 +0,0 @@
1
- {
2
- "janus" : "success",
3
- "transaction" : "<same as the request>"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "janus" : "success",
3
- "transaction" : "<same as the request>"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "janus" : "success",
3
- "transaction" : "<same as the request>"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "janus" : "success",
3
- "transaction" : "<same as the request>"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "janus" : "success",
3
- "transaction" : "<same as the request>"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "janus" : "success",
3
- "transaction" : "<same as the request>"
4
- }
@@ -1,5 +0,0 @@
1
- {
2
- "janus": "info",
3
- "session_id": 3547439636123024,
4
- "transaction": "JG3DBOZ046"
5
- }
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe RubyRabbitmqJanus::Janus::Responses::Event, type: :responses,
6
- name: :event,
7
- broken: true do
8
- let(:message) do
9
- # Transaction not exclusive, response is public queue
10
- @gateway.session_endpoint_public do |transaction|
11
- @response = transaction.publish_message(type)
12
- end
13
- end
14
-
15
- describe '#event' do
16
- subject(:thread) { @event.join }
17
-
18
- let(:type) { 'base::info' }
19
- let(:response) { @response }
20
-
21
- it 'eqls {}' do
22
- message
23
- expect(@response.to_hash).to eql({})
24
- end
25
- end
26
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe RubyRabbitmqJanus::Janus::Responses::Standard, type: :responses,
6
- broken: true,
7
- name: :standard do
8
- let(:message) do
9
- @gateway.session_endpoint_public do |transaction|
10
- @response = transaction.publish_message(type)
11
- end
12
- end
13
-
14
- context 'when just session' do
15
- describe '#session' do
16
- let(:type) { 'base::create' }
17
- let(:response) { @response.session }
18
-
19
- include_examples 'response is', Integer
20
- end
21
-
22
- describe '#sender' do
23
- let(:type) { 'base::create' }
24
- let(:response) { @response.sender }
25
-
26
- include_examples 'response is', Integer
27
- end
28
- end
29
-
30
- context 'when session and sender' do
31
- before do
32
- @gateway.session_endpoint_public do |transaction|
33
- @response = transaction.publish_message('base::create')
34
- end
35
- end
36
-
37
- describe '#session_id' do
38
- let(:type) { 'base::attach' }
39
- let(:response) { @response.session_id }
40
-
41
- include_examples 'response with sender is', Integer
42
- end
43
- end
44
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe RubyRabbitmqJanus::Rabbit::Propertie, type: :rabbit,
6
- name: :propertie do
7
- let(:rabbit) { described_class.new }
8
-
9
- describe '#options' do
10
- it { expect(rabbit.options).to match_json_schema(:rabbit_options) }
11
- end
12
-
13
- describe '#options_admin', broken: true do
14
- context 'when admin request' do
15
- it do
16
- expect(rabbit.options_admin('admin::sessions')).to \
17
- match_json_schema(:rabbit_options_admin)
18
- end
19
- end
20
-
21
- context 'when base request' do
22
- it do
23
- expect(rabbit.options_admin('request::create')).to \
24
- match_json_schema(:rabbit_options)
25
- end
26
- end
27
- end
28
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe RubyRabbitmqJanus::Rabbit::Propertie, type: :rabbit,
6
- name: :propertie,
7
- instances: true do
8
- let(:rabbit) { described_class.new(2) }
9
-
10
- describe '#options' do
11
- it { expect(rabbit.options).to match_json_schema(:rabbit_options2) }
12
- end
13
-
14
- describe '#options_admin', broken: true do
15
- context 'when admin request' do
16
- it do
17
- expect(rabbit.options_admin('admin::sessions')).to \
18
- match_json_schema(:rabbit_options_admin2)
19
- end
20
- end
21
-
22
- context 'when base request' do
23
- it do
24
- expect(rabbit.options_admin('request::create')).to \
25
- match_json_schema(:rabbit_options2)
26
- end
27
- end
28
- end
29
- end
@@ -1,84 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'rrj/tools/gem/log.rb'
5
-
6
- describe RubyRabbitmqJanus::Tools::Logger, type: :tools, name: :log, broken: true do
7
- let(:levels) do
8
- {
9
- DEBUG: Logger::DEBUG,
10
- INFO: Logger::INFO,
11
- WARN: Logger::WARN,
12
- ERROR: Logger::ERROR,
13
- FATAL: Logger::FATAL,
14
- UNKNOWN: Logger::UNKNOWN
15
- }
16
- end
17
- let(:sensitives) { %i[admin_secret apisecret] }
18
- let(:log) { described_class.instance }
19
- let(:log_constant) { described_class }
20
- let(:new_level) { Random.new.rand(5) }
21
- let(:message) { '## test ##' }
22
- let(:last_line) { IO.readlines('log/ruby-rabbitmq-janus.log')[-1..-1][0] }
23
-
24
- it 'Default levels' do
25
- expect(log_constant::LEVELS).to eql(levels)
26
- end
27
-
28
- it 'Defaults sensitives word' do
29
- expect(log_constant::SENSITIVES).to eql(sensitives)
30
- end
31
-
32
- it 'Log instance is correctly loading' do
33
- expect(log).not_to be(nil)
34
- end
35
-
36
- it 'Default level log is INFO' do
37
- # 0 = debug
38
- # ...
39
- # 5 = unknown
40
- expect(log.level).to eq(0)
41
- end
42
-
43
- context 'when write a message unknown' do
44
- before { log.unknown(message) }
45
-
46
- it { expect(last_line).to include('A, ## test ##') }
47
- end
48
-
49
- context 'when write a message fatal' do
50
- before { log.fatal(message) }
51
-
52
- it { expect(last_line).to include('F, ## test ##') }
53
- end
54
-
55
- context 'when write a message error' do
56
- before { log.error(message) }
57
-
58
- it { expect(last_line).to include('E, ## test ##') }
59
- end
60
-
61
- context 'when write a message warn' do
62
- before { log.warn(message) }
63
-
64
- it { expect(last_line).to include('W, ## test ##') }
65
- end
66
-
67
- context 'when write a message info' do
68
- before { log.info(message) }
69
-
70
- it { expect(last_line).to include('I, ## test ##') }
71
- end
72
-
73
- context 'when write a message debug' do
74
- before { log.debug(message) }
75
-
76
- it { expect(last_line).to include('D, ## test ##') }
77
- end
78
-
79
- context 'when level is changed' do
80
- it 'Change level' do
81
- expect(log.save_level(new_level)).to eql(log.level)
82
- end
83
- end
84
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Helpers method for admin requester
4
- # Use this methods before execute block 'it'
5
-
6
- # Prepare variable for sending request to RabbitMQ
7
- def help_admin_prepare
8
- @opt_instance = instance
9
- @opt_transaction = {}
10
- @transaction = nil
11
- end
12
-
13
- # Create a session
14
- def help_admin_create_session
15
- @gateway.session_endpoint_public(@opt_instance) do |transaction|
16
- session = transaction.publish_message('base::create', @opt_transaction).session
17
-
18
- @opt_transaction['session_id'] = session
19
- @opt_instance.merge!(@opt_transaction)
20
- end
21
- end
22
-
23
- # Create a handler (attached to plugin echo test)
24
- def help_admin_create_handler
25
- @gateway.session_endpoint_public(@opt_instance) do |transaction|
26
- handler = transaction.publish_message('base::attach', @opt_transaction).sender
27
- @opt_transaction['handle_id'] = handler
28
- @opt_instance.merge!(@opt_transaction)
29
- end
30
- end
31
-
32
- # Execute an action before test requester result
33
- def help_admin_request_before(type_before, admin_opt = {})
34
- @opt_transaction.merge!(admin_opt)
35
-
36
- @gateway.admin_endpoint(@opt_instance) do |transaction|
37
- transaction.publish_message(type_before, @opt_transaction)
38
- end
39
- end
40
-
41
- # Request tested
42
- def help_admin_request_tested(admin_opt = {})
43
- @opt_transaction.merge!(admin_opt)
44
-
45
- @gateway.admin_endpoint(@opt_instance) do |transaction|
46
- @transaction = transaction.publish_message(type, @opt_transaction)
47
- end
48
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'aruba/rspec'
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- shared_examples 'empty response' do
4
- it 'matches JSON empty' do
5
- message
6
- expect(@response.to_json).to eq('{}')
7
- end
8
- end
9
-
10
- shared_examples 'schema response' do
11
- it do
12
- message
13
- expect(@response.to_json).to match_json_schema(@type)
14
- end
15
- end
16
-
17
- shared_examples 'transaction should match json empty' do
18
- let(:message) do
19
- @gateway.session_endpoint_public(@session_instance) do |transaction|
20
- @response = transaction.publish_message(@type, @options)
21
- end
22
- end
23
-
24
- include_examples 'empty response'
25
- end
26
-
27
- shared_examples 'transaction should match json schema' do
28
- let(:message) do
29
- @gateway.session_endpoint_private(@session_instance) do |transaction|
30
- @response = transaction.publish_message(@type, @options)
31
- end
32
- end
33
-
34
- include_examples 'schema response'
35
- end
36
-
37
- shared_examples 'transaction handle should match json schema' do
38
- let(:message) do
39
- @gateway.handle_endpoint_private(@session_instance) do |transaction|
40
- @response = transaction.publish_message(@type, @options)
41
- end
42
- end
43
-
44
- include_examples 'schema response'
45
- end
46
-
47
- shared_examples 'transaction handle should match json empty' do
48
- let(:message) do
49
- @gateway.handle_endpoint_public(@session_instance) do |transaction|
50
- @response = transaction.publish_message(@type, @options)
51
- end
52
- end
53
-
54
- include_examples 'empty response'
55
- end
56
-
57
- shared_examples 'transaction admin should match json schema' do
58
- let(:message) do
59
- @gateway.admin_endpoint(@instance) do |transaction|
60
- @response = transaction.publish_message(@type, @options)
61
- end
62
- end
63
-
64
- include_examples 'schema response'
65
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- shared_examples 'response is' do |type|
4
- it do
5
- message
6
- expect(response).to be_kind_of(type)
7
- end
8
- end
9
-
10
- shared_examples 'response with sender is' do |klass|
11
- let(:message) do
12
- @gateway.session_endpoint_public do |transaction|
13
- opts = { 'handle_id' => @response.sender }
14
- @response = transaction.publish_message(type, opts)
15
- end
16
- end
17
-
18
- include_examples 'response is', klass
19
- end
20
-
21
- shared_examples 'admin response with sender is' do |klass|
22
- let(:message) do
23
- opts = { 'handle_id' => @response.sender }
24
- @gateway.admin_endpoint(opts) do |transaction|
25
- @response = transaction.publish_message(type, opts)
26
- end
27
- end
28
-
29
- include_examples 'response is', klass
30
- end