ince-api 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.1nce.com/management-api/oauth/token
6
+ body:
7
+ encoding: UTF-8
8
+ string: grant_type=client_credentials
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.1nce.com
18
+ Content-Type:
19
+ - application/x-www-form-urlencoded
20
+ Authorization:
21
+ - Basic ODEwMTIyNTFfUE9MVFJBWDpNclZHNzVYMnNtTXNUeWFO
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Content-Type:
28
+ - application/json
29
+ Content-Length:
30
+ - '2186'
31
+ Connection:
32
+ - keep-alive
33
+ Date:
34
+ - Sun, 14 Nov 2021 20:43:01 GMT
35
+ X-Amzn-Requestid:
36
+ - 62338bd0-ad18-4957-bf07-138bed41e1c2
37
+ X-Amzn-Remapped-X-Amzn-Requestid:
38
+ - fdbf65c2-47de-47ef-a8d9-a8f78036cc7a
39
+ X-Amzn-Remapped-Content-Length:
40
+ - '3108'
41
+ X-Amzn-Remapped-Connection:
42
+ - keep-alive
43
+ Via:
44
+ - 1.1 a56d6b55603697d6c44b19d4f907baaa.cloudfront.net (CloudFront), 1.1 39890eb6fee7152007acf27e00943abf.cloudfront.net
45
+ (CloudFront)
46
+ X-Amz-Apigw-Id:
47
+ - Iz8xVE1cFiAFeCw=
48
+ X-Amzn-Trace-Id:
49
+ - Root=1-619174d5-6d8ced692ef1257a0bcb16b5
50
+ X-Amz-Cf-Pop:
51
+ - FRA6-C1
52
+ - WAW50-C1
53
+ X-Amzn-Remapped-Date:
54
+ - Sun, 14 Nov 2021 20:43:01 GMT
55
+ X-Cache:
56
+ - Miss from cloudfront
57
+ X-Amz-Cf-Id:
58
+ - FbMC4Fg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 20:43:01 GMT
71
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe InceApi::CreateAccessToken do
4
+ it 'invalid credentials' do
5
+ VCR.use_cassette('invalid_credentials') do
6
+ response = described_class.new(username: 'Wrong', password: 'Credentials').create_token
7
+ expect(response['statusCode']).to eq 400
8
+ expect(response['errorCode']).to eq 'CognitoAuthenticationError'
9
+ expect(response['message']).to eq 'User does not exist.'
10
+ end
11
+ end
12
+
13
+ it 'invalid password' do
14
+ VCR.use_cassette('invalid_password') do
15
+ response = described_class.new(username: 'Proper Username', password: 'Invalid Password').create_token
16
+ expect(response['statusCode']).to eq 400
17
+ expect(response['errorCode']).to eq 'CognitoAuthenticationError'
18
+ expect(response['message']).to eq 'Incorrect username or password.'
19
+ end
20
+ end
21
+
22
+ it 'valid credentials' do
23
+ VCR.use_cassette('valid_credentials') do
24
+ response = described_class.new(username: 'Good Username', password: 'Good Password').create_token
25
+ expect(response['status_code']).to eq 200
26
+ expect(response['access_token']).not_to be_nil
27
+ expect(response['expires_in']).to eq 3600
28
+ expect(response['token_type']).to eq 'bearer'
29
+ end
30
+ end
31
+ end
32
+
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe InceApi::GetSim do
4
+ it 'get one sim card' do
5
+ VCR.use_cassette('get_sim') do
6
+ response = described_class.new(access_token: 'VALID TOKEN', iccid: '8988228066602306711').sim
7
+ expect(response['status']).to eq 'Activated'
8
+ expect(response['label']).to eq 'Test API'
9
+ end
10
+ end
11
+
12
+ it 'wrond iccid' do
13
+ VCR.use_cassette('get_sim_wrong_iccid') do
14
+ response = described_class.new(access_token: 'VALID TOKEN', iccid: '11111222233444').sim
15
+ expect(response['error_message']).to eq "SIM with ICCID not found"
16
+ expect(response['status_code']).to eq 404
17
+ end
18
+ end
19
+
20
+ it 'invalid token' do
21
+ VCR.use_cassette('get_sim_wrong_token') do
22
+ response = described_class.new(access_token: 'INVALID TOKEN', iccid: '8988228066602306711').sim
23
+ expect(response['error']).to eq 'Unauthorized'
24
+ expect(response['message']).to eq 'The token is invalid: Illegal base64 character 20'
25
+ expect(response['status']).to eq 401
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe InceApi::GetSims do
4
+ it 'get all sim cards' do
5
+ VCR.use_cassette('get_sims') do
6
+ response = described_class.new(access_token: 'VALID TOKEN').sims
7
+ expect(response.first['status']).to eq 'Enabled'
8
+ expect(response.first['label']).to eq 'Test API'
9
+ end
10
+ end
11
+
12
+ it 'get sim cards with params' do
13
+ VCR.use_cassette('get_sims_with_params') do
14
+ response = described_class.new(access_token: 'VALID TOKEN', params: {page: 2, pageSize: 5}).sims
15
+ expect(response.size).to eq 5
16
+ end
17
+ end
18
+
19
+ it 'paginates results' do
20
+ VCR.use_cassette('get_sims_with_params_page_1') do
21
+ @response_p1 = described_class.new(access_token: 'VALID TOKEN', params: {page: 1, pageSize: 5}).sims
22
+ expect(@response_p1.size).to eq 5
23
+ end
24
+
25
+ VCR.use_cassette('get_sims_with_params') do
26
+ @response_p2 = described_class.new(access_token: 'VALID TOKEN', params: {page: 2, pageSize: 5}).sims
27
+ expect(@response_p2.size).to eq 5
28
+ end
29
+
30
+ expect(@response_p1.first['iccid']).not_to eq(@response_p2.first['iccid'])
31
+ end
32
+
33
+ it 'invalid token' do
34
+ VCR.use_cassette('get_sims_wrong_token') do
35
+ response = described_class.new(access_token: 'INVALID TOKEN').sims
36
+ expect(response['error']).to eq 'Unauthorized'
37
+ expect(response['message']).to eq 'The token is invalid: Illegal base64 character 20'
38
+ expect(response['status']).to eq 401
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe InceApi::MultipleSimsConfiguration do
4
+ it 'updates one sim card - no changes' do
5
+ VCR.use_cassette('update_sims_empty_list') do
6
+ response = described_class.new(access_token: 'VALID TOKEN').update_many
7
+ expect(response[:status]).to eq 'OK'
8
+ end
9
+ end
10
+
11
+ it 'updates one sim card - changes' do
12
+ VCR.use_cassette('update_sims_label_change') do
13
+ params = [{iccid: '8988228066602306711', label: 'Test Label 1'}, {iccid: '8988228066602307111', label: 'Test Label 2'}]
14
+ response = described_class.new(access_token: 'VALID TOKEN', changes_array: params).update_many
15
+ expect(response[:status]).to eq 'OK'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe InceApi::SingleSimConfiguration do
4
+ it 'updates one sim card - no changes' do
5
+ VCR.use_cassette('update_sim_no_change') do
6
+ response = described_class.new(access_token: 'VALID TOKEN', iccid: '8988228066602306770').update
7
+ expect(response[:status]).to eq 'OK'
8
+ end
9
+ end
10
+
11
+ it 'updates one sim card - changes' do
12
+ VCR.use_cassette('update_sim_label_change') do
13
+ response = described_class.new(access_token: 'VALID TOKEN', iccid: '8988228066602306770', params: {label: 'Test Label'}).update
14
+ expect(response[:status]).to eq 'OK'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ require 'ince-api'
2
+ require 'vcr'
3
+
4
+ VCR.configure do |config|
5
+ config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
6
+ config.hook_into :webmock
7
+ end
8
+
9
+ RSpec.configure do |config|
10
+ config.expect_with :rspec do |expectations|
11
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
12
+ end
13
+
14
+ config.mock_with :rspec do |mocks|
15
+ mocks.verify_partial_doubles = true
16
+ end
17
+
18
+ config.shared_context_metadata_behavior = :apply_to_host_groups
19
+ end
20
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ince-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislaw Zawadzki
@@ -80,19 +80,84 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.13'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.9'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.9'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.14'
111
+ - !ruby/object:Gem::Dependency
112
+ name: vcr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '6.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '6.0'
83
125
  description: A simple wrapper for 1nce API
