itunes_validator 0.4.4 → 0.4.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 723220c4d8ec1994c0e2f2cdc7ccdd2ac7a2e1d5
4
- data.tar.gz: ad2bb0d8a6cd2cb6cccc130d1acae23dbc7d81c4
3
+ metadata.gz: a478903ae40c548da09c811f5ff575ee3d718357
4
+ data.tar.gz: b45ee4e98c5405679cbae5650cf05b5b405413aa
5
5
  SHA512:
6
- metadata.gz: 363a8c8239f61173794eb64bc8660212a4159d370cd13c79ec3f33a2a1ecf4a2856db27b899f15fbc4c504308e5af91bc963cddd40ce62cd9541537356e5d737
7
- data.tar.gz: aae61512aecd1452d9479a6d77da8c4197ee23de60e15cceb866a83323d37c0d48e74f7ddd951379e2f12d74084f9a50332011633a0cdb7fdf9c2b2314ea720b
6
+ metadata.gz: ce700a4fcb9283f6bcd128431513043019e66bebd2c9fc578a3849441219598f325f67e5e5a4cc5f6b757a02da3fac611f438ee7fa9970dac400332c3edd645f
7
+ data.tar.gz: e32aabe97755ae41ac6d8b3febc427c95c07d26eddf1e11cfd886a9174128a092cf3f6ab99706a3ce9aed23e8897c654c46a91f43fd2d89ebe3b19ea3c1e9473
@@ -2,5 +2,5 @@ require_relative 'itunes_validator/client'
2
2
  require_relative 'itunes_validator/receipt'
3
3
 
4
4
  module ItunesValidator
5
- VERSION = '0.4.4'
5
+ VERSION = '0.4.5'
6
6
  end
@@ -20,22 +20,18 @@ module ItunesValidator
20
20
  end
21
21
 
22
22
  def validate(receipt_data)
23
- raise ParameterError unless receipt_data
23
+ raise ParameterError unless (receipt_data && !receipt_data.strip.empty?)
24
24
 
25
- post_body = {}
26
- post_body['receipt-data'] = receipt_data
27
- post_body['password'] = @shared_secret if @shared_secret
25
+ post_body = { 'receipt-data' => receipt_data }
26
+ post_body['password'] = @shared_secret if @shared_secret && !@shared_secret.strip.empty?
28
27
 
29
28
  receipt_info = latest_receipt_info = nil
30
29
 
31
30
  uri = URI(APPSTORE_VERIFY_URL_PRODUCTION)
32
31
  begin
33
- h = Net::HTTP::Proxy(*@proxy) if @proxy
34
- h = Net::HTTP unless h
35
- h.start(uri.host, uri.port, {use_ssl: true}) do |http|
36
- req = Net::HTTP::Post.new(uri.request_uri)
37
- req['Accept'] = 'application/json'
38
- req['Content-Type'] = 'application/json'
32
+ h = @proxy ? Net::HTTP::Proxy(*@proxy) : Net::HTTP
33
+ h.start(uri.host, uri.port, use_ssl: true) do |http|
34
+ req = Net::HTTP::Post.new(uri.request_uri, {'Accept' => 'application/json', 'Content-Type'=>'applications/json'})
39
35
  req.body = post_body.to_json
40
36
 
41
37
  response = http.request(req)
@@ -43,19 +39,19 @@ module ItunesValidator
43
39
  response_body = JSON.parse(response.body)
44
40
 
45
41
  case itunes_status = response_body['status'].to_i
46
- when 0
47
- receipt_info = response_body['receipt']
48
- latest_receipt_info = response_body['latest_receipt_info']
49
- else
50
- raise ItunesValidationError.new(itunes_status)
42
+ when 0
43
+ receipt_info = response_body['receipt']
44
+ latest_receipt_info = response_body['latest_receipt_info']
45
+ else
46
+ raise ItunesValidationError.new(itunes_status)
51
47
  end
52
48
  end
53
49
  rescue ItunesCommunicationError
54
50
  rescue ItunesValidationError => e
55
51
  case e.code
56
- when 21007
57
- uri = URI(APPSTORE_VERIFY_URL_SANDBOX)
58
- retry
52
+ when 21007
53
+ uri = URI(APPSTORE_VERIFY_URL_SANDBOX)
54
+ retry
59
55
  end
60
56
  end
61
57
 
@@ -81,6 +81,12 @@ class TestItunesValidator < Test::Unit::TestCase
81
81
  assert_raises(ItunesValidator::ParameterError) do
82
82
  ItunesValidator.validate(nil)
83
83
  end
84
+ assert_raises(ItunesValidator::ParameterError) do
85
+ ItunesValidator.validate('')
86
+ end
87
+ assert_raises(ItunesValidator::ParameterError) do
88
+ ItunesValidator.validate(' ')
89
+ end
84
90
  end
85
91
 
86
92
  def test_invalid_parameters_no_receipt
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itunes_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Talbot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-24 00:00:00.000000000 Z
11
+ date: 2013-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake