opensips-mi 0.0.5 → 0.0.10

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.
@@ -0,0 +1,112 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+
16
+ require 'simplecov'
17
+ SimpleCov.start
18
+
19
+ require 'opensips/mi'
20
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
+ RSpec.configure do |config|
22
+ # rspec-expectations config goes here. You can use an alternate
23
+ # assertion/expectation library such as wrong or the stdlib/minitest
24
+ # assertions if you prefer.
25
+ config.expect_with :rspec do |expectations|
26
+ # This option will default to `true` in RSpec 4. It makes the `description`
27
+ # and `failure_message` of custom matchers include text for helper methods
28
+ # defined using `chain`, e.g.:
29
+ # be_bigger_than(2).and_smaller_than(4).description
30
+ # # => "be bigger than 2 and smaller than 4"
31
+ # ...rather than:
32
+ # # => "be bigger than 2"
33
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
34
+ end
35
+
36
+ # rspec-mocks config goes here. You can use an alternate test double
37
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
38
+ config.mock_with :rspec do |mocks|
39
+ # Prevents you from mocking or stubbing a method that does not exist on
40
+ # a real object. This is generally recommended, and will default to
41
+ # `true` in RSpec 4.
42
+ mocks.verify_partial_doubles = true
43
+ end
44
+
45
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
46
+ # have no way to turn it off -- the option exists only for backwards
47
+ # compatibility in RSpec 3). It causes shared context metadata to be
48
+ # inherited by the metadata hash of host groups and examples, rather than
49
+ # triggering implicit auto-inclusion in groups with matching metadata.
50
+ config.shared_context_metadata_behavior = :apply_to_host_groups
51
+
52
+ # The settings below are suggested to provide a good initial experience
53
+ # with RSpec, but feel free to customize to your heart's content.
54
+ =begin
55
+ # This allows you to limit a spec run to individual examples or groups
56
+ # you care about by tagging them with `:focus` metadata. When nothing
57
+ # is tagged with `:focus`, all examples get run. RSpec also provides
58
+ # aliases for `it`, `describe`, and `context` that include `:focus`
59
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
60
+ config.filter_run_when_matching :focus
61
+
62
+ # Allows RSpec to persist some state between runs in order to support
63
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
64
+ # you configure your source control system to ignore this file.
65
+ config.example_status_persistence_file_path = "spec/examples.txt"
66
+
67
+ # Limits the available syntax to the non-monkey patched syntax that is
68
+ # recommended. For more details, see:
69
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
70
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
71
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
72
+ config.disable_monkey_patching!
73
+
74
+ # This setting enables warnings. It's recommended, but in some cases may
75
+ # be too noisy due to issues in dependencies.
76
+ config.warnings = true
77
+
78
+ # Many RSpec users commonly either run the entire suite or an individual
79
+ # file, and it's useful to allow more verbose output when running an
80
+ # individual spec file.
81
+ if config.files_to_run.one?
82
+ # Use the documentation formatter for detailed output,
83
+ # unless a formatter has already been configured
84
+ # (e.g. via a command-line flag).
85
+ config.default_formatter = "doc"
86
+ end
87
+
88
+ # Print the 10 slowest examples and example groups at the
89
+ # end of the spec run, to help surface which specs are running
90
+ # particularly slow.
91
+ config.profile_examples = 10
92
+
93
+ # Run specs in random order to surface order dependencies. If you find an
94
+ # order dependency and want to debug it, you can fix the order by providing
95
+ # the seed, which is printed after each run.
96
+ # --seed 1234
97
+ config.order = :random
98
+
99
+ # Seed global randomization in this process using the `--seed` CLI option.
100
+ # Setting this allows you to use `--seed` to deterministically reproduce
101
+ # test failures related to randomization by passing the same `--seed` value
102
+ # as the one that triggered the failure.
103
+ Kernel.srand config.seed
104
+ =end
105
+ end
106
+
107
+ def fixture(name)
108
+ path = File.expand_path('fixtures', File.dirname(__FILE__))
109
+ file = File.expand_path(name, path)
110
+ File.readlines(file).map{|l| l.chomp}
111
+ end
112
+
@@ -0,0 +1,119 @@
1
+ include Opensips::MI
2
+
3
+ describe Transport do
4
+ context "fifo" do
5
+ it "must raise when using unknown transport method" do
6
+ expect {
7
+ Opensips::MI.connect(:unknown_transport_method,{})
8
+ }.to raise_error NameError
9
+ end
10
+
11
+ it "must raise when no fifo_nameInstanceOf.new parameter passed" do
12
+ expect {
13
+ Opensips::MI.connect :fifo, {}
14
+ }.to raise_error ArgumentError
15
+ end
16
+
17
+ it "must raise when fifo_name file not exists" do
18
+ allow(File).to receive(:exists?).and_return(false)
19
+ expect {
20
+ Opensips::MI.connect :fifo, :fifo_name => '/file/not/exists'
21
+ }.to raise_error ArgumentError
22
+ end
23
+
24
+ it "must raise when fifo_name file is not pipe" do
25
+ allow(File).to receive(:exists?).and_return(true)
26
+ allow(File).to receive(:pipe?).and_return(false)
27
+ expect {
28
+ Opensips::MI.connect :fifo, :fifo_name => '/tmp/opensips_fifo'
29
+ }.to raise_error ArgumentError
30
+ end
31
+
32
+ it "must raise if fifo reply directory not exists" do
33
+ allow(Dir).to receive(:exists?).and_return(false)
34
+ expect {
35
+ Opensips::MI.connect :fifo, :fifo_name => '/tmp/opensips_fifo',
36
+ :reply_dir => '/tmp'
37
+ }.to raise_error ArgumentError
38
+ end
39
+ end
40
+
41
+ context "datagram" do
42
+ it "must raise if empty host" do
43
+ expect {
44
+ Opensips::MI.connect :datagram, {}
45
+ }.to raise_error ArgumentError
46
+ end
47
+
48
+ it "must raise if empty port" do
49
+ expect {
50
+ Opensips::MI.connect :datagram, {:host => "10.10.10.10"}
51
+ }.to raise_error ArgumentError
52
+ end
53
+
54
+ it "must raise if invalid host" do
55
+ host = "256.0.0.300"
56
+ expect {
57
+ Opensips::MI.connect :datagram, {:host => host, :port => 8088}
58
+ }.to raise_error(SocketError, /#{host}/)
59
+ end
60
+
61
+ it "must raise if invalid port" do
62
+ expect {
63
+ Opensips::MI.connect :datagram, {:host => "10.0.0.1", :port => (2**16 + 1)}
64
+ }.to raise_error SocketError
65
+
66
+ expect {
67
+ Opensips::MI.connect :datagram, {:host => "10.0.0.1", :port => 0}
68
+ }.to raise_error SocketError
69
+ end
70
+
71
+ it "default timeout is 3 sec" do
72
+ mi=Opensips::MI.connect :datagram, {:host => "10.0.0.1", :port => 8088}
73
+ expect(mi.tout).to be(3)
74
+ end
75
+
76
+ it "must set timeout from params" do
77
+ mi=Opensips::MI.connect :datagram, {:host => "10.0.0.1", :port => 8088, :timeout => 15}
78
+ expect(mi.tout).to be(15)
79
+ end
80
+
81
+ it "must foo" do
82
+ mi=Opensips::MI.connect :datagram, {:host => "10.0.0.1", :port => 8088, :timeout => 1}
83
+ expect {
84
+ mi.uptime
85
+ }.to raise_error Timeout::Error
86
+ end
87
+ end
88
+
89
+ context "xmlrpc" do
90
+ it "must raise if empty host" do
91
+ expect {
92
+ Opensips::MI.connect :xmlrpc, {}
93
+ }.to raise_error ArgumentError
94
+ end
95
+
96
+ it "must raise if empty port" do
97
+ expect {
98
+ Opensips::MI.connect :xmlrpc, {:host => "10.10.10.10"}
99
+ }.to raise_error ArgumentError
100
+ end
101
+
102
+ it "must raise if invalid host" do
103
+ host = "256.0.0.300"
104
+ expect {
105
+ Opensips::MI.connect :xmlrpc, {:host => host, :port => 8088}
106
+ }.to raise_error(SocketError, /#{host}/)
107
+ end
108
+
109
+ it "must raise if invalid port" do
110
+ expect {
111
+ Opensips::MI.connect :xmlrpc, {:host => "10.0.0.1", :port => (2**16 + 1)}
112
+ }.to raise_error SocketError
113
+
114
+ expect {
115
+ Opensips::MI.connect :xmlrpc, {:host => "10.0.0.1", :port => 0}
116
+ }.to raise_error SocketError
117
+ end
118
+ end
119
+ end
metadata CHANGED
@@ -1,66 +1,81 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opensips-mi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stas Kobzar
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-27 00:00:00.000000000 Z
11
+ date: 2021-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: xmlrpc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.3'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - ~>
31
+ - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '1.3'
33
+ version: 2.2.5
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - ~>
38
+ - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '1.3'
40
+ version: 2.2.5
27
41
  - !ruby/object:Gem::Dependency
28
- name: rdoc
42
+ name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - ! '>='
45
+ - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '0'
47
+ version: 13.0.3
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ! '>='
52
+ - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '0'
54
+ version: 13.0.3
41
55
  - !ruby/object:Gem::Dependency
42
- name: rake
56
+ name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ! '>='
59
+ - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '0'
61
+ version: 3.10.0
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ! '>='
66
+ - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '0'
68
+ version: 3.10.0
55
69
  description: Ruby module for interacting with OpenSIPs management interface
56
70
  email:
57
- - stas@modulis.ca
71
+ - staskobzar@gmail.com
58
72
  executables: []
59
73
  extensions: []
60
74
  extra_rdoc_files: []
61
75
  files:
62
- - .gitignore
63
- - .travis.yml
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
64
79
  - Gemfile
65
80
  - LICENSE.txt
66
81
  - README.md
@@ -75,40 +90,39 @@ files:
75
90
  - lib/opensips/mi/transport/xmlrpc.rb
76
91
  - lib/opensips/mi/version.rb
77
92
  - opensips-mi.gemspec
78
- - test/fixtures/dlg_list
79
- - test/fixtures/ul_dump
80
- - test/helper.rb
81
- - test/test_command.rb
82
- - test/test_response.rb
83
- - test/test_transport.rb
93
+ - spec/command_spec.rb
94
+ - spec/fixtures/dlg_list
95
+ - spec/fixtures/ul_dump
96
+ - spec/response_spec.rb
97
+ - spec/spec_helper.rb
98
+ - spec/transport_spec.rb
84
99
  homepage: http://github.com/staskobzar/opensips-mi
85
- licenses: []
100
+ licenses:
101
+ - MIT
86
102
  metadata: {}
87
- post_install_message:
103
+ post_install_message:
88
104
  rdoc_options: []
89
105
  require_paths:
90
106
  - lib
91
107
  required_ruby_version: !ruby/object:Gem::Requirement
92
108
  requirements:
93
- - - ! '>='
109
+ - - ">="
94
110
  - !ruby/object:Gem::Version
95
111
  version: '0'
96
112
  required_rubygems_version: !ruby/object:Gem::Requirement
97
113
  requirements:
98
- - - ! '>='
114
+ - - ">="
99
115
  - !ruby/object:Gem::Version
100
116
  version: '0'
101
117
  requirements: []
102
- rubyforge_project:
103
- rubygems_version: 2.0.3
104
- signing_key:
118
+ rubygems_version: 3.0.3
119
+ signing_key:
105
120
  specification_version: 4
106
121
  summary: OpenSIPs management interface
107
122
  test_files:
108
- - test/fixtures/dlg_list
109
- - test/fixtures/ul_dump
110
- - test/helper.rb
111
- - test/test_command.rb
112
- - test/test_response.rb
113
- - test/test_transport.rb
114
- has_rdoc:
123
+ - spec/command_spec.rb
124
+ - spec/fixtures/dlg_list
125
+ - spec/fixtures/ul_dump
126
+ - spec/response_spec.rb
127
+ - spec/spec_helper.rb
128
+ - spec/transport_spec.rb
@@ -1,89 +0,0 @@
1
- require 'simplecov'
2
- require 'coveralls'
3
- Coveralls.wear!
4
-
5
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
- SimpleCov::Formatter::HTMLFormatter,
7
- Coveralls::SimpleCov::Formatter
8
- ]
9
- SimpleCov.start
10
-
11
- require 'minitest/autorun'
12
- require 'mocha/setup'
13
- require 'stringio'
14
- require 'opensips/mi'
15
-
16
- class MiniTest::Unit::TestCase
17
-
18
- def init_class_fifo
19
- Dir.stubs(:exists?).once.returns(true)
20
- File.stubs(:exists?).once.returns(true)
21
- File.stubs(:pipe?).once.returns(true)
22
- directory = '/tmp/opensips/fifo'
23
- fifo_name = '/tmp/opensips_fifo'
24
- replayfifo= 'fifo_reply_file_name'
25
- Opensips::MI::Transport::Fifo.new :fifo_name => fifo_name,
26
- :reply_dir => directory,
27
- :reply_fifo => replayfifo
28
- end
29
-
30
- def response_data_cmd_which
31
- Array[
32
- "200 OK", "get_statistics", "reset_statistics", "uptime", "version",
33
- "pwd", "arg", "which", "ps", "kill", "debug", "cache_store",
34
- "cache_fetch", "cache_remove", "event_subscribe", "help", "list_blacklists",
35
- "t_uac_dlg", "t_uac_cancel", "t_hash", "t_reply", "ul_rm", "ul_rm_contact",
36
- "ul_dump", "ul_flush", "ul_add", "ul_show_contact", "ul_sync", ""
37
- ]
38
- end
39
-
40
- def response_uldump
41
- fix = File.expand_path('fixtures/ul_dump',File.dirname(__FILE__))
42
- File.readlines(fix).map{|l| l.chomp}
43
- end
44
-
45
- def response_dr_gw_status_cmd
46
- Array[
47
- "200 OK",
48
- ""
49
- ]
50
- end
51
-
52
- def response_dr_gw_status_single
53
- Array[
54
- "200 OK",
55
- "Enabled:: yes",
56
- ""
57
- ]
58
- end
59
-
60
- def response_dr_gw_status_list
61
- Array[
62
- "200 OK",
63
- "ID:: gw1 IP=212.182.133.202:5060 Enabled=no ",
64
- "ID:: gw2 IP=213.15.222.97:5060 Enabled=yes",
65
- "ID:: gw3 IP=200.182.132.201:5060 Enabled=yes",
66
- "ID:: gw4 IP=200.182.135.204:5060 Enabled=yes",
67
- "ID:: pstn1 IP=199.18.14.101:5060 Enabled=yes",
68
- "ID:: pstn2 IP=199.18.14.102:5060 Enabled=no",
69
- "ID:: pstn3 IP=199.18.12.103:5060 Enabled=yes",
70
- "ID:: pstn4 IP=199.18.12.104:5060 Enabled=yes",
71
- ""
72
- ]
73
- end
74
-
75
- def response_contacts
76
- [
77
- "200 OK",
78
- "Contact:: <sip:7747@10.132.113.198>;q=;expires=100;flags=0x0;cflags=0x0;socket=<udp:10.130.8.21:5060>;methods=0x1F7F;user_agent=<PolycomSoundStationIP-SSIP_6000-UA/3.3.5.0247_0004f2f18103>",
79
- "Contact:: <sip:7747@10.130.8.100;line=628f4ffdfa7316e>;q=;expires=3593;flags=0x0;cflags=0x0;socket=<udp:10.130.8.21:5060>;methods=0xFFFFFFFF;user_agent=<Linphone/3.5.2 (eXosip2/3.6.0)>",
80
- "",
81
- ]
82
- end
83
-
84
- def response_dlg_list
85
- fix = File.expand_path('fixtures/dlg_list',File.dirname(__FILE__))
86
- File.readlines(fix).map{|l| l.chomp}
87
- end
88
-
89
- end