minty 1.0.0 → 1.1.0

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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -16
  3. data/Gemfile.lock +28 -208
  4. data/README.md +58 -57
  5. data/Rakefile +4 -27
  6. data/docs/DefaultApi.md +217 -0
  7. data/docs/RedirectUrl.md +18 -0
  8. data/git_push.sh +57 -0
  9. data/lib/minty/api/default_api.rb +210 -0
  10. data/lib/minty/api_client.rb +388 -0
  11. data/lib/minty/api_error.rb +53 -0
  12. data/lib/minty/configuration.rb +275 -0
  13. data/lib/minty/models/redirect_url.rb +216 -0
  14. data/lib/minty/version.rb +9 -3
  15. data/lib/minty.rb +33 -7
  16. data/minty.gemspec +19 -32
  17. data/pkg/minty-1.1.0.gem +0 -0
  18. data/publish_rubygem.sh +1 -1
  19. data/spec/api/default_api_spec.rb +65 -0
  20. data/spec/api_client_spec.rb +222 -0
  21. data/spec/configuration_spec.rb +38 -0
  22. data/spec/models/redirect_url_spec.rb +28 -0
  23. data/spec/spec_helper.rb +95 -63
  24. metadata +37 -292
  25. data/.bundle/config +0 -4
  26. data/.devcontainer/Dockerfile +0 -19
  27. data/.devcontainer/devcontainer.json +0 -37
  28. data/.env.example +0 -2
  29. data/.gemrelease +0 -2
  30. data/.github/PULL_REQUEST_TEMPLATE.md +0 -33
  31. data/.github/dependabot.yml +0 -10
  32. data/.github/stale.yml +0 -20
  33. data/.gitignore +0 -18
  34. data/.rspec +0 -3
  35. data/.rubocop.yml +0 -9
  36. data/CODE_OF_CONDUCT.md +0 -3
  37. data/DEPLOYMENT.md +0 -61
  38. data/DEVELOPMENT.md +0 -35
  39. data/EXAMPLES.md +0 -195
  40. data/Guardfile +0 -39
  41. data/LICENSE +0 -21
  42. data/Makefile +0 -5
  43. data/RUBYGEM.md +0 -9
  44. data/codecov.yml +0 -22
  45. data/lib/minty/algorithm.rb +0 -7
  46. data/lib/minty/api/authentication_endpoints.rb +0 -30
  47. data/lib/minty/api/v2.rb +0 -8
  48. data/lib/minty/client.rb +0 -7
  49. data/lib/minty/exception.rb +0 -50
  50. data/lib/minty/mixins/api_token_struct.rb +0 -4
  51. data/lib/minty/mixins/headers.rb +0 -19
  52. data/lib/minty/mixins/httpproxy.rb +0 -125
  53. data/lib/minty/mixins/initializer.rb +0 -38
  54. data/lib/minty/mixins/validation.rb +0 -113
  55. data/lib/minty/mixins.rb +0 -23
  56. data/lib/minty_client.rb +0 -4
  57. data/spec/integration/lib/minty/api/api_authentication_spec.rb +0 -122
  58. data/spec/integration/lib/minty/minty_client_spec.rb +0 -92
  59. data/spec/lib/minty/client_spec.rb +0 -223
  60. data/spec/lib/minty/mixins/httpproxy_spec.rb +0 -658
  61. data/spec/lib/minty/mixins/initializer_spec.rb +0 -121
  62. data/spec/lib/minty/mixins/token_management_spec.rb +0 -129
  63. data/spec/lib/minty/mixins/validation_spec.rb +0 -559
  64. data/spec/support/credentials.rb +0 -14
  65. data/spec/support/dummy_class.rb +0 -20
  66. data/spec/support/dummy_class_for_proxy.rb +0 -6
  67. data/spec/support/dummy_class_for_restclient.rb +0 -4
  68. data/spec/support/dummy_class_for_tokens.rb +0 -18
  69. data/spec/support/import_users.json +0 -13
  70. data/spec/support/stub_response.rb +0 -3
