mailmock 1.1.1.pre.34026500447

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 (67) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +111 -0
  4. data/Rakefile +10 -0
  5. data/docs/EmailApi.md +202 -0
  6. data/docs/EmailCreate200Response.md +20 -0
  7. data/docs/EmailCreateRequest.md +20 -0
  8. data/docs/EmailList200ResponseInner.md +26 -0
  9. data/docs/EmailListDefaultResponse.md +22 -0
  10. data/docs/EmailListDefaultResponseIssuesInner.md +18 -0
  11. data/docs/EmailRead200Response.md +36 -0
  12. data/docs/EmailRead200ResponseHeadersInner.md +20 -0
  13. data/docs/EmailReadRequest.md +20 -0
  14. data/docs/SendApi.md +70 -0
  15. data/docs/SendAws200Response.md +24 -0
  16. data/docs/SendAwsRequest.md +24 -0
  17. data/docs/SendAwsRequestMail.md +30 -0
  18. data/docs/SendAwsRequestMailCommonHeaders.md +28 -0
  19. data/docs/SendAwsRequestReceipt.md +34 -0
  20. data/docs/SendAwsRequestReceiptAction.md +22 -0
  21. data/docs/SendAwsRequestReceiptSpamVerdict.md +18 -0
  22. data/git_push.sh +57 -0
  23. data/lib/mailmock/api/email_api.rb +222 -0
  24. data/lib/mailmock/api/send_api.rb +86 -0
  25. data/lib/mailmock/api_client.rb +397 -0
  26. data/lib/mailmock/api_error.rb +58 -0
  27. data/lib/mailmock/api_model_base.rb +88 -0
  28. data/lib/mailmock/configuration.rb +308 -0
  29. data/lib/mailmock/models/email_create200_response.rb +190 -0
  30. data/lib/mailmock/models/email_create_request.rb +190 -0
  31. data/lib/mailmock/models/email_list200_response_inner.rb +292 -0
  32. data/lib/mailmock/models/email_list_default_response.rb +201 -0
  33. data/lib/mailmock/models/email_list_default_response_issues_inner.rb +164 -0
  34. data/lib/mailmock/models/email_read200_response.rb +370 -0
  35. data/lib/mailmock/models/email_read200_response_headers_inner.rb +190 -0
  36. data/lib/mailmock/models/email_read_request.rb +175 -0
  37. data/lib/mailmock/models/send_aws200_response.rb +242 -0
  38. data/lib/mailmock/models/send_aws_request.rb +242 -0
  39. data/lib/mailmock/models/send_aws_request_mail.rb +324 -0
  40. data/lib/mailmock/models/send_aws_request_mail_common_headers.rb +298 -0
  41. data/lib/mailmock/models/send_aws_request_receipt.rb +374 -0
  42. data/lib/mailmock/models/send_aws_request_receipt_action.rb +216 -0
  43. data/lib/mailmock/models/send_aws_request_receipt_spam_verdict.rb +164 -0
  44. data/lib/mailmock/version.rb +15 -0
  45. data/lib/mailmock.rb +57 -0
  46. data/mailmock.gemspec +39 -0
  47. data/spec/api/email_api_spec.rb +70 -0
  48. data/spec/api/send_api_spec.rb +45 -0
  49. data/spec/api_client_spec.rb +228 -0
  50. data/spec/configuration_spec.rb +42 -0
  51. data/spec/models/email_create200_response_spec.rb +40 -0
  52. data/spec/models/email_create_request_spec.rb +40 -0
  53. data/spec/models/email_list200_response_inner_spec.rb +62 -0
  54. data/spec/models/email_list_default_response_issues_inner_spec.rb +34 -0
  55. data/spec/models/email_list_default_response_spec.rb +46 -0
  56. data/spec/models/email_read200_response_headers_inner_spec.rb +40 -0
  57. data/spec/models/email_read200_response_spec.rb +88 -0
  58. data/spec/models/email_read_request_spec.rb +40 -0
  59. data/spec/models/send_aws200_response_spec.rb +52 -0
  60. data/spec/models/send_aws_request_mail_common_headers_spec.rb +64 -0
  61. data/spec/models/send_aws_request_mail_spec.rb +70 -0
  62. data/spec/models/send_aws_request_receipt_action_spec.rb +46 -0
  63. data/spec/models/send_aws_request_receipt_spam_verdict_spec.rb +34 -0
  64. data/spec/models/send_aws_request_receipt_spec.rb +82 -0
  65. data/spec/models/send_aws_request_spec.rb +52 -0
  66. data/spec/spec_helper.rb +111 -0
  67. metadata +168 -0
