onsip 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5ffa2969c5d39aabe9a642a0c1750e51281b779
4
- data.tar.gz: 1e8224eb20ded09405509b34b3cc120a666e792d
3
+ metadata.gz: 0f35faf9732e0810a53019559d0efdab7f3d1372
4
+ data.tar.gz: 842964aec5a4bf1302eee9bc83f90bbc2276c8b1
5
5
  SHA512:
6
- metadata.gz: d2f165754d8602f33a43042c24abfcead864b2c359cf5aa9e5fbbdba0b717ddc99aa26eebbe608dbb3b5c0aa98d48316f24efdaa519184e93e0dfae24493a2c5
7
- data.tar.gz: be1ef2e3bc9486836c081695552fc3d086fbd709c587f0a91d45a726e359f006217f70e2d215fcbddde69e64f790196256fe3dc955f0a660b29e58d92b804118
6
+ metadata.gz: 0999e314646a8791ac4abe056b0862bc9a3ba2a306226f6611124fbf3489c34c8f0891761f69c3af03b09d3d4c3acba1b156c1bd42e5d8e6f0ac6fbb6ab04dd1
7
+ data.tar.gz: 0467ead20edf69c833371c4555f8a1a35084a2e0ad23712d83c79e5ce28ae6de36a555b5e95d3e045f200f0263805d579d9c7d060f5c8ece3cadbeb1e0fade5f
@@ -1,3 +1,3 @@
1
1
  module OnSIP
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -19,8 +19,16 @@ describe OnSIP::User do
19
19
  end
20
20
 
21
21
  describe "add" do
22
+ fail_body = {"Response"=> {"Context"=> {"Action"=>{"IsCompleted"=>"false"}, "Request"=> {"IsValid"=>"false", "DateTime"=>"2015-06-01T18:45:16+00:00", "Duration"=>"38", "Parameters"=> {"Parameter"=> [{"Name"=>"Action", "Value"=>"UserAdd"}, {"Name"=>"AuthUsername", "Value"=>"foobar888_firertc"}, {"Name"=>"Domain", "Value"=>"sip.devel.firertc.com"}, {"Name"=>"Email", "Value"=>"onsip+foobar888@icehook.com"}, {"Name"=>"Name", "Value"=>{}}, {"Name"=>"OrganizationId", "Value"=>"42975"}, {"Name"=>"Output", "Value"=>"json"}, {"Name"=>"Password", "Value"=>"******"}, {"Name"=>"PasswordConfirm", "Value"=>"******"}, {"Name"=>"SessionId", "Value"=>"ak7gllnq56e0soiebn23h9rlu3"}, {"Name"=>"Username", "Value"=>"foobar888"}]}, "Errors"=>{"Error"=>{"Parameter"=>"Username", "Code"=>"Address.Unavailable", "Message"=>"This address is already in use, is reserved, or is otherwise unavailable for use."}}}, "Session"=>{"IsEstablished"=>"true", "SessionId"=>"ak7gllnq56e0soiebn23h9rlu3", "UserId"=>"282881", "Roles"=>{"Role"=>{"Name"=>"Account Admin"}}}}}}.to_json
22
23
  add_body = {"Response"=>{"Context"=>{"Action"=>{ "IsCompleted"=>"true" },"Request"=>{"IsValid"=>"true","DateTime"=>"2014-04-21T16:19:55+00:00","Duration"=>"165","Parameters"=>{"Parameter"=>[{"Name"=>"Action","Value"=>"UserAdd"},{"Name"=>"SessionId","Value"=>"thqqva0i6jp3ea1ved17shcdg7"},{"Name"=>"OrganizationId","Value"=>"25018"},{"Name"=>"Username","Value"=>"docs"},{"Name"=>"Domain","Value"=>"example.onsip.com"},{"Name"=>"Name","Value"=>"Docs"},{"Name"=>"Email","Value"=>"docs@example.onsip.com"},{"Name"=>"AuthUsername","Value"=>"example"},{"Name"=>"Password","Value"=>"******"},{"Name"=>"PasswordConfirm","Value"=>"******"},{"Name"=>"Role","Value"=>"User"}]}},"Session"=>{"IsEstablished"=>"true","SessionId"=>"thqqva0i6jp3ea1ved17shcdg7","UserId"=>"152255","Roles"=>{"Role"=>{ "Name"=>"Account Admin" }}}},"Result"=>{"UserAdd"=>{"User"=>{"UserId"=>"218339","OrganizationId"=>"25018","AccountId"=>"22543","Flags"=>"0","Status"=>"enabled","Domain"=>"example.onsip.com","Username"=>"example","Password"=>"QPD2MLQhdaHB2hBW","AuthUsername"=>"example","Modified"=>"2014-04-21T16:19:55+00:00","Created"=>"2014-04-21T16:19:55+00:00","Ack911"=>"1970-01-01T00:00:00+00:00","SurveyCompleted"=>"1970-01-01T00:00:00+00:00","AckTrunkingTerms"=>"1970-01-01T00:00:00+00:00","AckTrunkingE911"=>"1970-01-01T00:00:00+00:00","AckHostedTerms"=>"1970-01-01T00:00:00+00:00","AckHostedE911"=>"1970-01-01T00:00:00+00:00","ExtendedDialing"=>"false","PSTNForwarding"=>"false","E911Provisioning"=>"false","PSTNTrunking"=>"false","FreePSTNTrunking"=>"false","BusyLampField"=>"false","Contact"=>{"Name"=>"Docs","Organization"=>"example","Address"=>"55 broad street","City"=>"Brooklyn","State"=>"NY","Zipcode"=>"11201","Country"=>"United States of America","CountryId"=>"207","Phone"=>"1-555-555-5555","Email"=>"docs@example.onsip.com","Modified"=>"2014-04-21T16:19:55+00:00"},"Roles"=>{"Role"=>{ "Name"=>"User" }}}}}}}.to_json