@@ -0,0 +1,222 @@
1
+ =begin
2
+ #Minty API
3
+
4
+ #Minty API
5
+
6
+
7
+ =end
8
+
9
+ require 'spec_helper'
10
+
11
+ describe MintyApi::ApiClient do
12
+ context 'initialization' do
13
+ context 'URL stuff' do
14
+ context 'host' do
15
+ it 'removes http from host' do
16
+ MintyApi.configure { |c| c.host = 'http://example.com' }
17
+ expect(MintyApi::Configuration.default.host).to eq('example.com')
18
+ end
19
+
20
+ it 'removes https from host' do
21
+ MintyApi.configure { |c| c.host = 'https://wookiee.com' }
22
+ expect(MintyApi::ApiClient.default.config.host).to eq('wookiee.com')
23
+ end
24
+
25
+ it 'removes trailing path from host' do
26
+ MintyApi.configure { |c| c.host = 'hobo.com/v4' }
27
+ expect(MintyApi::Configuration.default.host).to eq('hobo.com')
28
+ end
29
+ end
30
+
31
+ context 'base_path' do
32
+ it "prepends a slash to base_path" do
33
+ MintyApi.configure { |c| c.base_path = 'v4/dog' }
34
+ expect(MintyApi::Configuration.default.base_path).to eq('/v4/dog')
35
+ end
36
+
37
+ it "doesn't prepend a slash if one is already there" do
38
+ MintyApi.configure { |c| c.base_path = '/v4/dog' }
39
+ expect(MintyApi::Configuration.default.base_path).to eq('/v4/dog')
40
+ end
41
+
42
+ it "ends up as a blank string if nil" do
43
+ MintyApi.configure { |c| c.base_path = nil }
44
+ expect(MintyApi::Configuration.default.base_path).to eq('')
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ describe 'params_encoding in #build_request' do
51
+ let(:config) { MintyApi::Configuration.new }
52
+ let(:api_client) { MintyApi::ApiClient.new(config) }
53
+
54
+ it 'defaults to nil' do
55
+ expect(MintyApi::Configuration.default.params_encoding).to eq(nil)
56
+ expect(config.params_encoding).to eq(nil)
57
+
58
+ request = api_client.build_request(:get, '/test')
59
+ expect(request.options[:params_encoding]).to eq(nil)
60
+ end
61
+
62
+ it 'can be customized' do
63
+ config.params_encoding = :multi
64
+ request = api_client.build_request(:get, '/test')
65
+ expect(request.options[:params_encoding]).to eq(:multi)
66
+ end
67
+ end
68
+
69
+ describe 'timeout in #build_request' do
70
+ let(:config) { MintyApi::Configuration.new }
71
+ let(:api_client) { MintyApi::ApiClient.new(config) }
72
+
73
+ it 'defaults to 0' do
74
+ expect(MintyApi::Configuration.default.timeout).to eq(0)
75
+ expect(config.timeout).to eq(0)
76
+
77
+ request = api_client.build_request(:get, '/test')
78
+ expect(request.options[:timeout]).to eq(0)
79
+ end
80
+
81
+ it 'can be customized' do
82
+ config.timeout = 100
83
+ request = api_client.build_request(:get, '/test')
84
+ expect(request.options[:timeout]).to eq(100)
85
+ end
86
+ end
87
+
88
+ describe '#deserialize' do
89
+ it "handles Array<Integer>" do
90
+ api_client = MintyApi::ApiClient.new
91
+ headers = { 'Content-Type' => 'application/json' }
92
+ response = double('response', headers: headers, body: '[12, 34]')
93
+ data = api_client.deserialize(response, 'Array<Integer>')
94
+ expect(data).to be_instance_of(Array)
95
+ expect(data).to eq([12, 34])
96
+ end
97
+
98
+ it 'handles Array<Array<Integer>>' do
99
+ api_client = MintyApi::ApiClient.new
100
+ headers = { 'Content-Type' => 'application/json' }
101
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
102
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
103
+ expect(data).to be_instance_of(Array)
104
+ expect(data).to eq([[12, 34], [56]])
105
+ end
106
+
107
+ it 'handles Hash<String, String>' do
108
+ api_client = MintyApi::ApiClient.new
109
+ headers = { 'Content-Type' => 'application/json' }
110
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
111
+ data = api_client.deserialize(response, 'Hash<String, String>')
112
+ expect(data).to be_instance_of(Hash)
113
+ expect(data).to eq(:message => 'Hello')
114
+ end
115
+ end
116
+
117
+ describe "#object_to_hash" do
118
+ it 'ignores nils and includes empty arrays' do
119
+ # uncomment below to test object_to_hash for model
120
+ # api_client = MintyApi::ApiClient.new
121
+ # _model = MintyApi::ModelName.new
122
+ # update the model attribute below
123
+ # _model.id = 1
124
+ # update the expected value (hash) below
125
+ # expected = {id: 1, name: '', tags: []}
126
+ # expect(api_client.object_to_hash(_model)).to eq(expected)
127
+ end
128
+ end
129
+
130
+ describe '#build_collection_param' do
131
+ let(:param) { ['aa', 'bb', 'cc'] }
132
+ let(:api_client) { MintyApi::ApiClient.new }
133
+
134
+ it 'works for csv' do
135
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
136
+ end
137
+
138
+ it 'works for ssv' do
139
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
140
+ end
141
+
142
+ it 'works for tsv' do
143
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
144
+ end
145
+
146
+ it 'works for pipes' do
147
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
148
+ end
149
+
150
+ it 'works for multi' do
151
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
152
+ end
153
+
154
+ it 'fails for invalid collection format' do
155
+ expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
156
+ end
157
+ end
158
+
159
+ describe '#json_mime?' do
160
+ let(:api_client) { MintyApi::ApiClient.new }
161
+
162
+ it 'works' do
163
+ expect(api_client.json_mime?(nil)).to eq false
164
+ expect(api_client.json_mime?('')).to eq false
165
+
166
+ expect(api_client.json_mime?('application/json')).to eq true
167
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
168
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
169
+
170
+ expect(api_client.json_mime?('application/xml')).to eq false
171
+ expect(api_client.json_mime?('text/plain')).to eq false
172
+ expect(api_client.json_mime?('application/jsonp')).to eq false
173
+ end
174
+ end
175
+
176
+ describe '#select_header_accept' do
177
+ let(:api_client) { MintyApi::ApiClient.new }
178
+
179
+ it 'works' do
180
+ expect(api_client.select_header_accept(nil)).to be_nil
181
+ expect(api_client.select_header_accept([])).to be_nil
182
+
183
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
184
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
185
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
186
+
187
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
188
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
189
+ end
190
+ end
191
+
192
+ describe '#select_header_content_type' do
193
+ let(:api_client) { MintyApi::ApiClient.new }
194
+
195
+ it 'works' do
196
+ expect(api_client.select_header_content_type(nil)).to be_nil
197
+ expect(api_client.select_header_content_type([])).to be_nil
198
+
199
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
200
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
201
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
202
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
203
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
204
+ end
205
+ end
206
+
207
+ describe '#sanitize_filename' do
208
+ let(:api_client) { MintyApi::ApiClient.new }
209
+
210
+ it 'works' do
211
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
212
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
213
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
214
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
215
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
216
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
217
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
218
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
219
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
220
+ end
221
+ end
222
+ end
@@ -0,0 +1,38 @@
1
+ =begin
2
+ #Minty API
3
+
4
+ #Minty API
5
+
6
+
7
+ =end
8
+
9
+ require 'spec_helper'
10
+
11
+ describe MintyApi::Configuration do
12
+ let(:config) { MintyApi::Configuration.default }
13
+
14
+ before(:each) do
15
+ # uncomment below to setup host and base_path
16
+ # require 'URI'
17
+ # uri = URI.parse("http://localhost")
18
+ # MintyApi.configure do |c|
19
+ # c.host = uri.host
20
+ # c.base_path = uri.path
21
+ # end
22
+ end
23
+
24
+ describe '#base_url' do
25
+ it 'should have the default value' do
26
+ # uncomment below to test default value of the base path
27
+ # expect(config.base_url).to eq("http://localhost")
28
+ end
29
+
30
+ it 'should remove trailing slashes' do
31
+ [nil, '', '/', '//'].each do |base_path|
32
+ config.base_path = base_path
33
+ # uncomment below to test trailing slashes
34
+ # expect(config.base_url).to eq("http://localhost")
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,28 @@
1
+ =begin
2
+ #Minty API
3
+
4
+ #Minty API
5
+
6
+
7
+ =end
8
+
9
+ require 'spec_helper'
10
+ require 'json'
11
+ require 'date'
12
+
13
+ # Unit tests for MintyApi::RedirectUrl
14
+ describe MintyApi::RedirectUrl do
15
+ let(:instance) { MintyApi::RedirectUrl.new }
16
+
17
+ describe 'test an instance of RedirectUrl' do
18
+ it 'should create an instance of RedirectUrl' do
19
+ expect(instance).to be_instance_of(MintyApi::RedirectUrl)
20
+ end
21
+ end
22
+ describe 'test attribute "redirect_url"' do
23
+ it 'should work' do
24
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
25
+ end
26
+ end
27
+
28
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,75 +1,107 @@
1
- # frozen_string_literal: true
1
+ =begin
2
+ #Minty API
2
3
 