84
126
  email: st.zawadzki@gmail.com
85
127
  executables: []
86
128
  extensions: []
87
129
  extra_rdoc_files: []
88
130
  files:
131
+ - Gemfile
132
+ - Gemfile.lock
89
133
  - README.md
90
134
  - ince-api.gemspec
91
135
  - lib/ince-api.rb
92
136
  - lib/ince_api/create_access_token.rb
93
137
  - lib/ince_api/get_sim.rb
94
138
  - lib/ince_api/get_sims.rb
139
+ - lib/ince_api/multiple_sims_configuration.rb
95
140
  - lib/ince_api/single_sim_configuration.rb
141
+ - spec/fixtures/vcr_cassettes/get_sim.yml
142
+ - spec/fixtures/vcr_cassettes/get_sim_wrong_iccid.yml
143
+ - spec/fixtures/vcr_cassettes/get_sim_wrong_token.yml
144
+ - spec/fixtures/vcr_cassettes/get_sims.yml
145
+ - spec/fixtures/vcr_cassettes/get_sims_with_params.yml
146
+ - spec/fixtures/vcr_cassettes/get_sims_with_params_page_1.yml
147
+ - spec/fixtures/vcr_cassettes/get_sims_wrong_token.yml
148
+ - spec/fixtures/vcr_cassettes/invalid_credentials.yml
149
+ - spec/fixtures/vcr_cassettes/invalid_password.yml
150
+ - spec/fixtures/vcr_cassettes/update_sim_label_change.yml
151
+ - spec/fixtures/vcr_cassettes/update_sim_no_change.yml
152
+ - spec/fixtures/vcr_cassettes/update_sims_empty_list.yml
153
+ - spec/fixtures/vcr_cassettes/update_sims_label_change.yml
154
+ - spec/fixtures/vcr_cassettes/valid_credentials.yml
155
+ - spec/ince-api/create_access_token_spec.rb
156
+ - spec/ince-api/get_sim_spec.rb
157
+ - spec/ince-api/get_sims_spec.rb
158
+ - spec/ince-api/multiple_sims_configuration_spec.rb
159
+ - spec/ince-api/single_sim_configuration_spec.rb
160
+ - spec/spec_helper.rb
96
161
  homepage: https://rubygems.org/gems/ince-api
