fax_finder 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
data/fax_finder.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fax_finder}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Erich L. Timkar"]
12
- s.date = %q{2011-05-10}
12
+ s.date = %q{2011-07-12}
13
13
  s.email = %q{erich@hordesoftware.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -25,11 +25,14 @@ Gem::Specification.new do |s|
25
25
  "fax_finder.gemspec",
26
26
  "fax_finder.tmproj",
27
27
  "lib/fax_finder.rb",
28
+ "lib/fax_finder/abort.rb",
28
29
  "lib/fax_finder/query.rb",
29
30
  "lib/fax_finder/request.rb",
30
31
  "lib/fax_finder/response.rb",
31
32
  "lib/fax_finder/send.rb",
32
- "pkg/fax_finder-0.2.0.gem",
33
+ "pkg/fax_finder-0.2.1.gem",
34
+ "pkg/fax_finder-0.2.2.gem",
35
+ "test/abort_test.rb",
33
36
  "test/fixtures/send_request_external.xml",
34
37
  "test/fixtures/send_request_inline.xml",
35
38
  "test/fixtures/send_response_success.xml",
@@ -0,0 +1,28 @@
1
+ require 'nokogiri'
2
+ require 'builder'
3
+
4
+ module FaxFinder
5
+
6
+ class Abort < Request
7
+ def self.delete(fax_key, entry_key)
8
+ self.post(){
9
+ construct_http_request(fax_key, entry_key)
10
+ }
11
+ end
12
+
13
+ def self.construct_http_request(fax_key, entry_key)
14
+ request = Net::HTTP::Delete.new(self.path(fax_key, entry_key))
15
+ request.basic_auth self.user, self.password
16
+ request.set_content_type(Request::CONTENT_TYPE)
17
+ request
18
+ end
19
+
20
+ def self.path(fax_key, entry_key)
21
+ params=[BASE_PATH, fax_key, entry_key].reject{ |p| p.nil? }
22
+ File.join(*params)
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
@@ -24,8 +24,12 @@ module FaxFinder
24
24
  response_body=nil
25
25
 
26
26
  begin
27
- Net::HTTP.start(Request.host, Request.port) { |http|
28
- http.use_ssl=Request.ssl
27
+
28
+ _http=Net::HTTP.new(Request.host, Request.port)
29
+ _http.use_ssl=Request.ssl
30
+ _http.verify_mode = OpenSSL::SSL::VERIFY_NONE if _http.use_ssl?
31
+
32
+ _http.start {|http|
29
33
  http_request = yield
30
34
  http_request.basic_auth Request.user, Request.password
31
35
  http_request.set_content_type(Request::CONTENT_TYPE)
@@ -34,6 +38,8 @@ module FaxFinder
34
38
  }
35
39
  rescue Errno::ECONNREFUSED => e
36
40
  response_body=Responses::NO_CONNECTION
41
+ rescue OpenSSL::SSL::SSLError => e
42
+ response_body=Responses::BAD_SSL_CONFIG
37
43
  rescue RuntimeError => e
38
44
  response_body=Responses::APPLICATION_ERROR.gsub(Responses::ERROR_GSUB, e.message)
39
45
  end
@@ -14,6 +14,8 @@ module FaxFinder
14
14
  NO_CONNECTION = APPLICATION_ERROR.gsub('####MESSAGE#####', 'No connection to fax server')
15
15
 
16
16
  UNAUTHORIZED = APPLICATION_ERROR.gsub('####MESSAGE#####', 'Unauthorized to communicate with fax server.')
17
+
18
+ BAD_SSL_CONFIG = APPLICATION_ERROR.gsub('####MESSAGE#####', 'Your connection is not configured correctly. If you are using SSL, make sure the port is is set to 443.')
17
19
 
18
20
  end
19
21
 
data/lib/fax_finder.rb CHANGED
@@ -29,3 +29,4 @@ require 'fax_finder/response.rb'
29
29
  require 'fax_finder/request.rb'
30
30
  require 'fax_finder/send.rb'
31
31
  require 'fax_finder/query.rb'
32
+ require 'fax_finder/abort.rb'
Binary file
Binary file
@@ -0,0 +1,51 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ module FaxFinder
4
+ class AbortDeleteTest<Test::Unit::TestCase
5
+ def setup
6
+ Request.configure('example.com', 'user', 'password')
7
+ end
8
+
9
+ def test_get
10
+ Abort.delete('user', 'password')
11
+ end
12
+
13
+ def test_gets_returns_response
14
+ assert_instance_of(FaxFinder::Response, Abort.delete(nil, nil))
15
+ end
16
+ end
17
+
18
+ class AbortConstructHttpRequestTest<Test::Unit::TestCase
19
+ def setup
20
+ Request.configure('example.com', 'user', 'password')
21
+ @http_request=Abort.construct_http_request('fax_key', 'entry_key')
22
+ end
23
+
24
+ def test_returns_a_get
25
+ assert_instance_of(Net::HTTP::Delete, @http_request)
26
+ end
27
+
28
+ def test_sets_path
29
+ assert_equal(Abort.path('fax_key', 'entry_key'), @http_request.path)
30
+ end
31
+
32
+ def test_sets_basic_auth
33
+ assert_not_nil(@http_request['authorization'])
34
+ end
35
+
36
+ def test_sets_content_type
37
+ assert_equal('text/xml', @http_request['Content-Type'])
38
+ end
39
+ end
40
+
41
+ class AbortPathTest<Test::Unit::TestCase
42
+ def setup
43
+ end
44
+
45
+ def test_constructs_using_base_path
46
+ assert_equal(Request::BASE_PATH+'/'+'fax_key' +'/'+'entry_key', Abort.path('fax_key', 'entry_key'))
47
+ end
48
+
49
+ end
50
+
51
+ end
data/test/send_test.rb CHANGED
@@ -32,6 +32,8 @@ module FaxFinder
32
32
  class SendConstructXMLTest<Test::Unit::TestCase
33
33
  def setup
34
34
  @doc=Nokogiri::XML(Send.construct_xml('1234567890', OPTIONS.merge(:external_url=>'https://localhost/something')))
35
+ now=Time.now.utc
36
+ @now_utc=DateTime.civil(Date.today.year, Date.today.month, Date.today.day, now.hour, now.min, now.sec)
35
37
  end
36
38
 
37
39
  def test_returns_string_and_doesnt_blow_up
@@ -96,12 +98,14 @@ module FaxFinder
96
98
  end
97
99
 
98
100
  def test_includes_schedule_all_at
99
- assert_equal(Time.now.utc.strftime(Request::TIME_FORMAT), @doc.xpath('//schedule_fax/schedule_all_at').text)
101
+ actual=DateTime.parse(@doc.xpath('//schedule_fax/schedule_all_at').text)
102
+ (@now_utc.ajd-actual.ajd).abs < 5
100
103
  end
101
104
 
102
105
  def test_converts_to_utc
103
106
  @doc=Nokogiri::XML(Send.construct_xml('1234567890', OPTIONS.merge(:schedule_all_at=>Time.now, :external_url=>'https://localhost/something')))
104
- assert_equal(Time.now.utc.strftime(Request::TIME_FORMAT), @doc.xpath('//schedule_fax/schedule_all_at').text)
107
+ actual=DateTime.now(@doc.xpath('//schedule_fax/schedule_all_at').text)
108
+ (@now_utc.ajd-actual.ajd).abs < 5
105
109
  end
106
110
 
107
111
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fax_finder
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Erich L. Timkar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-30 00:00:00 Z
18
+ date: 2011-07-12 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: nokogiri
@@ -97,11 +97,14 @@ files:
97
97
  - fax_finder.gemspec
98
98
  - fax_finder.tmproj
99
99
  - lib/fax_finder.rb
100
+ - lib/fax_finder/abort.rb
100
101
  - lib/fax_finder/query.rb
101
102
  - lib/fax_finder/request.rb
102
103
  - lib/fax_finder/response.rb
103
104
  - lib/fax_finder/send.rb
104
- - pkg/fax_finder-0.2.0.gem
105
+ - pkg/fax_finder-0.2.1.gem
106
+ - pkg/fax_finder-0.2.2.gem
107
+ - test/abort_test.rb
105
108
  - test/fixtures/send_request_external.xml
106
109
  - test/fixtures/send_request_inline.xml
107
110
  - test/fixtures/send_response_success.xml
Binary file