3
- require 'pry'
4
- require 'rack/test'
5
- require 'faker'
6
- require 'json'
7
- require 'minty'
8
-
9
- if RUBY_VERSION >= '2.7.2'
10
- # NOTE: https://bugs.ruby-lang.org/issues/17000
11
- Warning[:deprecated] = true
12
- end
13
-
14
- require 'simplecov'
15
- SimpleCov.start
16
-
17
- if ENV['CI'] == 'true'
18
- require 'simplecov-cobertura'
19
- SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
20
- end
21
-
22
- require 'dotenv'
23
- Dotenv.load
24
-
25
- require 'webmock/rspec'
26
- WebMock.allow_net_connect!
27
-
28
- require 'vcr'
29
- VCR.configure do |config|
30
- # Uncomment the line below to record new VCR cassettes.
31
- # When this is commented out, VCR will reject all outbound HTTP calls.
32
- config.allow_http_connections_when_no_cassette = true
33
- config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
34
- config.configure_rspec_metadata!
35
- config.hook_into :webmock
36
- config.filter_sensitive_data('CLIENT_SECRET') { ENV['CLIENT_SECRET'] }
37
- config.filter_sensitive_data('API_TOKEN') { ENV['MASTER_JWT'] }
4
+ #Minty API
38
5
 