97
162
  licenses:
98
163
  - MIT
@@ -116,4 +181,24 @@ rubygems_version: 3.1.4
116
181
  signing_key:
117
182
  specification_version: 4
118
183
  summary: 1nce API wrapper
119
- test_files: []
184
+ test_files:
185
+ - spec/fixtures/vcr_cassettes/get_sim.yml
186
+ - spec/fixtures/vcr_cassettes/get_sim_wrong_iccid.yml
187
+ - spec/fixtures/vcr_cassettes/get_sim_wrong_token.yml
188
+ - spec/fixtures/vcr_cassettes/get_sims.yml
189
+ - spec/fixtures/vcr_cassettes/get_sims_with_params.yml
190
+ - spec/fixtures/vcr_cassettes/get_sims_with_params_page_1.yml
191
+ - spec/fixtures/vcr_cassettes/get_sims_wrong_token.yml
192
+ - spec/fixtures/vcr_cassettes/invalid_credentials.yml
193
+ - spec/fixtures/vcr_cassettes/invalid_password.yml
194
+ - spec/fixtures/vcr_cassettes/update_sim_label_change.yml
195
+ - spec/fixtures/vcr_cassettes/update_sim_no_change.yml
196
+ - spec/fixtures/vcr_cassettes/update_sims_empty_list.yml
197
+ - spec/fixtures/vcr_cassettes/update_sims_label_change.yml
198
+ - spec/fixtures/vcr_cassettes/valid_credentials.yml
199
+ - spec/ince-api/create_access_token_spec.rb
200
+ - spec/ince-api/get_sim_spec.rb
201
+ - spec/ince-api/get_sims_spec.rb
202
+ - spec/ince-api/multiple_sims_configuration_spec.rb
203
+ - spec/ince-api/single_sim_configuration_spec.rb
204
+ - spec/spec_helper.rb