candy_check 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +34 -0
- data/.gitignore +2 -1
- data/.ruby-version +1 -1
- data/README.md +2 -2
- data/candy_check.gemspec +7 -5
- data/lib/candy_check/cli/app.rb +6 -2
- data/lib/candy_check/play_store.rb +2 -1
- data/lib/candy_check/version.rb +1 -1
- data/spec/app_store/client_spec.rb +2 -2
- data/spec/app_store/config_spec.rb +5 -5
- data/spec/app_store/receipt_collection_spec.rb +9 -9
- data/spec/app_store/receipt_spec.rb +16 -16
- data/spec/app_store/subscription_verification_spec.rb +20 -20
- data/spec/app_store/verifcation_failure_spec.rb +6 -6
- data/spec/app_store/verification_spec.rb +12 -12
- data/spec/app_store/verifier_spec.rb +14 -14
- data/spec/candy_check_spec.rb +1 -1
- data/spec/cli/app_spec.rb +10 -6
- data/spec/cli/commands/app_store_spec.rb +6 -6
- data/spec/cli/commands/version_spec.rb +1 -1
- data/spec/cli/out_spec.rb +4 -4
- data/spec/fixtures/vcr_cassettes/play_store/product_acknowledgements/acknowledged.yml +1 -1
- data/spec/fixtures/vcr_cassettes/play_store/product_acknowledgements/already_acknowledged.yml +1 -1
- data/spec/fixtures/vcr_cassettes/play_store/product_acknowledgements/refunded.yml +1 -1
- data/spec/fixtures/vcr_cassettes/play_store/product_purchases/permission_denied.yml +2 -2
- data/spec/fixtures/vcr_cassettes/play_store/product_purchases/response_with_empty_body.yml +2 -2
- data/spec/fixtures/vcr_cassettes/play_store/product_purchases/valid_but_not_consumed.yml +1 -1
- data/spec/fixtures/vcr_cassettes/play_store/subscription_purchases/permission_denied.yml +2 -2
- data/spec/fixtures/vcr_cassettes/play_store/subscription_purchases/valid_but_expired.yml +1 -1
- data/spec/play_store/acknowledger_spec.rb +11 -11
- data/spec/play_store/product_acknowledgements/acknowledgement_spec.rb +11 -11
- data/spec/play_store/product_acknowledgements/response_spec.rb +5 -5
- data/spec/play_store/product_purchases/product_purchase_spec.rb +12 -12
- data/spec/play_store/product_purchases/product_verification_spec.rb +7 -7
- data/spec/play_store/subscription_purchases/subscription_purchase_spec.rb +26 -26
- data/spec/play_store/subscription_purchases/subscription_verification_spec.rb +7 -7
- data/spec/play_store/verification_failure_spec.rb +4 -4
- data/spec/play_store/verifier_spec.rb +6 -6
- data/spec/spec_helper.rb +15 -2
- data/spec/support/with_command.rb +0 -3
- metadata +53 -25
- data/.travis.yml +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0609ac137a3e05f673213d7f5583809227f63986a17c6624bdea3996c6fe60ff'
|
4
|
+
data.tar.gz: 3e3a451db11ffa96877fd280372c968131f4f2d81697d519963193e5678f31d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee72d24027ee9c5ae4131e8eca1ba3a52e9e3376227e1b204fdc2a87c0bc53d81cf581b615724b716539f19a59b3535d15d9b3e1e875c1552e87a75ef7f90ddc
|
7
|
+
data.tar.gz: 7336d9f3808127cac0469b7f2c90867b96567ae35acaf53c9b15528d3bcbf9cc6cb956226291d8fac284aceea1ac676e8d748a104764823d08f14eec83d366b7
|
@@ -0,0 +1,34 @@
|
|
1
|
+
name: build
|
2
|
+
on: [push, pull_request]
|
3
|
+
jobs:
|
4
|
+
build:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
strategy:
|
7
|
+
matrix:
|
8
|
+
ruby-version:
|
9
|
+
- "2.6"
|
10
|
+
- "2.7"
|
11
|
+
- "3.0"
|
12
|
+
- "3.1"
|
13
|
+
- "jruby-9.3.10.0"
|
14
|
+
- "jruby-9.4.1.0"
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v3
|
17
|
+
- uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby-version }}
|
20
|
+
bundler-cache: true
|
21
|
+
- run: bundle exec rake
|
22
|
+
- uses: coverallsapp/github-action@master
|
23
|
+
with:
|
24
|
+
github-token: ${{ secrets.github_token }}
|
25
|
+
flag-name: run-${{ matrix.ruby-version }}
|
26
|
+
parallel: true
|
27
|
+
finish:
|
28
|
+
needs: build
|
29
|
+
runs-on: ubuntu-latest
|
30
|
+
steps:
|
31
|
+
- uses: coverallsapp/github-action@master
|
32
|
+
with:
|
33
|
+
github-token: ${{ secrets.github_token }}
|
34
|
+
parallel-finished: true
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.3
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# candy_check
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/candy_check.svg)](http://badge.fury.io/rb/candy_check)
|
4
|
-
[![Build Status](https://
|
5
|
-
[![Coverage Status](https://coveralls.io/repos/jnbt/candy_check/badge.svg?branch=master)](https://coveralls.io/
|
4
|
+
[![Build Status](https://github.com/jnbt/candy_check/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/jnbt/candy_check/actions?query=branch%3Amaster)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/github/jnbt/candy_check/badge.svg?branch=master)](https://coveralls.io/github/jnbt/candy_check?branch=master)
|
6
6
|
[![Code Climate](https://codeclimate.com/github/jnbt/candy_check/badges/gpa.svg)](https://codeclimate.com/github/jnbt/candy_check)
|
7
7
|
[![Inline docs](http://inch-ci.org/github/jnbt/candy_check.svg?branch=master)](http://inch-ci.org/github/jnbt/candy_check)
|
8
8
|
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg?style=flat)](http://www.rubydoc.info/github/jnbt/candy_check/master)
|
data/candy_check.gemspec
CHANGED
@@ -18,14 +18,14 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
21
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6")
|
22
22
|
|
23
|
-
spec.add_dependency "google-
|
24
|
-
spec.add_dependency "
|
25
|
-
spec.add_dependency "
|
23
|
+
spec.add_dependency "google-apis-androidpublisher_v3", "~> 0.25.0"
|
24
|
+
spec.add_dependency "googleauth", "~> 1.2.0"
|
25
|
+
spec.add_dependency "multi_json", "~> 1.15"
|
26
|
+
spec.add_dependency "thor", "< 2.0"
|
26
27
|
|
27
28
|
spec.add_development_dependency "bundler", "~> 2.0"
|
28
|
-
spec.add_development_dependency "coveralls", "~> 0.8"
|
29
29
|
spec.add_development_dependency "inch", "~> 0.7"
|
30
30
|
spec.add_development_dependency "minitest", "~> 5.10"
|
31
31
|
spec.add_development_dependency "minitest-around", "~> 0.4"
|
@@ -39,4 +39,6 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.add_development_dependency "awesome_print"
|
40
40
|
spec.add_development_dependency "guard"
|
41
41
|
spec.add_development_dependency "guard-minitest"
|
42
|
+
spec.add_development_dependency "simplecov", "~> 0.18.0"
|
43
|
+
spec.add_development_dependency "simplecov-lcov", "~> 0.8.0"
|
42
44
|
end
|
data/lib/candy_check/cli/app.rb
CHANGED
@@ -21,7 +21,7 @@ module CandyCheck
|
|
21
21
|
desc: "The shared secret for auto-renewable subscriptions"
|
22
22
|
|
23
23
|
def app_store(receipt)
|
24
|
-
Commands::AppStore.run(receipt, options)
|
24
|
+
Commands::AppStore.run(receipt, **options)
|
25
25
|
end
|
26
26
|
|
27
27
|
desc "play_store PACKAGE PRODUCT_ID TOKEN", "Verify PlayStore purchase"
|
@@ -32,7 +32,7 @@ module CandyCheck
|
|
32
32
|
desc: "The json key file to use for API authentication"
|
33
33
|
|
34
34
|
def play_store(package, product_id, token)
|
35
|
-
Commands::PlayStore.run(package, product_id, token, options)
|
35
|
+
Commands::PlayStore.run(package, product_id, token, **options)
|
36
36
|
end
|
37
37
|
|
38
38
|
desc "version", 'Print the gem\'s version'
|
@@ -40,6 +40,10 @@ module CandyCheck
|
|
40
40
|
def version
|
41
41
|
Commands::Version.run
|
42
42
|
end
|
43
|
+
|
44
|
+
def self.exit_on_failure?
|
45
|
+
true
|
46
|
+
end
|
43
47
|
end
|
44
48
|
end
|
45
49
|
end
|
data/lib/candy_check/version.rb
CHANGED
@@ -39,7 +39,7 @@ describe CandyCheck::AppStore::Client do
|
|
39
39
|
body: response
|
40
40
|
)
|
41
41
|
result = subject.verify(receipt_data)
|
42
|
-
result.must_equal expected
|
42
|
+
_(result).must_equal expected
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'sends JSON and parses the JSON response with a secret' do
|
@@ -54,7 +54,7 @@ describe CandyCheck::AppStore::Client do
|
|
54
54
|
body: response
|
55
55
|
)
|
56
56
|
result = subject.verify(receipt_data, password)
|
57
|
-
result.must_equal expected
|
57
|
+
_(result).must_equal expected
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -11,16 +11,16 @@ describe CandyCheck::AppStore::Config do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'returns environment' do
|
14
|
-
subject.environment.must_equal :sandbox
|
14
|
+
_(subject.environment).must_equal :sandbox
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'checks for production?' do
|
18
|
-
subject.production
|
18
|
+
_(subject.production?).must_be_false
|
19
19
|
|
20
20
|
other = CandyCheck::AppStore::Config.new(
|
21
21
|
environment: :production
|
22
22
|
)
|
23
|
-
other.production
|
23
|
+
_(other.production?).must_be_true
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -30,12 +30,12 @@ describe CandyCheck::AppStore::Config do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'needs an environment' do
|
33
|
-
proc { subject }.must_raise ArgumentError
|
33
|
+
_(proc { subject }).must_raise ArgumentError
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'needs an included environment' do
|
37
37
|
attributes[:environment] = :invalid
|
38
|
-
proc { subject }.must_raise ArgumentError
|
38
|
+
_(proc { subject }).must_raise ArgumentError
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -19,27 +19,27 @@ describe CandyCheck::AppStore::ReceiptCollection do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'is expired' do
|
22
|
-
subject.expired
|
22
|
+
_(subject.expired?).must_be_true
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'is not a trial' do
|
26
|
-
subject.trial
|
26
|
+
_(subject.trial?).must_be_false
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'has positive overdue days' do
|
30
30
|
overdue = subject.overdue_days
|
31
|
-
overdue.must_be_instance_of
|
31
|
+
_(overdue).must_be_instance_of Integer
|
32
32
|
assert overdue > 0
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'has a last expires date' do
|
36
36
|
expected = DateTime.new(2015, 4, 15, 12, 52, 40)
|
37
|
-
subject.expires_at.must_equal expected
|
37
|
+
_(subject.expires_at).must_equal expected
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'is expired? at same pointin time' do
|
41
41
|
Timecop.freeze(Time.utc(2015, 4, 15, 12, 52, 40)) do
|
42
|
-
subject.expired
|
42
|
+
_(subject.expired?).must_be_true
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -61,7 +61,7 @@ describe CandyCheck::AppStore::ReceiptCollection do
|
|
61
61
|
|
62
62
|
it 'the expires date is the latest one in time' do
|
63
63
|
expected = DateTime.new(2015, 4, 15, 12, 52, 40)
|
64
|
-
subject.expires_at.must_equal expected
|
64
|
+
_(subject.expires_at).must_equal expected
|
65
65
|
end
|
66
66
|
|
67
67
|
end
|
@@ -83,15 +83,15 @@ describe CandyCheck::AppStore::ReceiptCollection do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'has not expired' do
|
86
|
-
subject.expired
|
86
|
+
_(subject.expired?).must_be_false
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'it is a trial' do
|
90
|
-
subject.trial
|
90
|
+
_(subject.trial?).must_be_true
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'expires in two days' do
|
94
|
-
subject.overdue_days.must_equal(-2)
|
94
|
+
_(subject.overdue_days).must_equal(-2)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -31,62 +31,62 @@ describe CandyCheck::AppStore::Receipt do
|
|
31
31
|
|
32
32
|
describe 'valid transaction' do
|
33
33
|
it 'is valid' do
|
34
|
-
subject.valid
|
34
|
+
_(subject.valid?).must_be_true
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'returns the item\'s id' do
|
38
|
-
subject.item_id.must_equal 'some_item_id'
|
38
|
+
_(subject.item_id).must_equal 'some_item_id'
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'returns the item\'s product_id' do
|
42
|
-
subject.product_id.must_equal 'some_product'
|
42
|
+
_(subject.product_id).must_equal 'some_product'
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'returns the quantity' do
|
46
|
-
subject.quantity.must_equal 1
|
46
|
+
_(subject.quantity).must_equal 1
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'returns the app version' do
|
50
|
-
subject.app_version.must_equal '2.0'
|
50
|
+
_(subject.app_version).must_equal '2.0'
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'returns the bundle identifier' do
|
54
|
-
subject.bundle_identifier.must_equal 'some.test.app'
|
54
|
+
_(subject.bundle_identifier).must_equal 'some.test.app'
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'returns the purchase date' do
|
58
58
|
expected = DateTime.new(2015, 1, 9, 11, 40, 46)
|
59
|
-
subject.purchase_date.must_equal expected
|
59
|
+
_(subject.purchase_date).must_equal expected
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'returns the original purchase date' do
|
63
63
|
expected = DateTime.new(2015, 1, 8, 11, 40, 46)
|
64
|
-
subject.original_purchase_date.must_equal expected
|
64
|
+
_(subject.original_purchase_date).must_equal expected
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'returns the transaction id' do
|
68
|
-
subject.transaction_id.must_equal 'some_transaction_id'
|
68
|
+
_(subject.transaction_id).must_equal 'some_transaction_id'
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'returns the original transaction id' do
|
72
|
-
subject.original_transaction_id.must_equal 'some_original_transaction_id'
|
72
|
+
_(subject.original_transaction_id).must_equal 'some_original_transaction_id'
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'return nil for cancellation date' do
|
76
|
-
subject.cancellation_date.must_be_nil
|
76
|
+
_(subject.cancellation_date).must_be_nil
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'returns raw attributes' do
|
80
|
-
subject.attributes.must_be_same_as attributes
|
80
|
+
_(subject.attributes).must_be_same_as attributes
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'returns the subscription expiration date' do
|
84
84
|
expected = DateTime.new(2016, 6, 9, 13, 59, 40)
|
85
|
-
subject.expires_date.must_equal expected
|
85
|
+
_(subject.expires_date).must_equal expected
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'returns the trial status' do
|
89
|
-
subject.is_trial_period.must_be_false
|
89
|
+
_(subject.is_trial_period).must_be_false
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -96,12 +96,12 @@ describe CandyCheck::AppStore::Receipt do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'isn\'t valid' do
|
99
|
-
subject.valid
|
99
|
+
_(subject.valid?).must_be_false
|
100
100
|
end
|
101
101
|
|
102
102
|
it 'return nil for cancellation date' do
|
103
103
|
expected = DateTime.new(2015, 1, 12, 11, 40, 46)
|
104
|
-
subject.cancellation_date.must_equal expected
|
104
|
+
_(subject.cancellation_date).must_equal expected
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
@@ -11,26 +11,26 @@ describe CandyCheck::AppStore::SubscriptionVerification do
|
|
11
11
|
it 'returns a verification failure for status != 0' do
|
12
12
|
with_mocked_response('status' => 21_000) do |client, recorded|
|
13
13
|
result = subject.call!
|
14
|
-
client.receipt_data.must_equal data
|
15
|
-
client.secret.must_equal secret
|
14
|
+
_(client.receipt_data).must_equal data
|
15
|
+
_(client.secret).must_equal secret
|
16
16
|
|
17
|
-
recorded.first.must_equal [endpoint]
|
17
|
+
_(recorded.first).must_equal [endpoint]
|
18
18
|
|
19
|
-
result.must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
20
|
-
result.code.must_equal 21_000
|
19
|
+
_(result).must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
20
|
+
_(result.code).must_equal 21_000
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'returns a verification failure when receipt is missing' do
|
25
25
|
with_mocked_response({}) do |client, recorded|
|
26
26
|
result = subject.call!
|
27
|
-
client.receipt_data.must_equal data
|
28
|
-
client.secret.must_equal secret
|
27
|
+
_(client.receipt_data).must_equal data
|
28
|
+
_(client.secret).must_equal secret
|
29
29
|
|
30
|
-
recorded.first.must_equal [endpoint]
|
30
|
+
_(recorded.first).must_equal [endpoint]
|
31
31
|
|
32
|
-
result.must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
33
|
-
result.code.must_equal(-1)
|
32
|
+
_(result).must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
33
|
+
_(result.code).must_equal(-1)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -44,12 +44,12 @@ describe CandyCheck::AppStore::SubscriptionVerification do
|
|
44
44
|
}
|
45
45
|
with_mocked_response(response) do
|
46
46
|
result = subject.call!
|
47
|
-
result.must_be_instance_of CandyCheck::AppStore::ReceiptCollection
|
48
|
-
result.receipts.must_be_instance_of Array
|
49
|
-
result.receipts.size.must_equal(2)
|
47
|
+
_(result).must_be_instance_of CandyCheck::AppStore::ReceiptCollection
|
48
|
+
_(result.receipts).must_be_instance_of Array
|
49
|
+
_(result.receipts.size).must_equal(2)
|
50
50
|
last = result.receipts.last
|
51
|
-
last.must_be_instance_of CandyCheck::AppStore::Receipt
|
52
|
-
last.item_id.must_equal('some_other_id')
|
51
|
+
_(last).must_be_instance_of CandyCheck::AppStore::Receipt
|
52
|
+
_(last.item_id).must_equal('some_other_id')
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -75,12 +75,12 @@ describe CandyCheck::AppStore::SubscriptionVerification do
|
|
75
75
|
}
|
76
76
|
with_mocked_response(response) do
|
77
77
|
result = subject.call!
|
78
|
-
result.must_be_instance_of CandyCheck::AppStore::ReceiptCollection
|
79
|
-
result.receipts.must_be_instance_of Array
|
80
|
-
result.receipts.size.must_equal(2)
|
78
|
+
_(result).must_be_instance_of CandyCheck::AppStore::ReceiptCollection
|
79
|
+
_(result.receipts).must_be_instance_of Array
|
80
|
+
_(result.receipts.size).must_equal(2)
|
81
81
|
last = result.receipts.last
|
82
|
-
last.must_be_instance_of CandyCheck::AppStore::Receipt
|
83
|
-
last.item_id.must_equal('some_other_id')
|
82
|
+
_(last).must_be_instance_of CandyCheck::AppStore::Receipt
|
83
|
+
_(last.item_id).must_equal('some_other_id')
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
@@ -9,20 +9,20 @@ describe CandyCheck::AppStore::VerificationFailure do
|
|
9
9
|
it 'fetched an failure with message for every known code' do
|
10
10
|
known.each do |code|
|
11
11
|
got = subject.fetch(code)
|
12
|
-
got.code.must_equal code
|
13
|
-
got.message.wont_equal 'Unknown error'
|
12
|
+
_(got.code).must_equal code
|
13
|
+
_(got.message).wont_equal 'Unknown error'
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'fetched an failure for unknown codes' do
|
18
18
|
got = subject.fetch(1234)
|
19
|
-
got.code.must_equal 1234
|
20
|
-
got.message.must_equal 'Unknown error'
|
19
|
+
_(got.code).must_equal 1234
|
20
|
+
_(got.message).must_equal 'Unknown error'
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'fetched an failure for nil code' do
|
24
24
|
got = subject.fetch(nil)
|
25
|
-
got.code.must_equal(-1)
|
26
|
-
got.message.must_equal 'Unknown error'
|
25
|
+
_(got.code).must_equal(-1)
|
26
|
+
_(got.message).must_equal 'Unknown error'
|
27
27
|
end
|
28
28
|
end
|
@@ -9,26 +9,26 @@ describe CandyCheck::AppStore::Verification do
|
|
9
9
|
it 'returns a verification failure for status != 0' do
|
10
10
|
with_mocked_response('status' => 21_000) do |client, recorded|
|
11
11
|
result = subject.call!
|
12
|
-
client.receipt_data.must_equal data
|
13
|
-
client.secret.must_equal secret
|
12
|
+
_(client.receipt_data).must_equal data
|
13
|
+
_(client.secret).must_equal secret
|
14
14
|
|
15
|
-
recorded.first.must_equal [endpoint]
|
15
|
+
_(recorded.first).must_equal [endpoint]
|
16
16
|
|
17
|
-
result.must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
18
|
-
result.code.must_equal 21_000
|
17
|
+
_(result).must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
18
|
+
_(result.code).must_equal 21_000
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'returns a verification failure when receipt is missing' do
|
23
23
|
with_mocked_response({}) do |client, recorded|
|
24
24
|
result = subject.call!
|
25
|
-
client.receipt_data.must_equal data
|
26
|
-
client.secret.must_equal secret
|
25
|
+
_(client.receipt_data).must_equal data
|
26
|
+
_(client.secret).must_equal secret
|
27
27
|
|
28
|
-
recorded.first.must_equal [endpoint]
|
28
|
+
_(recorded.first).must_equal [endpoint]
|
29
29
|
|
30
|
-
result.must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
31
|
-
result.code.must_equal(-1)
|
30
|
+
_(result).must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
31
|
+
_(result.code).must_equal(-1)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -36,8 +36,8 @@ describe CandyCheck::AppStore::Verification do
|
|
36
36
|
response = { 'status' => 0, 'receipt' => { 'item_id' => 'some_id' } }
|
37
37
|
with_mocked_response(response) do
|
38
38
|
result = subject.call!
|
39
|
-
result.must_be_instance_of CandyCheck::AppStore::Receipt
|
40
|
-
result.item_id.must_equal('some_id')
|
39
|
+
_(result).must_be_instance_of CandyCheck::AppStore::Receipt
|
40
|
+
_(result.item_id).must_equal('some_id')
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -18,7 +18,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'holds the config' do
|
21
|
-
subject.config.must_be_same_as config
|
21
|
+
_(subject.config).must_be_same_as config
|
22
22
|
end
|
23
23
|
|
24
24
|
describe 'sandbox' do
|
@@ -26,7 +26,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
26
26
|
|
27
27
|
it 'uses sandbox endpoint without retry on success' do
|
28
28
|
with_mocked_verifier(receipt) do
|
29
|
-
subject.verify(data, secret).must_be_same_as receipt
|
29
|
+
_(subject.verify(data, secret)).must_be_same_as receipt
|
30
30
|
assert_recorded([sandbox_endpoint, data, secret])
|
31
31
|
end
|
32
32
|
end
|
@@ -34,7 +34,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
34
34
|
it 'only uses sandbox endpoint for normal failures' do
|
35
35
|
failure = get_failure(21_000)
|
36
36
|
with_mocked_verifier(failure) do
|
37
|
-
subject.verify(data, secret).must_be_same_as failure
|
37
|
+
_(subject.verify(data, secret)).must_be_same_as failure
|
38
38
|
assert_recorded([sandbox_endpoint, data, secret])
|
39
39
|
end
|
40
40
|
end
|
@@ -42,7 +42,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
42
42
|
it 'retries production endpoint for redirect error' do
|
43
43
|
failure = get_failure(21_008)
|
44
44
|
with_mocked_verifier(failure, receipt) do
|
45
|
-
subject.verify(data, secret).must_be_same_as receipt
|
45
|
+
_(subject.verify(data, secret)).must_be_same_as receipt
|
46
46
|
assert_recorded(
|
47
47
|
[sandbox_endpoint, data, secret],
|
48
48
|
[production_endpoint, data, secret]
|
@@ -56,7 +56,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
56
56
|
|
57
57
|
it 'uses production endpoint without retry on success' do
|
58
58
|
with_mocked_verifier(receipt) do
|
59
|
-
subject.verify(data, secret).must_be_same_as receipt
|
59
|
+
_(subject.verify(data, secret)).must_be_same_as receipt
|
60
60
|
assert_recorded([production_endpoint, data, secret])
|
61
61
|
end
|
62
62
|
end
|
@@ -64,7 +64,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
64
64
|
it 'only uses production endpoint for normal failures' do
|
65
65
|
failure = get_failure(21_000)
|
66
66
|
with_mocked_verifier(failure) do
|
67
|
-
subject.verify(data, secret).must_be_same_as failure
|
67
|
+
_(subject.verify(data, secret)).must_be_same_as failure
|
68
68
|
assert_recorded([production_endpoint, data, secret])
|
69
69
|
end
|
70
70
|
end
|
@@ -72,7 +72,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
72
72
|
it 'retries production endpoint for redirect error' do
|
73
73
|
failure = get_failure(21_007)
|
74
74
|
with_mocked_verifier(failure, receipt) do
|
75
|
-
subject.verify(data, secret).must_be_same_as receipt
|
75
|
+
_(subject.verify(data, secret)).must_be_same_as receipt
|
76
76
|
assert_recorded(
|
77
77
|
[production_endpoint, data, secret],
|
78
78
|
[sandbox_endpoint, data, secret]
|
@@ -86,9 +86,9 @@ describe CandyCheck::AppStore::Verifier do
|
|
86
86
|
|
87
87
|
it 'uses production endpoint without retry on success' do
|
88
88
|
with_mocked_verifier(receipt_collection) do
|
89
|
-
subject.verify_subscription(
|
89
|
+
_(subject.verify_subscription(
|
90
90
|
data, secret
|
91
|
-
).must_be_same_as receipt_collection
|
91
|
+
)).must_be_same_as receipt_collection
|
92
92
|
assert_recorded([production_endpoint, data, secret, nil])
|
93
93
|
end
|
94
94
|
end
|
@@ -96,7 +96,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
96
96
|
it 'only uses production endpoint for normal failures' do
|
97
97
|
failure = get_failure(21_000)
|
98
98
|
with_mocked_verifier(failure) do
|
99
|
-
subject.verify_subscription(data, secret).must_be_same_as failure
|
99
|
+
_(subject.verify_subscription(data, secret)).must_be_same_as failure
|
100
100
|
assert_recorded([production_endpoint, data, secret, nil])
|
101
101
|
end
|
102
102
|
end
|
@@ -104,7 +104,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
104
104
|
it 'retries production endpoint for redirect error' do
|
105
105
|
failure = get_failure(21_007)
|
106
106
|
with_mocked_verifier(failure, receipt) do
|
107
|
-
subject.verify_subscription(data, secret).must_be_same_as receipt
|
107
|
+
_(subject.verify_subscription(data, secret)).must_be_same_as receipt
|
108
108
|
assert_recorded(
|
109
109
|
[production_endpoint, data, secret, nil],
|
110
110
|
[sandbox_endpoint, data, secret, nil]
|
@@ -115,9 +115,9 @@ describe CandyCheck::AppStore::Verifier do
|
|
115
115
|
it 'passed the product_ids' do
|
116
116
|
product_ids = ['product_1']
|
117
117
|
with_mocked_verifier(receipt_collection) do
|
118
|
-
subject.verify_subscription(
|
118
|
+
_(subject.verify_subscription(
|
119
119
|
data, secret, product_ids
|
120
|
-
).must_be_same_as receipt_collection
|
120
|
+
)).must_be_same_as receipt_collection
|
121
121
|
assert_recorded([production_endpoint, data, secret, product_ids])
|
122
122
|
end
|
123
123
|
end
|
@@ -137,7 +137,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def assert_recorded(*calls)
|
140
|
-
@recorded.must_equal calls
|
140
|
+
_(@recorded).must_equal calls
|
141
141
|
end
|
142
142
|
|
143
143
|
def get_failure(code)
|
data/spec/candy_check_spec.rb
CHANGED
data/spec/cli/app_spec.rb
CHANGED
@@ -5,25 +5,29 @@ describe CandyCheck::CLI::App do
|
|
5
5
|
|
6
6
|
it 'supports the version command' do
|
7
7
|
stub_command(CandyCheck::CLI::Commands::Version) do
|
8
|
-
subject.version.must_equal :stubbed
|
9
|
-
@arguments.must_be_empty
|
8
|
+
_(subject.version).must_equal :stubbed
|
9
|
+
_(@arguments).must_be_empty
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'supports the app_store command' do
|
14
14
|
stub_command(CandyCheck::CLI::Commands::AppStore) do
|
15
|
-
subject.app_store('receipt').must_equal :stubbed
|
16
|
-
@arguments.must_equal ['receipt'
|
15
|
+
_(subject.app_store('receipt')).must_equal :stubbed
|
16
|
+
_(@arguments).must_equal ['receipt']
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'supports the play_store command' do
|
21
21
|
stub_command(CandyCheck::CLI::Commands::PlayStore) do
|
22
|
-
subject.play_store('package', 'id', 'token').must_equal :stubbed
|
23
|
-
@arguments.must_equal ['package', 'id', 'token'
|
22
|
+
_(subject.play_store('package', 'id', 'token')).must_equal :stubbed
|
23
|
+
_(@arguments).must_equal ['package', 'id', 'token']
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
it 'returns true when call .exit_on_failure?' do
|
28
|
+
_(CandyCheck::CLI::App.exit_on_failure?).must_equal true
|
29
|
+
end
|
30
|
+
|
27
31
|
private
|
28
32
|
|
29
33
|
def stub_command(target)
|