39
- ENV['DOMAIN'] = 'minty-sdk-tests.minty.page'
40
- ENV['CLIENT_ID'] = '2cnWuug6zaFX1j0ge1P99jAUn0F4XSuI'
41
- end
42
6
 
43
- $LOAD_PATH.unshift File.expand_path(__dir__)
44
- $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
7
+ =end
45
8
 
46
- Dir['./lib/*.rb'].sort.each { |f| require f }
47
- Dir['./lib/api/**/*.rb'].sort.each { |f| require f }
48
- Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
49
- Dir['./spec/support/*.rb'].sort.each { |f| require f }
9
+ # load the gem
10
+ require 'minty'
50
11
 
51
- require 'rspec'
12
+ # The following was generated by the `rspec --init` command. Conventionally, all
13
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
14
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
15
+ # this file to always be loaded, without a need to explicitly require it in any
16
+ # files.
17
+ #
18
+ # Given that it is always loaded, you are encouraged to keep this file as
19
+ # light-weight as possible. Requiring heavyweight dependencies from this file
20
+ # will add to the boot time of your test suite on EVERY test run, even for an
21
+ # individual file that may not need all of that loaded. Instead, consider making
22
+ # a separate helper file that requires the additional dependencies and performs
23
+ # the additional setup, and require it from the spec files that actually need
24
+ # it.
25
+ #
26
+ # The `.rspec` file also contains a few flags that are not defaults but that
27
+ # users commonly want.
28
+ #
29
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
52
30
  RSpec.configure do |config|