23
24
  before {
25
+ stub_request(:get, Regexp.new("http://addfail.onsip.com/api?.*UserAdd.*"))
26
+ .to_return({
27
+ :body => fail_body,
28
+ :status => 200,
29
+ :headers => { 'Content-Type' => 'application/json; charset=utf-8' }
30
+ })
31
+
24
32
  stub_request(:get, Regexp.new("http://add.onsip.com/api?.*UserAdd.*"))
25
33
  .to_return({
26
34
  :body => add_body,
@@ -29,8 +37,7 @@ describe OnSIP::User do
29
37
  })
30
38
  }
31
39
 
32
-
33
- it "with valid orgnization and attrs" do
40
+ it "should add with valid orgnization and attrs" do
34
41
  OnSIP.connect('http://add.onsip.com')
35
42
  org = OnSIP::Organization.new
36
43
  attrs = {
@@ -47,6 +54,24 @@ describe OnSIP::User do
47
54
  user = OnSIP::User.add(org, attrs)
48
55
  expect(user.class).to eq OnSIP::User
49
56
  end
57
+
58
+ it "should not add without valid orgnization and attrs" do
59
+ OnSIP.connect('http://addfail.onsip.com')
60
+ org = OnSIP::Organization.new
61
+ attrs = {
62
+ 'SessionId' => 'thqqva0i6jp3ea1ved17shcdg7',
63
+ 'OrganizationId' => '2501',
64
+ 'Username' => 'docs',
65
+ 'Domain' => 'example.onsip.com',
66
+ 'Name' => 'Docs',
67
+ 'Email' => 'docs@example.onsip.com',
68
+ 'AuthUsername' => 'example',
69
+ 'Password' => 'mysuperpassword',
70
+ 'PasswordConfirm' => 'mysuperpassword'
71
+ }
72
+ expect { OnSIP::User.add(org, attrs) }.to raise_error(OnSIP::Exceptions::OnSIPRequestError)
73
+
74
+ end
50
75
  end
51
76
 
52
77
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  describe OnSIP::Session do
4
4
  before :each do
5
5
 
6
+ # {"Response"=>{"Context"=>{"Action"=>{"IsCompleted"=>"false"}, "Request"=>{"IsValid"=>"true", "DateTime"=>"2014-12-04T20:07:08+00:00", "Duration"=>"8", "Parameters"=>{"Parameter"=>[{"Name"=>"Action", "Value"=>"SessionCreate"}, {"Name"=>"Output", "Value"=>"json"}, {"Name"=>"Password", "Value"=>"7onsip6"}, {"Name"=>"Username", "Value"=>"klarrimore@icehook.com"}]}, "Errors"=>{"Error"=>{"Parameter"=>"Action", "Code"=>"Accessor.LoginLocked", "Message"=>"You have failed to log in too many times. Please wait 10 minutes then try again."}}}, "Session"=>{"IsEstablished"=>"false"}}}}
7
+
6
8
  body = {"Response"=>{"Context"=>{"Action"=>{"IsCompleted"=>"true"}, "Request"=>{"IsValid"=>"true", "DateTime"=>"2014-12-04T17:39:53+00:00", "Duration"=>"30", "Parameters"=>{"Parameter"=>[{"Name"=>"Action", "Value"=>"SessionCreate"}, {"Name"=>"Output", "Value"=>"json"}, {"Name"=>"Password", "Value"=>"******"}, {"Name"=>"Username", "Value"=>"icehook"}]}}, "Session"=>{"IsEstablished"=>"true", "SessionId"=>"j2vtu1bk7rsdpklofplu07ocq1", "UserId"=>"212762", "Roles"=>{"Role"=>{"Name"=>"Account Admin"}}}}, "Result"=>{"SessionCreate"=>{}}}}.to_json
7
9
  stub_request(:get, Regexp.new('http://api.onsip.com/api?.*SessionCreate.*'))
8
10
  .to_return({
@@ -27,5 +29,3 @@ describe OnSIP::Session do
27
29
  end
28
30
 
29
31
  end
30
-
31
- # {"Response"=>{"Context"=>{"Action"=>{"IsCompleted"=>"false"}, "Request"=>{"IsValid"=>"true", "DateTime"=>"2014-12-04T20:07:08+00:00", "Duration"=>"8", "Parameters"=>{"Parameter"=>[{"Name"=>"Action", "Value"=>"SessionCreate"}, {"Name"=>"Output", "Value"=>"json"}, {"Name"=>"Password", "Value"=>"7onsip6"}, {"Name"=>"Username", "Value"=>"klarrimore@icehook.com"}]}, "Errors"=>{"Error"=>{"Parameter"=>"Action", "Code"=>"Accessor.LoginLocked", "Message"=>"You have failed to log in too many times. Please wait 10 minutes then try again."}}}, "Session"=>{"IsEstablished"=>"false"}}}}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onsip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Larrimore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-02 00:00:00.000000000 Z
11
+ date: 2015-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -336,7 +336,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
336
336
  version: '0'
337
337
  requirements: []
338
338
  rubyforge_project:
339
- rubygems_version: 2.4.5
339
+ rubygems_version: 2.4.6
340
340
  signing_key:
341
341
  specification_version: 4
342
342
  summary: OnSIP ruby client.
@@ -352,3 +352,4 @@ test_files:
352
352
  - spec/lib/onsip/session_spec.rb
353
353
  - spec/spec_helper.rb
354
354
  - spec/support/helpers.rb
355
+ has_rdoc: