cloudmersive-virus-scan-api-client 1.3.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +10 -5
- data/cloudmersive-virus-scan-api-client.gemspec +3 -3
- data/docs/CloudStorageVirusFound.md +9 -0
- data/docs/CloudStorageVirusScanResult.md +12 -0
- data/docs/ScanApi.md +9 -5
- data/docs/ScanCloudStorageApi.md +197 -0
- data/docs/VirusScanAdvancedResult.md +2 -0
- data/lib/cloudmersive-virus-scan-api-client.rb +4 -1
- data/lib/cloudmersive-virus-scan-api-client/api/scan_api.rb +21 -18
- data/lib/cloudmersive-virus-scan-api-client/api/scan_cloud_storage_api.rb +244 -0
- data/lib/cloudmersive-virus-scan-api-client/api_client.rb +11 -9
- data/lib/cloudmersive-virus-scan-api-client/api_error.rb +1 -1
- data/lib/cloudmersive-virus-scan-api-client/configuration.rb +2 -2
- data/lib/cloudmersive-virus-scan-api-client/models/cloud_storage_virus_found.rb +196 -0
- data/lib/cloudmersive-virus-scan-api-client/models/cloud_storage_virus_scan_result.rb +228 -0
- data/lib/cloudmersive-virus-scan-api-client/models/virus_found.rb +7 -10
- data/lib/cloudmersive-virus-scan-api-client/models/virus_scan_advanced_result.rb +28 -11
- data/lib/cloudmersive-virus-scan-api-client/models/virus_scan_result.rb +7 -10
- data/lib/cloudmersive-virus-scan-api-client/models/website_scan_request.rb +7 -10
- data/lib/cloudmersive-virus-scan-api-client/models/website_scan_result.rb +10 -12
- data/lib/cloudmersive-virus-scan-api-client/version.rb +2 -2
- data/spec/api/scan_api_spec.rb +7 -5
- data/spec/api/scan_cloud_storage_api_spec.rb +79 -0
- data/spec/api_client_spec.rb +52 -35
- data/spec/configuration_spec.rb +9 -9
- data/spec/models/cloud_storage_virus_found_spec.rb +47 -0
- data/spec/models/cloud_storage_virus_scan_result_spec.rb +65 -0
- data/spec/models/virus_found_spec.rb +3 -4
- data/spec/models/virus_scan_advanced_result_spec.rb +20 -9
- data/spec/models/virus_scan_result_spec.rb +3 -4
- data/spec/models/website_scan_request_spec.rb +2 -3
- data/spec/models/website_scan_result_spec.rb +9 -10
- data/spec/spec_helper.rb +1 -1
- metadata +11 -2
@@ -6,7 +6,7 @@
|
|
6
6
|
OpenAPI spec version: v1
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.
|
9
|
+
Swagger Codegen version: 2.4.14
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -18,7 +18,6 @@ module CloudmersiveVirusScanApiClient
|
|
18
18
|
# URL of the website to scan; should begin with http:// or https://
|
19
19
|
attr_accessor :url
|
20
20
|
|
21
|
-
|
22
21
|
# Attribute mapping from ruby-style variable name to JSON key.
|
23
22
|
def self.attribute_map
|
24
23
|
{
|
@@ -39,25 +38,24 @@ module CloudmersiveVirusScanApiClient
|
|
39
38
|
return unless attributes.is_a?(Hash)
|
40
39
|
|
41
40
|
# convert string to symbol for hash key
|
42
|
-
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
41
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
43
42
|
|
44
43
|
if attributes.has_key?(:'Url')
|
45
44
|
self.url = attributes[:'Url']
|
46
45
|
end
|
47
|
-
|
48
46
|
end
|
49
47
|
|
50
48
|
# Show invalid properties with the reasons. Usually used together with valid?
|
51
49
|
# @return Array for valid properties with the reasons
|
52
50
|
def list_invalid_properties
|
53
51
|
invalid_properties = Array.new
|
54
|
-
|
52
|
+
invalid_properties
|
55
53
|
end
|
56
54
|
|
57
55
|
# Check to see if the all the properties in the model are valid
|
58
56
|
# @return true if the model is valid
|
59
57
|
def valid?
|
60
|
-
|
58
|
+
true
|
61
59
|
end
|
62
60
|
|
63
61
|
# Checks equality by comparing each attribute.
|
@@ -87,10 +85,10 @@ module CloudmersiveVirusScanApiClient
|
|
87
85
|
return nil unless attributes.is_a?(Hash)
|
88
86
|
self.class.swagger_types.each_pair do |key, type|
|
89
87
|
if type =~ /\AArray<(.*)>/i
|
90
|
-
# check to ensure the input is an array given that the
|
88
|
+
# check to ensure the input is an array given that the attribute
|
91
89
|
# is documented as an array but the input is not
|
92
90
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
93
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) }
|
91
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
94
92
|
end
|
95
93
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
96
94
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
@@ -172,7 +170,7 @@ module CloudmersiveVirusScanApiClient
|
|
172
170
|
# @return [Hash] Returns the value in the form of hash
|
173
171
|
def _to_hash(value)
|
174
172
|
if value.is_a?(Array)
|
175
|
-
value.compact.map{ |v| _to_hash(v) }
|
173
|
+
value.compact.map { |v| _to_hash(v) }
|
176
174
|
elsif value.is_a?(Hash)
|
177
175
|
{}.tap do |hash|
|
178
176
|
value.each { |k, v| hash[k] = _to_hash(v) }
|
@@ -185,5 +183,4 @@ module CloudmersiveVirusScanApiClient
|
|
185
183
|
end
|
186
184
|
|
187
185
|
end
|
188
|
-
|
189
186
|
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
OpenAPI spec version: v1
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.
|
9
|
+
Swagger Codegen version: 2.4.14
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -75,7 +75,7 @@ module CloudmersiveVirusScanApiClient
|
|
75
75
|
return unless attributes.is_a?(Hash)
|
76
76
|
|
77
77
|
# convert string to symbol for hash key
|
78
|
-
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
78
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
79
79
|
|
80
80
|
if attributes.has_key?(:'CleanResult')
|
81
81
|
self.clean_result = attributes[:'CleanResult']
|
@@ -94,30 +94,29 @@ module CloudmersiveVirusScanApiClient
|
|
94
94
|
if attributes.has_key?(:'WebsiteHttpResponseCode')
|
95
95
|
self.website_http_response_code = attributes[:'WebsiteHttpResponseCode']
|
96
96
|
end
|
97
|
-
|
98
97
|
end
|
99
98
|
|
100
99
|
# Show invalid properties with the reasons. Usually used together with valid?
|
101
100
|
# @return Array for valid properties with the reasons
|
102
101
|
def list_invalid_properties
|
103
102
|
invalid_properties = Array.new
|
104
|
-
|
103
|
+
invalid_properties
|
105
104
|
end
|
106
105
|
|
107
106
|
# Check to see if the all the properties in the model are valid
|
108
107
|
# @return true if the model is valid
|
109
108
|
def valid?
|
110
|
-
website_threat_type_validator = EnumAttributeValidator.new('String', [
|
109
|
+
website_threat_type_validator = EnumAttributeValidator.new('String', ['None', 'Malware', 'Phishing', 'ForcedDownload', 'UnableToConnect'])
|
111
110
|
return false unless website_threat_type_validator.valid?(@website_threat_type)
|
112
|
-
|
111
|
+
true
|
113
112
|
end
|
114
113
|
|
115
114
|
# Custom attribute writer method checking allowed values (enum).
|
116
115
|
# @param [Object] website_threat_type Object to be assigned
|
117
116
|
def website_threat_type=(website_threat_type)
|
118
|
-
validator = EnumAttributeValidator.new('String', [
|
117
|
+
validator = EnumAttributeValidator.new('String', ['None', 'Malware', 'Phishing', 'ForcedDownload', 'UnableToConnect'])
|
119
118
|
unless validator.valid?(website_threat_type)
|
120
|
-
fail ArgumentError,
|
119
|
+
fail ArgumentError, 'invalid value for "website_threat_type", must be one of #{validator.allowable_values}.'
|
121
120
|
end
|
122
121
|
@website_threat_type = website_threat_type
|
123
122
|
end
|
@@ -152,10 +151,10 @@ module CloudmersiveVirusScanApiClient
|
|
152
151
|
return nil unless attributes.is_a?(Hash)
|
153
152
|
self.class.swagger_types.each_pair do |key, type|
|
154
153
|
if type =~ /\AArray<(.*)>/i
|
155
|
-
# check to ensure the input is an array given that the
|
154
|
+
# check to ensure the input is an array given that the attribute
|
156
155
|
# is documented as an array but the input is not
|
157
156
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
158
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) }
|
157
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
159
158
|
end
|
160
159
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
161
160
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
@@ -237,7 +236,7 @@ module CloudmersiveVirusScanApiClient
|
|
237
236
|
# @return [Hash] Returns the value in the form of hash
|
238
237
|
def _to_hash(value)
|
239
238
|
if value.is_a?(Array)
|
240
|
-
value.compact.map{ |v| _to_hash(v) }
|
239
|
+
value.compact.map { |v| _to_hash(v) }
|
241
240
|
elsif value.is_a?(Hash)
|
242
241
|
{}.tap do |hash|
|
243
242
|
value.each { |k, v| hash[k] = _to_hash(v) }
|
@@ -250,5 +249,4 @@ module CloudmersiveVirusScanApiClient
|
|
250
249
|
end
|
251
250
|
|
252
251
|
end
|
253
|
-
|
254
252
|
end
|
@@ -6,10 +6,10 @@
|
|
6
6
|
OpenAPI spec version: v1
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.
|
9
|
+
Swagger Codegen version: 2.4.14
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
module CloudmersiveVirusScanApiClient
|
14
|
-
VERSION =
|
14
|
+
VERSION = '2.0.4'
|
15
15
|
end
|
data/spec/api/scan_api_spec.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
OpenAPI spec version: v1
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.
|
9
|
+
Swagger Codegen version: 2.4.14
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -39,7 +39,7 @@ describe 'ScanApi' do
|
|
39
39
|
# @param [Hash] opts the optional parameters
|
40
40
|
# @return [VirusScanResult]
|
41
41
|
describe 'scan_file test' do
|
42
|
-
it
|
42
|
+
it 'should work' do
|
43
43
|
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
44
44
|
end
|
45
45
|
end
|
@@ -51,11 +51,13 @@ describe 'ScanApi' do
|
|
51
51
|
# @param [Hash] opts the optional parameters
|
52
52
|
# @option opts [BOOLEAN] :allow_executables Set to false to block executable files (program code) from being allowed in the input file. Default is false (recommended).
|
53
53
|
# @option opts [BOOLEAN] :allow_invalid_files Set to false to block invalid files, such as a PDF file that is not really a valid PDF file, or a Word Document that is not a valid Word Document. Default is false (recommended).
|
54
|
-
# @option opts [BOOLEAN] :allow_scripts Set to false to block script files, such as a PHP files,
|
54
|
+
# @option opts [BOOLEAN] :allow_scripts Set to false to block script files, such as a PHP files, Python scripts, and other malicious content or security threats that can be embedded in the file. Set to true to allow these file types. Default is false (recommended).
|
55
|
+
# @option opts [BOOLEAN] :allow_password_protected_files Set to false to block password protected and encrypted files, such as encrypted zip and rar files, and other files that seek to circumvent scanning through passwords. Set to true to allow these file types. Default is false (recommended).
|
56
|
+
# @option opts [BOOLEAN] :allow_macros Set to false to block macros and other threats embedded in document files, such as Word, Excel and PowerPoint embedded Macros, and other files that contain embedded content threats. Set to true to allow these file types. Default is false (recommended).
|
55
57
|
# @option opts [String] :restrict_file_types Specify a restricted set of file formats to allow as clean as a comma-separated list of file formats, such as .pdf,.docx,.png would allow only PDF, PNG and Word document files. All files must pass content verification against this list of file formats, if they do not, then the result will be returned as CleanResult=false. Set restrictFileTypes parameter to null or empty string to disable; default is disabled.
|
56
58
|
# @return [VirusScanAdvancedResult]
|
57
59
|
describe 'scan_file_advanced test' do
|
58
|
-
it
|
60
|
+
it 'should work' do
|
59
61
|
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
60
62
|
end
|
61
63
|
end
|
@@ -67,7 +69,7 @@ describe 'ScanApi' do
|
|
67
69
|
# @param [Hash] opts the optional parameters
|
68
70
|
# @return [WebsiteScanResult]
|
69
71
|
describe 'scan_website test' do
|
70
|
-
it
|
72
|
+
it 'should work' do
|
71
73
|
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
72
74
|
end
|
73
75
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
=begin
|
2
|
+
#virusapi
|
3
|
+
|
4
|
+
#The Cloudmersive Virus Scan API lets you scan files and content for viruses and identify security issues with content.
|
5
|
+
|
6
|
+
OpenAPI spec version: v1
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.14
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# Unit tests for CloudmersiveVirusScanApiClient::ScanCloudStorageApi
|
17
|
+
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
18
|
+
# Please update as you see appropriate
|
19
|
+
describe 'ScanCloudStorageApi' do
|
20
|
+
before do
|
21
|
+
# run before each test
|
22
|
+
@instance = CloudmersiveVirusScanApiClient::ScanCloudStorageApi.new
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
# run after each test
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'test an instance of ScanCloudStorageApi' do
|
30
|
+
it 'should create an instance of ScanCloudStorageApi' do
|
31
|
+
expect(@instance).to be_instance_of(CloudmersiveVirusScanApiClient::ScanCloudStorageApi)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# unit tests for scan_cloud_storage_scan_aws_s3_file
|
36
|
+
# Scan an AWS S3 file for viruses
|
37
|
+
# Scan the contents of a single AWS S3 file and its content for viruses. Leverage continuously updated signatures for millions of threats, and advanced high-performance scanning capabilities. Over 17 million virus and malware signatures. Continuous cloud-based updates. Wide file format support including Office, PDF, HTML, Flash. Zip support including .Zip, .Rar, .DMG, .Tar, and other archive formats. Multi-threat scanning across viruses, malware, trojans, ransomware, and spyware. High-speed in-memory scanning delivers subsecond typical response time.
|
38
|
+
# @param access_key AWS S3 access key for the S3 bucket; you can get this from My Security Credentials in the AWS console
|
39
|
+
# @param secret_key AWS S3 secret key for the S3 bucket; you can get this from My Security Credentials in the AWS console
|
40
|
+
# @param bucket_region Name of the region of the S3 bucket, such as 'US-East-1'
|
41
|
+
# @param bucket_name Name of the S3 bucket
|
42
|
+
# @param key_name Key name (also called file name) of the file in S3 that you wish to scan for viruses
|
43
|
+
# @param [Hash] opts the optional parameters
|
44
|
+
# @return [CloudStorageVirusScanResult]
|
45
|
+
describe 'scan_cloud_storage_scan_aws_s3_file test' do
|
46
|
+
it 'should work' do
|
47
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# unit tests for scan_cloud_storage_scan_azure_blob
|
52
|
+
# Scan an Azure Blob for viruses
|
53
|
+
# Scan the contents of a single Azure Blob and its content for viruses. Leverage continuously updated signatures for millions of threats, and advanced high-performance scanning capabilities. Over 17 million virus and malware signatures. Continuous cloud-based updates. Wide file format support including Office, PDF, HTML, Flash. Zip support including .Zip, .Rar, .DMG, .Tar, and other archive formats. Multi-threat scanning across viruses, malware, trojans, ransomware, and spyware. High-speed in-memory scanning delivers subsecond typical response time.
|
54
|
+
# @param connection_string Connection string for the Azure Blob Storage Account; you can get this connection string from the Access Keys tab of the Storage Account blade in the Azure Portal.
|
55
|
+
# @param container_name Name of the Blob container within the Azure Blob Storage account
|
56
|
+
# @param blob_path Path to the blob within the container, such as 'hello.pdf' or '/folder/subfolder/world.pdf'
|
57
|
+
# @param [Hash] opts the optional parameters
|
58
|
+
# @return [CloudStorageVirusScanResult]
|
59
|
+
describe 'scan_cloud_storage_scan_azure_blob test' do
|
60
|
+
it 'should work' do
|
61
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# unit tests for scan_cloud_storage_scan_gcp_storage_file
|
66
|
+
# Scan an Google Cloud Platform (GCP) Storage file for viruses
|
67
|
+
# Scan the contents of a single Google Cloud Platform (GCP) Storage file and its content for viruses. Leverage continuously updated signatures for millions of threats, and advanced high-performance scanning capabilities. Over 17 million virus and malware signatures. Continuous cloud-based updates. Wide file format support including Office, PDF, HTML, Flash. Zip support including .Zip, .Rar, .DMG, .Tar, and other archive formats. Multi-threat scanning across viruses, malware, trojans, ransomware, and spyware. High-speed in-memory scanning delivers subsecond typical response time.
|
68
|
+
# @param bucket_name Name of the bucket in Google Cloud Storage
|
69
|
+
# @param object_name Name of the object or file in Google Cloud Storage
|
70
|
+
# @param json_credential_file Service Account credential for Google Cloud stored in a JSON file.
|
71
|
+
# @param [Hash] opts the optional parameters
|
72
|
+
# @return [CloudStorageVirusScanResult]
|
73
|
+
describe 'scan_cloud_storage_scan_gcp_storage_file test' do
|
74
|
+
it 'should work' do
|
75
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
data/spec/api_client_spec.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
OpenAPI spec version: v1
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.
|
9
|
+
Swagger Codegen version: 2.4.14
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -51,11 +51,11 @@ describe CloudmersiveVirusScanApiClient::ApiClient do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe
|
54
|
+
describe 'params_encoding in #build_request' do
|
55
55
|
let(:config) { CloudmersiveVirusScanApiClient::Configuration.new }
|
56
56
|
let(:api_client) { CloudmersiveVirusScanApiClient::ApiClient.new(config) }
|
57
57
|
|
58
|
-
it
|
58
|
+
it 'defaults to nil' do
|
59
59
|
expect(CloudmersiveVirusScanApiClient::Configuration.default.params_encoding).to eq(nil)
|
60
60
|
expect(config.params_encoding).to eq(nil)
|
61
61
|
|
@@ -63,18 +63,18 @@ describe CloudmersiveVirusScanApiClient::ApiClient do
|
|
63
63
|
expect(request.options[:params_encoding]).to eq(nil)
|
64
64
|
end
|
65
65
|
|
66
|
-
it
|
66
|
+
it 'can be customized' do
|
67
67
|
config.params_encoding = :multi
|
68
68
|
request = api_client.build_request(:get, '/test')
|
69
69
|
expect(request.options[:params_encoding]).to eq(:multi)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
describe
|
73
|
+
describe 'timeout in #build_request' do
|
74
74
|
let(:config) { CloudmersiveVirusScanApiClient::Configuration.new }
|
75
75
|
let(:api_client) { CloudmersiveVirusScanApiClient::ApiClient.new(config) }
|
76
76
|
|
77
|
-
it
|
77
|
+
it 'defaults to 0' do
|
78
78
|
expect(CloudmersiveVirusScanApiClient::Configuration.default.timeout).to eq(0)
|
79
79
|
expect(config.timeout).to eq(0)
|
80
80
|
|
@@ -82,88 +82,105 @@ describe CloudmersiveVirusScanApiClient::ApiClient do
|
|
82
82
|
expect(request.options[:timeout]).to eq(0)
|
83
83
|
end
|
84
84
|
|
85
|
-
it
|
85
|
+
it 'can be customized' do
|
86
86
|
config.timeout = 100
|
87
87
|
request = api_client.build_request(:get, '/test')
|
88
88
|
expect(request.options[:timeout]).to eq(100)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
describe
|
92
|
+
describe '#build_request' do
|
93
|
+
let(:config) { CloudmersiveVirusScanApiClient::Configuration.new }
|
94
|
+
let(:api_client) { CloudmersiveVirusScanApiClient::ApiClient.new(config) }
|
95
|
+
|
96
|
+
it 'does not send multipart to request' do
|
97
|
+
expect(Typhoeus::Request).to receive(:new).with(anything, hash_not_including(:multipart))
|
98
|
+
api_client.build_request(:get, '/test')
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'when the content type is multipart' do
|
102
|
+
it 'sends multipart to request' do
|
103
|
+
expect(Typhoeus::Request).to receive(:new).with(anything, hash_including(multipart: true))
|
104
|
+
api_client.build_request(:get, '/test', {header_params: { 'Content-Type' => 'multipart/form-data'}})
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe '#deserialize' do
|
93
110
|
it "handles Array<Integer>" do
|
94
111
|
api_client = CloudmersiveVirusScanApiClient::ApiClient.new
|
95
|
-
headers = {'Content-Type' => 'application/json'}
|
112
|
+
headers = { 'Content-Type' => 'application/json' }
|
96
113
|
response = double('response', headers: headers, body: '[12, 34]')
|
97
114
|
data = api_client.deserialize(response, 'Array<Integer>')
|
98
115
|
expect(data).to be_instance_of(Array)
|
99
116
|
expect(data).to eq([12, 34])
|
100
117
|
end
|
101
118
|
|
102
|
-
it
|
119
|
+
it 'handles Array<Array<Integer>>' do
|
103
120
|
api_client = CloudmersiveVirusScanApiClient::ApiClient.new
|
104
|
-
headers = {'Content-Type' => 'application/json'}
|
121
|
+
headers = { 'Content-Type' => 'application/json' }
|
105
122
|
response = double('response', headers: headers, body: '[[12, 34], [56]]')
|
106
123
|
data = api_client.deserialize(response, 'Array<Array<Integer>>')
|
107
124
|
expect(data).to be_instance_of(Array)
|
108
125
|
expect(data).to eq([[12, 34], [56]])
|
109
126
|
end
|
110
127
|
|
111
|
-
it
|
128
|
+
it 'handles Hash<String, String>' do
|
112
129
|
api_client = CloudmersiveVirusScanApiClient::ApiClient.new
|
113
|
-
headers = {'Content-Type' => 'application/json'}
|
130
|
+
headers = { 'Content-Type' => 'application/json' }
|
114
131
|
response = double('response', headers: headers, body: '{"message": "Hello"}')
|
115
132
|
data = api_client.deserialize(response, 'Hash<String, String>')
|
116
133
|
expect(data).to be_instance_of(Hash)
|
117
|
-
expect(data).to eq(
|
134
|
+
expect(data).to eq(:message => 'Hello')
|
118
135
|
end
|
119
136
|
end
|
120
137
|
|
121
138
|
describe "#object_to_hash" do
|
122
|
-
it
|
139
|
+
it 'ignores nils and includes empty arrays' do
|
123
140
|
# uncomment below to test object_to_hash for model
|
124
|
-
#api_client = CloudmersiveVirusScanApiClient::ApiClient.new
|
125
|
-
#_model = CloudmersiveVirusScanApiClient::ModelName.new
|
141
|
+
# api_client = CloudmersiveVirusScanApiClient::ApiClient.new
|
142
|
+
# _model = CloudmersiveVirusScanApiClient::ModelName.new
|
126
143
|
# update the model attribute below
|
127
|
-
#_model.id = 1
|
144
|
+
# _model.id = 1
|
128
145
|
# update the expected value (hash) below
|
129
|
-
#expected = {id: 1, name: '', tags: []}
|
130
|
-
#expect(api_client.object_to_hash(_model)).to eq(expected)
|
146
|
+
# expected = {id: 1, name: '', tags: []}
|
147
|
+
# expect(api_client.object_to_hash(_model)).to eq(expected)
|
131
148
|
end
|
132
149
|
end
|
133
150
|
|
134
|
-
describe
|
151
|
+
describe '#build_collection_param' do
|
135
152
|
let(:param) { ['aa', 'bb', 'cc'] }
|
136
153
|
let(:api_client) { CloudmersiveVirusScanApiClient::ApiClient.new }
|
137
154
|
|
138
|
-
it
|
155
|
+
it 'works for csv' do
|
139
156
|
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
|
140
157
|
end
|
141
158
|
|
142
|
-
it
|
159
|
+
it 'works for ssv' do
|
143
160
|
expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
|
144
161
|
end
|
145
162
|
|
146
|
-
it
|
163
|
+
it 'works for tsv' do
|
147
164
|
expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
|
148
165
|
end
|
149
166
|
|
150
|
-
it
|
167
|
+
it 'works for pipes' do
|
151
168
|
expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
|
152
169
|
end
|
153
170
|
|
154
|
-
it
|
171
|
+
it 'works for multi' do
|
155
172
|
expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
|
156
173
|
end
|
157
174
|
|
158
|
-
it
|
175
|
+
it 'fails for invalid collection format' do
|
159
176
|
expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
|
160
177
|
end
|
161
178
|
end
|
162
179
|
|
163
|
-
describe
|
180
|
+
describe '#json_mime?' do
|
164
181
|
let(:api_client) { CloudmersiveVirusScanApiClient::ApiClient.new }
|
165
182
|
|
166
|
-
it
|
183
|
+
it 'works' do
|
167
184
|
expect(api_client.json_mime?(nil)).to eq false
|
168
185
|
expect(api_client.json_mime?('')).to eq false
|
169
186
|
|
@@ -177,10 +194,10 @@ describe CloudmersiveVirusScanApiClient::ApiClient do
|
|
177
194
|
end
|
178
195
|
end
|
179
196
|
|
180
|
-
describe
|
197
|
+
describe '#select_header_accept' do
|
181
198
|
let(:api_client) { CloudmersiveVirusScanApiClient::ApiClient.new }
|
182
199
|
|
183
|
-
it
|
200
|
+
it 'works' do
|
184
201
|
expect(api_client.select_header_accept(nil)).to be_nil
|
185
202
|
expect(api_client.select_header_accept([])).to be_nil
|
186
203
|
|
@@ -193,10 +210,10 @@ describe CloudmersiveVirusScanApiClient::ApiClient do
|
|
193
210
|
end
|
194
211
|
end
|
195
212
|
|
196
|
-
describe
|
213
|
+
describe '#select_header_content_type' do
|
197
214
|
let(:api_client) { CloudmersiveVirusScanApiClient::ApiClient.new }
|
198
215
|
|
199
|
-
it
|
216
|
+
it 'works' do
|
200
217
|
expect(api_client.select_header_content_type(nil)).to eq('application/json')
|
201
218
|
expect(api_client.select_header_content_type([])).to eq('application/json')
|
202
219
|
|
@@ -208,10 +225,10 @@ describe CloudmersiveVirusScanApiClient::ApiClient do
|
|
208
225
|
end
|
209
226
|
end
|
210
227
|
|
211
|
-
describe
|
228
|
+
describe '#sanitize_filename' do
|
212
229
|
let(:api_client) { CloudmersiveVirusScanApiClient::ApiClient.new }
|
213
230
|
|
214
|
-
it
|
231
|
+
it 'works' do
|
215
232
|
expect(api_client.sanitize_filename('sun')).to eq('sun')
|
216
233
|
expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
|
217
234
|
expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
|