53
- config.filter_run focus: true
54
- config.run_all_when_everything_filtered = true
55
- config.include Credentials
31
+ # rspec-expectations config goes here. You can use an alternate
32
+ # assertion/expectation library such as wrong or the stdlib/minitest
33
+ # assertions if you prefer.
34
+ config.expect_with :rspec do |expectations|
35
+ # This option will default to `true` in RSpec 4. It makes the `description`
36
+ # and `failure_message` of custom matchers include text for helper methods
37
+ # defined using `chain`, e.g.:
38
+ # be_bigger_than(2).and_smaller_than(4).description
39
+ # # => "be bigger than 2 and smaller than 4"
40
+ # ...rather than:
41
+ # # => "be bigger than 2"
42
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
43
+ end
56
44
 
57
- config.expect_with :rspec do |c|
58
- c.max_formatted_output_length = 1_000_000
45
+ # rspec-mocks config goes here. You can use an alternate test double
46
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
47
+ config.mock_with :rspec do |mocks|
48
+ # Prevents you from mocking or stubbing a method that does not exist on
49
+ # a real object. This is generally recommended, and will default to
50
+ # `true` in RSpec 4.
51
+ mocks.verify_partial_doubles = true
59
52
  end
60
- end
61
53
 
62
- def wait(time, increment = 5, elapsed_time = 0, &block)
63
- yield
64
- rescue RSpec::Expectations::ExpectationNotMetError => e
65
- raise e if elapsed_time >= time
54
+ # The settings below are suggested to provide a good initial experience
55
+ # with RSpec, but feel free to customize to your heart's content.
56
+ =begin
57
+ # These two settings work together to allow you to limit a spec run
58
+ # to individual examples or groups you care about by tagging them with
59
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
60
+ # get run.
61
+ config.filter_run :focus
62
+ config.run_all_when_everything_filtered = true
66
63
 
67
- sleep increment
68
- wait(time, increment, elapsed_time + increment, &block)
69
- end
64
+ # Allows RSpec to persist some state between runs in order to support
65
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
66
+ # you configure your source control system to ignore this file.
67
+ config.example_status_persistence_file_path = "spec/examples.txt"
68
+
69
+ # Limits the available syntax to the non-monkey patched syntax that is
70
+ # recommended. For more details, see:
71
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
72
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
73
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
74
+ config.disable_monkey_patching!
75
+
76
+ # This setting enables warnings. It's recommended, but in some cases may
77
+ # be too noisy due to issues in dependencies.
78
+ config.warnings = true
79
+
80
+ # Many RSpec users commonly either run the entire suite or an individual
81
+ # file, and it's useful to allow more verbose output when running an
82
+ # individual spec file.
83
+ if config.files_to_run.one?
84
+ # Use the documentation formatter for detailed output,
85
+ # unless a formatter has already been configured
86
+ # (e.g. via a command-line flag).
87
+ config.default_formatter = 'doc'
88
+ end
70
89
 
71
- def entity_suffix
72
- 'rubytest-210908'
90
+ # Print the 10 slowest examples and example groups at the
91
+ # end of the spec run, to help surface which specs are running
92
+ # particularly slow.
93
+ config.profile_examples = 10
94
+
95
+ # Run specs in random order to surface order dependencies. If you find an
96
+ # order dependency and want to debug it, you can fix the order by providing
97
+ # the seed, which is printed after each run.
98
+ # --seed 1234
99
+ config.order = :random
100
+
101
+ # Seed global randomization in this process using the `--seed` CLI option.
102
+ # Setting this allows you to use `--seed` to deterministically reproduce
103
+ # test failures related to randomization by passing the same `--seed` value
104
+ # as the one that triggered the failure.
105
+ Kernel.srand config.seed
106
+ =end
73
107
  end
74
-
75
- puts "Entity suffix is #{entity_suffix}"