punk 0.0.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +9 -0
  3. data/.github/workflows/ship.yml +28 -0
  4. data/.github/workflows/test.yml +45 -0
  5. data/.rdoc_options +23 -0
  6. data/.rgignore +1 -0
  7. data/.rspec +2 -0
  8. data/.rubocop.yml +243 -0
  9. data/Gemfile +6 -6
  10. data/Gemfile.lock +18 -30
  11. data/README.md +8 -0
  12. data/Rakefile +7 -9
  13. data/VERSION +1 -1
  14. data/app/migrations/001_lets_punk.rb +3 -0
  15. data/app/routes/hello.rb +4 -0
  16. data/bin/punk +0 -1
  17. data/env/.gitignore +3 -0
  18. data/env/spec/test.sh +3 -0
  19. data/env/test.sh +5 -0
  20. data/lib/punk/actions/.keep +0 -0
  21. data/lib/punk/actions/groups/list.rb +24 -0
  22. data/lib/punk/actions/sessions/clear.rb +21 -0
  23. data/lib/punk/actions/sessions/create.rb +64 -0
  24. data/lib/punk/actions/sessions/list.rb +18 -0
  25. data/lib/punk/actions/sessions/verify.rb +24 -0
  26. data/lib/punk/actions/tenants/list.rb +18 -0
  27. data/lib/punk/actions/users/list_group.rb +18 -0
  28. data/lib/punk/actions/users/list_tenant.rb +18 -0
  29. data/lib/punk/actions/users/show.rb +18 -0
  30. data/lib/punk/commands/http.rb +3 -3
  31. data/lib/punk/commands/list.rb +12 -6
  32. data/lib/punk/config/defaults.json +3 -0
  33. data/lib/punk/config/schema.json +3 -0
  34. data/lib/punk/core/app.rb +6 -8
  35. data/lib/punk/core/commander.rb +9 -6
  36. data/lib/punk/core/exec.rb +2 -0
  37. data/lib/punk/core/load.rb +0 -1
  38. data/lib/punk/framework/command.rb +5 -1
  39. data/lib/punk/framework/plugins/validation.rb +0 -14
  40. data/lib/punk/framework/runnable.rb +1 -1
  41. data/lib/punk/helpers/loggable.rb +1 -1
  42. data/lib/punk/migrations/001_punk.rb +103 -0
  43. data/lib/punk/models/.keep +0 -0
  44. data/lib/punk/models/group.rb +20 -0
  45. data/lib/punk/models/group_user_metadata.rb +17 -0
  46. data/lib/punk/models/identity.rb +29 -0
  47. data/lib/punk/models/session.rb +89 -0
  48. data/lib/punk/models/tenant.rb +19 -0
  49. data/lib/punk/models/tenant_user_metadata.rb +17 -0
  50. data/lib/punk/models/user.rb +31 -0
  51. data/lib/punk/routes/groups.rb +31 -0
  52. data/lib/punk/routes/plivo.rb +4 -0
  53. data/lib/punk/routes/sessions.rb +108 -0
  54. data/lib/punk/routes/swagger.rb +9 -0
  55. data/lib/punk/routes/tenants.rb +29 -0
  56. data/lib/punk/routes/users.rb +36 -0
  57. data/lib/punk/services/.keep +0 -0
  58. data/lib/punk/services/challenge_claim.rb +46 -0
  59. data/lib/punk/services/create_identities.rb +25 -0
  60. data/lib/punk/services/generate_swagger.rb +25 -0
  61. data/lib/punk/services/prove_claim.rb +29 -0
  62. data/lib/punk/services/secret.rb +9 -0
  63. data/lib/punk/templates/groups/list.jbuilder +7 -0
  64. data/lib/punk/templates/plivo.slim +16 -0
  65. data/lib/punk/templates/sessions/list.jbuilder +6 -0
  66. data/lib/punk/templates/sessions/pending.jbuilder +4 -0
  67. data/lib/punk/templates/tenants/list.jbuilder +7 -0
  68. data/lib/punk/templates/tenants/list.slim +8 -0
  69. data/lib/punk/templates/users/list.jbuilder +7 -0
  70. data/lib/punk/templates/users/list.rcsv +4 -0
  71. data/lib/punk/templates/users/show.jbuilder +5 -0
  72. data/lib/punk/views/groups/list.rb +22 -0
  73. data/lib/punk/views/plivo_store.rb +15 -0
  74. data/lib/punk/views/sessions/list.rb +22 -0
  75. data/lib/punk/views/sessions/pending.rb +28 -0
  76. data/lib/punk/views/tenants/list.rb +22 -0
  77. data/lib/punk/views/users/list.rb +22 -0
  78. data/lib/punk/views/users/show.rb +22 -0
  79. data/lib/punk/workers/.keep +0 -0
  80. data/lib/punk/workers/expire_sessions.rb +9 -0
  81. data/lib/punk/workers/geocode_session_worker.rb +48 -0
  82. data/lib/punk/workers/identify_session_worker.rb +45 -0
  83. data/lib/punk/workers/secret.rb +18 -0
  84. data/lib/punk/workers/send_email_worker.rb +51 -0
  85. data/lib/punk/workers/send_sms_worker.rb +40 -0
  86. data/punk.gemspec +149 -16
  87. data/schema.psql +345 -0
  88. data/spec/actions/groups/punk/list_groups_action_spec.rb +36 -0
  89. data/spec/actions/sessions/punk/clear_session_action_spec.rb +29 -0
  90. data/spec/actions/sessions/punk/create_session_action_spec.rb +33 -0
  91. data/spec/actions/sessions/punk/list_sessions_action_spec.rb +26 -0
  92. data/spec/actions/sessions/punk/verify_session_action_spec.rb +59 -0
  93. data/spec/actions/tenants/punk/list_tenants_action_spec.rb +25 -0
  94. data/spec/actions/users/punk/list_group_users_action_spec.rb +26 -0
  95. data/spec/actions/users/punk/list_tenant_users_action_spec.rb +26 -0
  96. data/spec/factories/group.rb +12 -0
  97. data/spec/factories/group_user_metadata.rb +10 -0
  98. data/spec/factories/identity.rb +19 -0
  99. data/spec/factories/session.rb +12 -0
  100. data/spec/factories/tenant.rb +10 -0
  101. data/spec/factories/tenant_user_metadata.rb +10 -0
  102. data/spec/factories/user.rb +12 -0
  103. data/spec/lib/commands/auth_spec.rb +11 -0
  104. data/spec/lib/commands/generate_spec.rb +7 -0
  105. data/spec/lib/commands/http_spec.rb +23 -0
  106. data/spec/lib/commands/list_spec.rb +7 -0
  107. data/spec/lib/commands/swagger_spec.rb +7 -0
  108. data/spec/lib/engine/punk_env_spec.rb +13 -0
  109. data/spec/lib/engine/punk_exec_spec.rb +9 -0
  110. data/spec/lib/engine/punk_init_spec.rb +9 -0
  111. data/spec/lib/engine/punk_store_spec.rb +10 -0
  112. data/spec/lib/punk.env +7 -0
  113. data/spec/models/punk/group_spec.rb +50 -0
  114. data/spec/models/punk/group_user_metadata_spec.rb +61 -0
  115. data/spec/models/punk/identity_spec.rb +61 -0
  116. data/spec/models/punk/session_spec.rb +156 -0
  117. data/spec/models/punk/tenant_spec.rb +51 -0
  118. data/spec/models/punk/tenant_user_metadata_spec.rb +61 -0
  119. data/spec/models/punk/user_spec.rb +115 -0
  120. data/spec/routes/groups/get_groups_spec.rb +33 -0
  121. data/spec/routes/plivo/get_plivo_spec.rb +11 -0
  122. data/spec/routes/sessions/delete_session_spec.rb +11 -0
  123. data/spec/routes/sessions/get_sessions_spec.rb +30 -0
  124. data/spec/routes/sessions/patch_session_spec.rb +11 -0
  125. data/spec/routes/sessions/post_session_spec.rb +11 -0
  126. data/spec/routes/swagger/get_swagger_spec.rb +12 -0
  127. data/spec/routes/tenants/get_tenants_spec.rb +31 -0
  128. data/spec/routes/users/get_users_spec.rb +60 -0
  129. data/spec/services/punk/challenge_claim_service_spec.rb +7 -0
  130. data/spec/services/punk/create_identities_service_spec.rb +14 -0
  131. data/spec/services/punk/generate_swagger_service_spec.rb +7 -0
  132. data/spec/services/punk/prove_claim_service_spec.rb +7 -0
  133. data/spec/services/punk/secret_service_spec.rb +7 -0
  134. data/spec/spec_helper.rb +122 -0
  135. data/spec/vcr_cassettes/PUNK_GeocodeSessionWorker/updates_the_session_data.yml +57 -0
  136. data/spec/vcr_cassettes/PUNK_IdentifySessionWorker/updates_the_session_data.yml +112 -0
  137. data/spec/views/punk/plivo_store_spec.rb +7 -0
  138. data/spec/views/sessions/punk/list_sessions_view_spec.rb +7 -0
  139. data/spec/views/sessions/punk/pending_session_view_spec.rb +7 -0
  140. data/spec/views/tenants/punk/list_tenants_view_spec.rb +7 -0
  141. data/spec/views/users/punk/list_groups_view_spec.rb +7 -0
  142. data/spec/views/users/punk/list_users_view_spec.rb +7 -0
  143. data/spec/workers/punk/expire_sessions_worker_spec.rb +31 -0
  144. data/spec/workers/punk/geocode_session_worker_spec.rb +14 -0
  145. data/spec/workers/punk/identify_session_worker_spec.rb +15 -0
  146. data/spec/workers/punk/secret_worker_spec.rb +20 -0
  147. data/spec/workers/punk/send_email_worker_spec.rb +46 -0
  148. data/spec/workers/punk/send_sms_worker_spec.rb +33 -0
  149. metadata +169 -13
  150. data/lib/punk/views/all.rb +0 -4
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe PUNK, "GET /plivo" do
4
+ include_context "Punk"
5
+
6
+ before do
7
+ get '/plivo.html'
8
+ end
9
+
10
+ it { is_expected.to be_successful }
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe PUNK, "DELETE /sessions" do
4
+ include_context "Punk"
5
+
6
+ before do
7
+ delete '/sessions'
8
+ end
9
+
10
+ it { is_expected.not_to be_successful }
11
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe PUNK, "GET /sessions" do
4
+ include_context "Punk"
5
+
6
+ context 'when the user is not authenticated' do
7
+ before do
8
+ get '/sessions'
9
+ end
10
+
11
+ it { is_expected.not_to be_successful }
12
+ end
13
+
14
+ context 'when the user is authenticated' do
15
+ let(:user) { create(:user) }
16
+ let(:identity) { create(:identity, user: user, claim_type: 'phone') }
17
+
18
+ before do
19
+ login(identity.claim)
20
+ get '/sessions'
21
+ end
22
+
23
+ after do
24
+ logout
25
+ end
26
+
27
+ it { is_expected.to be_successful }
28
+ its(:body) { is_expected.to match(user.active_sessions.first.id) }
29
+ end
30
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe PUNK, "PATCH /sessions" do
4
+ include_context "Punk"
5
+
6
+ before do
7
+ patch '/sessions'
8
+ end
9
+
10
+ it { is_expected.not_to be_successful }
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe PUNK, "POST /sessions" do
4
+ include_context "Punk"
5
+
6
+ before do
7
+ post '/sessions'
8
+ end
9
+
10
+ it { is_expected.not_to be_successful }
11
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe PUNK, "GET /swagger" do
4
+ include_context "Punk"
5
+
6
+ before do
7
+ get '/swagger'
8
+ end
9
+
10
+ it { is_expected.to be_successful }
11
+ its(:body) { is_expected.to match('"openapi": "3.0.0"') }
12
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe PUNK, "GET /tenants" do
4
+ include_context "Punk"
5
+
6
+ context 'when the user is not authenticated' do
7
+ before do
8
+ get '/tenants'
9
+ end
10
+
11
+ it { is_expected.not_to be_successful }
12
+ end
13
+
14
+ context 'when the user is authenticated' do
15
+ let(:tenant) { create(:tenant) }
16
+ let(:identity) { create(:identity, claim_type: 'phone') }
17
+
18
+ before do
19
+ identity.user.add_tenant(tenant)
20
+ login(identity.claim)
21
+ get '/tenants'
22
+ end
23
+
24
+ after do
25
+ logout
26
+ end
27
+
28
+ it { is_expected.to be_successful }
29
+ its(:body) { is_expected.to match(tenant.name) }
30
+ end
31
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe PUNK, "GET /users" do
4
+ include_context "Punk"
5
+
6
+ context 'when the user is not authenticated' do
7
+ before do
8
+ get '/users'
9
+ end
10
+
11
+ it { is_expected.not_to be_successful }
12
+ end
13
+
14
+ context 'when the user is authenticated' do
15
+ let(:tenant) { create(:tenant) }
16
+ let(:identity) { create(:identity, claim_type: 'phone') }
17
+ let(:group) { create(:group, tenant: tenant) }
18
+ let(:tenant_user) { create(:user) }
19
+ let(:group_user) { create(:user) }
20
+
21
+ before do
22
+ identity.user.add_tenant(tenant)
23
+ identity.user.add_group(group)
24
+ tenant_user.add_tenant(tenant)
25
+ group_user.add_tenant(tenant)
26
+ group_user.add_group(group)
27
+ login(identity.claim)
28
+ end
29
+
30
+ after do
31
+ logout
32
+ end
33
+
34
+ context 'without a group' do
35
+ before do
36
+ get "/users?tenant_id=#{tenant.id}"
37
+ end
38
+
39
+ it { is_expected.to be_successful }
40
+
41
+ its(:body) do
42
+ is_expected.to match(tenant_user.name)
43
+ is_expected.to match(group_user.name)
44
+ end
45
+ end
46
+
47
+ context 'with a group' do
48
+ before do
49
+ get "/users?tenant_id=#{tenant.id}&group_id=#{group.id}"
50
+ end
51
+
52
+ it { is_expected.to be_successful }
53
+
54
+ its(:body) do
55
+ is_expected.not_to match(tenant_user.name)
56
+ is_expected.to match(group_user.name)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe PUNK::ChallengeClaimService do
4
+ context 'with no specs written' do
5
+ it 'displays a warning'
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe PUNK::CreateIdentitiesService do
4
+ before do
5
+ create(:user, phone: nil)
6
+ create(:user, email: nil)
7
+ end
8
+
9
+ it 'creates identities for users that are missing them' do
10
+ expect(PUNK::Identity.count).to eq(0)
11
+ described_class.run
12
+ expect(PUNK::Identity.count).to eq(2)
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe PUNK::GenerateSwaggerService do
4
+ context 'with no specs written' do
5
+ it 'displays a warning'
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe PUNK::ProveClaimService do
4
+ context 'with no specs written' do
5
+ it 'displays a warning'
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe PUNK::SecretService do
4
+ context 'with no specs written' do
5
+ it 'displays a warning'
6
+ end
7
+ end
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov'
4
+ require 'coveralls'
5
+ SimpleCov.start do
6
+ add_filter 'spec'
7
+ add_filter 'lib/punk/commands/auth.rb'
8
+ add_filter 'lib/punk/commands/generate.rb'
9
+ add_filter 'lib/punk/commands/http.rb'
10
+ add_filter 'lib/punk/commands/list.rb'
11
+ add_filter 'lib/punk/core/commands.rb'
12
+ add_filter 'lib/punk/framework/command.rb'
13
+ add_filter 'lib/punk/plugins/cors.rb'
14
+ add_filter 'lib/punk/plugins/ssl.rb'
15
+ add_filter 'lib/punk/startup/logger.rb'
16
+ end
17
+ Coveralls.wear!
18
+
19
+ require_relative '../lib/punk'
20
+
21
+ require 'factory_bot'
22
+ require 'faker'
23
+ require 'timecop'
24
+ require 'securerandom'
25
+ require 'vcr'
26
+ require 'rack/test'
27
+
28
+ Faker::Config.locale = 'en-US'
29
+
30
+ FactoryBot.use_parent_strategy = false
31
+
32
+ VCR.configure do |c|
33
+ c.ignore_localhost = true
34
+ c.cassette_library_dir = 'spec/vcr_cassettes'
35
+ c.hook_into :webmock
36
+ c.configure_rspec_metadata!
37
+ end
38
+
39
+ PUNK.init(task: 'spec', config: { app: { name: 'Punk Test' } }).exec
40
+
41
+ Sidekiq.logger = SemanticLogger['PUNK::SKQ']
42
+
43
+ RSpec.shared_context 'Punk' do # rubocop:disable RSpec/ContextWording
44
+ include Rack::Test::Methods
45
+
46
+ subject { last_response }
47
+
48
+ def app
49
+ PUNK.app
50
+ end
51
+
52
+ def login(claim)
53
+ PUNK.cache.delete(:plivo)
54
+ response =
55
+ PUNK.app.call(
56
+ "REQUEST_METHOD" => "POST",
57
+ "PATH_INFO" => "/sessions",
58
+ "CONTENT_TYPE" => "text/json",
59
+ "SCRIPT_NAME" => "",
60
+ "rack.input" => StringIO.new({ claim: claim }.to_json)
61
+ )
62
+ response = ActiveSupport::JSON.decode(response[-1].first).deep_symbolize_keys
63
+ slug = response[:slug]
64
+ PUNK::SendSmsWorker.drain
65
+ sms = PUNK.cache.get(:plivo).first
66
+ PUNK.app.call(
67
+ "REQUEST_METHOD" => "PATCH",
68
+ "PATH_INFO" => "/sessions/#{slug}",
69
+ "CONTENT_TYPE" => "text/json",
70
+ "SCRIPT_NAME" => "",
71
+ "rack.input" => StringIO.new({ secret: sms[:body][-7..-2] }.to_json)
72
+ )
73
+ end
74
+
75
+ def logout
76
+ PUNK.app.call(
77
+ "REQUEST_METHOD" => "DELETE",
78
+ "PATH_INFO" => "/sessions",
79
+ "SCRIPT_NAME" => "",
80
+ "rack.input" => StringIO.new
81
+ )
82
+ end
83
+ end
84
+
85
+ module Helpers
86
+ def valid_uuid?(data)
87
+ data.split('-').map { |s| Integer(s, 16) }.length == 5
88
+ end
89
+ end
90
+
91
+ FactoryBot.define do
92
+ sequence :phone do
93
+ phone = "+1#{Phony.normalize(Faker::PhoneNumber.cell_phone)}" until Phony.plausible?(phone)
94
+ phone
95
+ end
96
+
97
+ sequence :uuid do
98
+ SecureRandom.uuid
99
+ end
100
+ end
101
+
102
+ RSpec.configure do |config|
103
+ config.expect_with :rspec do |expectations|
104
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
105
+ end
106
+
107
+ config.include Helpers
108
+
109
+ config.include FactoryBot::Syntax::Methods
110
+ config.before(:suite) do
111
+ FactoryBot.find_definitions
112
+ end
113
+ config.before do
114
+ Sidekiq::Worker.clear_all
115
+ end
116
+
117
+ config.around do |example|
118
+ PUNK.db.transaction(rollback: :always, auto_savepoint: true) { example.run }
119
+ end
120
+
121
+ PUNK.commands(:spec, config)
122
+ end
@@ -0,0 +1,57 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.ipstack.com/42.221.129.61?access_key=8125be66761ffcad1604896a17d00ac4
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Tue, 12 Jan 2021 09:12:13 GMT
23
+ Content-Type:
24
+ - application/json; Charset=UTF-8
25
+ Transfer-Encoding:
26
+ - chunked
27
+ Connection:
28
+ - keep-alive
29
+ Set-Cookie:
30
+ - __cfduid=df0fa25d4e0073142f3e466cbb8e9237d1610442733; expires=Thu, 11-Feb-21
31
+ 09:12:13 GMT; path=/; domain=.ipstack.com; HttpOnly; SameSite=Lax
32
+ X-Apilayer-Transaction-Id:
33
+ - caef65a2-5cd1-4be2-9d01-a3f045f5e011
34
+ Access-Control-Allow-Methods:
35
+ - GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS
36
+ Access-Control-Allow-Origin:
37
+ - "*"
38
+ X-Request-Time:
39
+ - '0.014'
40
+ Cf-Cache-Status:
41
+ - DYNAMIC
42
+ Cf-Request-Id:
43
+ - '0797770e3300003e76e7ab3000000001'
44
+ Report-To:
45
+ - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=Uenx5X7lc5Ezh895Wc50n0Isr6maHO6FOA%2BRfJjJmgQiXBdHDhrhjBNxBsssKN178ozv9zvrsBtroUCIEdQIEf9QvpWMnfD3bVh1gLHHV44%3D"}],"group":"cf-nel","max_age":604800}'
46
+ Nel:
47
+ - '{"report_to":"cf-nel","max_age":604800}'
48
+ Server:
49
+ - cloudflare
50
+ Cf-Ray:
51
+ - 6105c129e8443e76-ADL
52
+ body:
53
+ encoding: ASCII-8BIT
54
+ string: '{"ip":"42.221.129.61","type":"ipv4","continent_code":"AS","continent_name":"Asia","country_code":"CN","country_name":"China","region_code":"BJ","region_name":"Beijing","city":"Beijing","zip":"100038","latitude":39.912288665771484,"longitude":116.3658676147461,"location":{"geoname_id":1816670,"capital":"Beijing","languages":[{"code":"zh","name":"Chinese","native":"\u4e2d\u6587"}],"country_flag":"http:\/\/assets.ipstack.com\/flags\/cn.svg","country_flag_emoji":"\ud83c\udde8\ud83c\uddf3","country_flag_emoji_unicode":"U+1F1E8
55
+ U+1F1F3","calling_code":"86","is_eu":false}}'
56
+ recorded_at: Thu, 22 Sep 2022 09:28:13 GMT
57
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,112 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.userstack.com/detect?access_key=a4b1af0fb201d34a6d5e457c6b7adb00&ua=Mozilla/5.0%20(Windows%20NT%20x.y%3B%20Win64%3B%20x64%3B%20rv:10.0)%20Gecko/20100101%20Firefox/10.0
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Userstack gem/0.1.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Tue, 12 Jan 2021 09:12:14 GMT
23
+ Content-Type:
24
+ - application/json; Charset=UTF-8
25
+ Transfer-Encoding:
26
+ - chunked
27
+ Connection:
28
+ - keep-alive
29
+ Set-Cookie:
30
+ - __cfduid=db0548b42a779266f4790ea8166bdd4581610442733; expires=Thu, 11-Feb-21
31
+ 09:12:13 GMT; path=/; domain=.userstack.com; HttpOnly; SameSite=Lax
32
+ X-Apilayer-Transaction-Id:
33
+ - 454d0588-d787-4d01-b289-5a0038a25ee7
34
+ Access-Control-Allow-Methods:
35
+ - GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS
36
+ Access-Control-Allow-Origin:
37
+ - "*"
38
+ X-Request-Time:
39
+ - '0.078'
40
+ Cf-Cache-Status:
41
+ - DYNAMIC
42
+ Cf-Request-Id:
43
+ - '079777114700003e638fb08000000001'
44
+ Report-To:
45
+ - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=pLrm5k%2Fi9dtcefUXSTR6PXZbtnMZKqUzyi02QEWLC47MbuX678rfUazHnI2eSEecDBP04Z058W04qlR%2FeqM7g1x6NblI0fMkzM4Prk76ikkanA%3D%3D"}],"group":"cf-nel","max_age":604800}'
46
+ Nel:
47
+ - '{"report_to":"cf-nel","max_age":604800}'
48
+ Server:
49
+ - cloudflare
50
+ Cf-Ray:
51
+ - 6105c12ed9223e63-ADL
52
+ body:
53
+ encoding: ASCII-8BIT
54
+ string: '{"ua":"Mozilla\/5.0 (Windows NT x.y; Win64; x64; rv:10.0) Gecko\/20100101
55
+ Firefox\/10.0","type":"browser","brand":null,"name":null,"url":"https:\/\/www.mozilla.org\/","os":{"name":"Windows","code":"windows","url":"https:\/\/en.wikipedia.org\/wiki\/Windows","family":"Windows","family_code":"windows","family_vendor":"Microsoft
56
+ Corporation.","icon":"https:\/\/assets.userstack.com\/icon\/os\/windows.png","icon_large":"https:\/\/assets.userstack.com\/icon\/os\/windows_big.png"},"device":{"is_mobile_device":false,"type":"desktop","brand":null,"brand_code":null,"brand_url":null,"name":null},"browser":{"name":"Firefox","version":"10.0","version_major":"10","engine":"Gecko"},"crawler":{"is_crawler":false,"category":null,"last_seen":null}}'
57
+ recorded_at: Thu, 22 Sep 2022 09:28:14 GMT
58
+ - request:
59
+ method: get
60
+ uri: http://api.ipstack.com/92.177.45.168?access_key=8125be66761ffcad1604896a17d00ac4
61
+ body:
62
+ encoding: US-ASCII
63
+ string: ''
64
+ headers:
65
+ Accept-Encoding:
66
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
67
+ Accept:
68
+ - "*/*"
69
+ User-Agent:
70
+ - Ruby
71
+ response:
72
+ status:
73
+ code: 200
74
+ message: OK
75
+ headers:
76
+ Date:
77
+ - Tue, 12 Jan 2021 09:12:15 GMT
78
+ Content-Type:
79
+ - application/json; Charset=UTF-8
80
+ Transfer-Encoding:
81
+ - chunked
82
+ Connection:
83
+ - keep-alive
84
+ Set-Cookie:
85
+ - __cfduid=d09629f587b5e96df54ed5c24f57106641610442734; expires=Thu, 11-Feb-21
86
+ 09:12:14 GMT; path=/; domain=.ipstack.com; HttpOnly; SameSite=Lax
87
+ X-Apilayer-Transaction-Id:
88
+ - ed39795d-84f4-4260-85c9-356205d21f34
89
+ Access-Control-Allow-Methods:
90
+ - GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS
91
+ Access-Control-Allow-Origin:
92
+ - "*"
93
+ X-Request-Time:
94
+ - '0.014'
95
+ Cf-Cache-Status:
96
+ - DYNAMIC
97
+ Cf-Request-Id:
98
+ - '07977713f000003e5edc09b000000001'
99
+ Report-To:
100
+ - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=zwkDF9e6nBBIRQ9DRnQhJakXNshZyHSuVB0GDGhrqPJBADBFWnsUL6pQU0eXUHnxouMS5Ec%2Fzd%2BJSe4NZXkogkQ1QCR1vil1gaEo2USlO%2Fs%3D"}],"group":"cf-nel","max_age":604800}'
101
+ Nel:
102
+ - '{"report_to":"cf-nel","max_age":604800}'
103
+ Server:
104
+ - cloudflare
105
+ Cf-Ray:
106
+ - 6105c1331d423e5e-ADL
107
+ body:
108
+ encoding: ASCII-8BIT
109
+ string: '{"ip":"92.177.45.168","type":"ipv4","continent_code":"EU","continent_name":"Europe","country_code":"ES","country_name":"Spain","region_code":"CT","region_name":"Catalonia","city":"Tarragona","zip":"43002","latitude":41.1220588684082,"longitude":1.249400019645691,"location":{"geoname_id":3108288,"capital":"Madrid","languages":[{"code":"es","name":"Spanish","native":"Espa\u00f1ol"},{"code":"eu","name":"Basque","native":"Euskara"},{"code":"ca","name":"Catalan","native":"Catal\u00e0"},{"code":"gl","name":"Galician","native":"Galego"},{"code":"oc","name":"Occitan","native":"Occitan"}],"country_flag":"http:\/\/assets.ipstack.com\/flags\/es.svg","country_flag_emoji":"\ud83c\uddea\ud83c\uddf8","country_flag_emoji_unicode":"U+1F1EA
110
+ U+1F1F8","calling_code":"34","is_eu":true}}'
111
+ recorded_at: Thu, 22 Sep 2022 09:28:15 GMT
112
+ recorded_with: VCR 6.0.0