@@ -0,0 +1,164 @@
1
+ =begin
2
+ #Mailmock API
3
+
4
+ #Mailmock API
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.24.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Mailmock
17
+ class SendAwsRequestReceiptSpamVerdict < ApiModelBase
18
+ attr_accessor :status
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'status' => :'status'
24
+ }
25
+ end
26
+
27
+ # Returns attribute mapping this model knows about
28
+ def self.acceptable_attribute_map
29
+ attribute_map
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ acceptable_attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'status' => :'String'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Mailmock::SendAwsRequestReceiptSpamVerdict` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ acceptable_attribute_map = self.class.acceptable_attribute_map
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!acceptable_attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Mailmock::SendAwsRequestReceiptSpamVerdict`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'status')
67
+ self.status = attributes[:'status']
68
+ else
69
+ self.status = nil
70
+ end
71
+ end
72
+
73
+ # Show invalid properties with the reasons. Usually used together with valid?
74
+ # @return Array for valid properties with the reasons
75
+ def list_invalid_properties
76
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
77
+ invalid_properties = Array.new
78
+ if @status.nil?
79
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
80
+ end
81
+
82
+ invalid_properties
83
+ end
84
+
85
+ # Check to see if the all the properties in the model are valid
86
+ # @return true if the model is valid
87
+ def valid?
88
+ warn '[DEPRECATED] the `valid?` method is obsolete'
89
+ return false if @status.nil?
90
+ true
91
+ end
92
+
93
+ # Custom attribute writer method with validation
94
+ # @param [Object] status Value to be assigned
95
+ def status=(status)
96
+ if status.nil?
97
+ fail ArgumentError, 'status cannot be nil'
98
+ end
99
+
100
+ @status = status
101
+ end
102
+
103
+ # Checks equality by comparing each attribute.
104
+ # @param [Object] Object to be compared
105
+ def ==(o)
106
+ return true if self.equal?(o)
107
+ self.class == o.class &&
108
+ status == o.status
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(o)
114
+ self == o
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Integer] Hash code
119
+ def hash
120
+ [status].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def self.build_from_hash(attributes)
127
+ return nil unless attributes.is_a?(Hash)
128
+ attributes = attributes.transform_keys(&:to_sym)
129
+ transformed_hash = {}
130
+ openapi_types.each_pair do |key, type|
131
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
132
+ transformed_hash["#{key}"] = nil
133
+ elsif type =~ /\AArray<(.*)>/i
134
+ # check to ensure the input is an array given that the attribute
135
+ # is documented as an array but the input is not
136
+ if attributes[attribute_map[key]].is_a?(Array)
137
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
138
+ end
139
+ elsif !attributes[attribute_map[key]].nil?
140
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
141
+ end
142
+ end
143
+ new(transformed_hash)
144
+ end
145
+
146
+ # Returns the object in the form of hash
147
+ # @return [Hash] Returns the object in the form of hash
148
+ def to_hash
149
+ hash = {}
150
+ self.class.attribute_map.each_pair do |attr, param|
151
+ value = self.send(attr)
152
+ if value.nil?
153
+ is_nullable = self.class.openapi_nullable.include?(attr)
154
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
155
+ end
156
+
157
+ hash[param] = _to_hash(value)
158
+ end
159
+ hash
160
+ end
161
+
162
+ end
163
+
164
+ end
@@ -0,0 +1,15 @@
1
+ =begin
2
+ #Mailmock API
3
+
4
+ #Mailmock API
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.24.0
10
+
11
+ =end
12
+
13
+ module Mailmock
14
+ VERSION = '1.1.1.pre.34026500447'
15
+ end
data/lib/mailmock.rb ADDED
@@ -0,0 +1,57 @@
1
+ =begin
2
+ #Mailmock API
3
+
4
+ #Mailmock API
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.24.0
10
+
11
+ =end
12
+
13
+ # Common files
14
+ require 'mailmock/api_client'
15
+ require 'mailmock/api_error'
16
+ require 'mailmock/api_model_base'
17
+ require 'mailmock/version'
18
+ require 'mailmock/configuration'
19
+
20
+ # Models
21
+ require 'mailmock/models/email_create200_response'
22
+ require 'mailmock/models/email_create_request'
23
+ require 'mailmock/models/email_list200_response_inner'
24
+ require 'mailmock/models/email_list_default_response'
25
+ require 'mailmock/models/email_list_default_response_issues_inner'
26
+ require 'mailmock/models/email_read200_response'
27
+ require 'mailmock/models/email_read200_response_headers_inner'
28
+ require 'mailmock/models/email_read_request'
29
+ require 'mailmock/models/send_aws200_response'
30
+ require 'mailmock/models/send_aws_request'
31
+ require 'mailmock/models/send_aws_request_mail'
32
+ require 'mailmock/models/send_aws_request_mail_common_headers'
33
+ require 'mailmock/models/send_aws_request_receipt'
34
+ require 'mailmock/models/send_aws_request_receipt_action'
35
+ require 'mailmock/models/send_aws_request_receipt_spam_verdict'
36
+
37
+ # APIs
38
+ require 'mailmock/api/email_api'
39
+ require 'mailmock/api/send_api'
40
+
41
+ module Mailmock
42
+ class << self
43
+ # Customize default settings for the SDK using block.
44
+ # Mailmock.configure do |config|
45
+ # config.username = "xxx"
46
+ # config.password = "xxx"
47
+ # end
48
+ # If no block given, return the default Configuration object.
49
+ def configure
50
+ if block_given?
51
+ yield(Configuration.default)
52
+ else
53
+ Configuration.default
54
+ end
55
+ end
56
+ end
57
+ end
data/mailmock.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ =begin
4
+ #Mailmock API
5
+
6
+ #Mailmock API
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+
10
+ Generated by: https://openapi-generator.tech
11
+ Generator version: 7.24.0
12
+
13
+ =end
14
+
15
+ $:.push File.expand_path("../lib", __FILE__)
16
+ require "mailmock/version"
17
+
18
+ Gem::Specification.new do |s|
19
+ s.name = "mailmock"
20
+ s.version = Mailmock::VERSION
21
+ s.platform = Gem::Platform::RUBY
22
+ s.authors = ["Descope"]
23
+ s.email = [""]
24
+ s.homepage = "https://github.com/descope/mailmock"
25
+ s.summary = "Mailmock API Ruby Gem"
26
+ s.description = "Mailmock API"
27
+ s.license = "MIT"
28
+ s.required_ruby_version = ">= 3.2"
29
+ s.metadata = {}
30
+
31
+ s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
32
+
33
+ s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
34
+
35
+ s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
36
+ s.test_files = `find spec/*`.split("\n")
37
+ s.executables = []
38
+ s.require_paths = ["lib"]
39
+ end
@@ -0,0 +1,70 @@
1
+ =begin
2
+ #Mailmock API
3
+
4
+ #Mailmock API
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.0.0
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for Mailmock::EmailApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'EmailApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = Mailmock::EmailApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of EmailApi' do
30
+ it 'should create an instance of EmailApi' do
31
+ expect(@api_instance).to be_instance_of(Mailmock::EmailApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for email_create
36
+ # Create a new mailbox
37
+ # @param email_create_request
38
+ # @param [Hash] opts the optional parameters
39
+ # @return [EmailCreate200Response]
40
+ describe 'email_create test' do
41
+ it 'should work' do
42
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
43
+ end
44
+ end
45
+
46
+ # unit tests for email_list
47
+ # List mailbox(es)
48
+ # @param [Hash] opts the optional parameters
49
+ # @option opts [String] :user
50
+ # @option opts [String] :mailbox
51
+ # @option opts [String] :unread
52
+ # @return [Array<EmailList200ResponseInner>]
53
+ describe 'email_list test' do
54
+ it 'should work' do
55
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
56
+ end
57
+ end
58
+
59
+ # unit tests for email_read
60
+ # Fetch an email, optionally mark as read
61
+ # @param email_read_request
62
+ # @param [Hash] opts the optional parameters
63
+ # @return [EmailRead200Response]
64
+ describe 'email_read test' do
65
+ it 'should work' do
66
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
67
+ end
68
+ end
69
+
70
+ end
@@ -0,0 +1,45 @@
1
+ =begin
2
+ #Mailmock API
3
+
4
+ #Mailmock API
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.0.0
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for Mailmock::SendApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'SendApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = Mailmock::SendApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of SendApi' do
30
+ it 'should create an instance of SendApi' do
31
+ expect(@api_instance).to be_instance_of(Mailmock::SendApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for send_aws
36
+ # @param send_aws_request
37
+ # @param [Hash] opts the optional parameters
38
+ # @return [SendAws200Response]
39
+ describe 'send_aws test' do
40
+ it 'should work' do
41
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
42
+ end
43
+ end
44
+
45
+ end
@@ -0,0 +1,228 @@
1
+ =begin
2
+ #Mailmock API
3
+
4
+ #Mailmock API
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.0.0
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+
15
+ describe Mailmock::ApiClient do
16
+ context 'initialization' do
17
+ context 'URL stuff' do
18
+ context 'host' do
19
+ it 'removes http from host' do
20
+ Mailmock.configure { |c| c.host = 'http://example.com' }
21
+ expect(Mailmock::Configuration.default.host).to eq('example.com')
22
+ end
23
+
24
+ it 'removes https from host' do
25
+ Mailmock.configure { |c| c.host = 'https://wookiee.com' }
26
+ expect(Mailmock::ApiClient.default.config.host).to eq('wookiee.com')
27
+ end
28
+
29
+ it 'removes trailing path from host' do
30
+ Mailmock.configure { |c| c.host = 'hobo.com/v4' }
31
+ expect(Mailmock::Configuration.default.host).to eq('hobo.com')
32
+ end
33
+ end
34
+
35
+ context 'base_path' do
36
+ it "prepends a slash to base_path" do
37
+ Mailmock.configure { |c| c.base_path = 'v4/dog' }
38
+ expect(Mailmock::Configuration.default.base_path).to eq('/v4/dog')
39
+ end
40
+
41
+ it "doesn't prepend a slash if one is already there" do
42
+ Mailmock.configure { |c| c.base_path = '/v4/dog' }
43
+ expect(Mailmock::Configuration.default.base_path).to eq('/v4/dog')
44
+ end
45
+
46
+ it "ends up as a blank string if nil" do
47
+ Mailmock.configure { |c| c.base_path = nil }
48
+ expect(Mailmock::Configuration.default.base_path).to eq('')
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ describe 'params_encoding in #build_request' do
55
+ let(:config) { Mailmock::Configuration.new }
56
+ let(:api_client) { Mailmock::ApiClient.new(config) }
57
+
58
+ it 'defaults to nil' do
59
+ expect(Mailmock::Configuration.default.params_encoding).to eq(nil)
60
+ expect(config.params_encoding).to eq(nil)
61
+
62
+ request = api_client.build_request(:get, '/test')
63
+ expect(request.options[:params_encoding]).to eq(nil)
64
+ end
65
+
66
+ it 'can be customized' do
67
+ config.params_encoding = :multi
68
+ request = api_client.build_request(:get, '/test')
69
+ expect(request.options[:params_encoding]).to eq(:multi)
70
+ end
71
+ end
72
+
73
+ describe 'timeout in #build_request' do
74
+ let(:config) { Mailmock::Configuration.new }
75
+ let(:api_client) { Mailmock::ApiClient.new(config) }
76
+
77
+ it 'defaults to 0' do
78
+ expect(Mailmock::Configuration.default.timeout).to eq(0)
79
+ expect(config.timeout).to eq(0)
80
+
81
+ request = api_client.build_request(:get, '/test')
82
+ expect(request.options[:timeout]).to eq(0)
83
+ end
84
+
85
+ it 'can be customized' do
86
+ config.timeout = 100
87
+ request = api_client.build_request(:get, '/test')
88
+ expect(request.options[:timeout]).to eq(100)
89
+ end
90
+ end
91
+
92
+
93
+
94
+ describe '#deserialize' do
95
+ it "handles Array<Integer>" do
96
+ api_client = Mailmock::ApiClient.new
97
+ headers = { 'Content-Type' => 'application/json' }
98
+ response = double('response', headers: headers, body: '[12, 34]')
99
+ data = api_client.deserialize(response, 'Array<Integer>')
100
+ expect(data).to be_instance_of(Array)
101
+ expect(data).to eq([12, 34])
102
+ end
103
+
104
+ it 'handles Array<Array<Integer>>' do
105
+ api_client = Mailmock::ApiClient.new
106
+ headers = { 'Content-Type' => 'application/json' }
107
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
108
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
109
+ expect(data).to be_instance_of(Array)
110
+ expect(data).to eq([[12, 34], [56]])
111
+ end
112
+
113
+ it 'handles Hash<String, String>' do
114
+ api_client = Mailmock::ApiClient.new
115
+ headers = { 'Content-Type' => 'application/json' }
116
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
117
+ data = api_client.deserialize(response, 'Hash<String, String>')
118
+ expect(data).to be_instance_of(Hash)
119
+ expect(data).to eq(:message => 'Hello')
120
+ end
121
+ end
122
+
123
+ describe "#object_to_hash" do
124
+ it 'ignores nils and includes empty arrays' do
125
+ # uncomment below to test object_to_hash for model
126
+ # api_client = Mailmock::ApiClient.new
127
+ # _model = Mailmock::ModelName.new
128
+ # update the model attribute below
129
+ # _model.id = 1
130
+ # update the expected value (hash) below
131
+ # expected = {id: 1, name: '', tags: []}
132
+ # expect(api_client.object_to_hash(_model)).to eq(expected)
133
+ end
134
+ end
135
+
136
+ describe '#build_collection_param' do
137
+ let(:param) { ['aa', 'bb', 'cc'] }
138
+ let(:api_client) { Mailmock::ApiClient.new }
139
+
140
+ it 'works for csv' do
141
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
142
+ end
143
+
144
+ it 'works for ssv' do
145
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
146
+ end
147
+
148
+ it 'works for tsv' do
149
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
150
+ end
151
+
152
+ it 'works for pipes' do
153
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
154
+ end
155
+
156
+ it 'works for multi' do
157
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
158
+ end
159
+
160
+ it 'fails for invalid collection format' do
161
+ expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
162
+ end
163
+ end
164
+
165
+ describe '#json_mime?' do
166
+ let(:api_client) { Mailmock::ApiClient.new }
167
+
168
+ it 'works' do
169
+ expect(api_client.json_mime?(nil)).to eq false
170
+ expect(api_client.json_mime?('')).to eq false
171
+
172
+ expect(api_client.json_mime?('application/json')).to eq true
173
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
174
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
175
+
176
+ expect(api_client.json_mime?('application/xml')).to eq false
177
+ expect(api_client.json_mime?('text/plain')).to eq false
178
+ expect(api_client.json_mime?('application/jsonp')).to eq false
179
+ end
180
+ end
181
+
182
+ describe '#select_header_accept' do
183
+ let(:api_client) { Mailmock::ApiClient.new }
184
+
185
+ it 'works' do
186
+ expect(api_client.select_header_accept(nil)).to be_nil
187
+ expect(api_client.select_header_accept([])).to be_nil
188
+
189
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
190
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
191
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
192
+
193
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
194
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
195
+ end
196
+ end
197
+
198
+ describe '#select_header_content_type' do
199
+ let(:api_client) { Mailmock::ApiClient.new }
200
+
201
+ it 'works' do
202
+ expect(api_client.select_header_content_type(nil)).to be_nil
203
+ expect(api_client.select_header_content_type([])).to be_nil
204
+
205
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
206
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
207
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
208
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
209
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
210
+ end
211
+ end
212
+
213
+ describe '#sanitize_filename' do
214
+ let(:api_client) { Mailmock::ApiClient.new }
215
+
216
+ it 'works' do
217
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
218
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
219
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
220
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
221
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
222
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
223
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
224
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
225
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
226
+ end
227
+ end
228
+ end
@@ -0,0 +1,42 @@
1
+ =begin
2
+ #Mailmock API
3
+
4
+ #Mailmock API
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.0.0
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+
15
+ describe Mailmock::Configuration do
16
+ let(:config) { Mailmock::Configuration.default }
17
+
18
+ before(:each) do
19
+ # uncomment below to setup host and base_path
20
+ # require 'URI'
21
+ # uri = URI.parse("/api/trpc")
22
+ # Mailmock.configure do |c|
23
+ # c.host = uri.host
24
+ # c.base_path = uri.path
25
+ # end
26
+ end
27
+
28
+ describe '#base_url' do
29
+ it 'should have the default value' do
30
+ # uncomment below to test default value of the base path
31
+ # expect(config.base_url).to eq("/api/trpc")
32
+ end
33
+
34
+ it 'should remove trailing slashes' do
35
+ [nil, '', '/', '//'].each do |base_path|
36
+ config.base_path = base_path
37
+ # uncomment below to test trailing slashes
38
+ # expect(config.base_url).to eq("/api/trpc")
39
+ end
40
+ end
41
+ end
42
+ end