vsphere-automation-vcenter 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -17
- data/README.md +1 -1
- data/lib/vsphere-automation-vcenter/version.rb +1 -1
- data/pkg/vsphere-automation-vcenter-0.4.0.gem +0 -0
- data/spec/api/certificate_management_vcenter_tls_api_spec.rb +0 -1
- data/spec/api/deployment_api_spec.rb +0 -1
- data/spec/api/deployment_import_history_api_spec.rb +0 -1
- data/spec/api/deployment_install_api_spec.rb +0 -1
- data/spec/api/deployment_install_psc_replicated_api_spec.rb +0 -1
- data/spec/api/deployment_install_psc_standalone_api_spec.rb +0 -1
- data/spec/api/deployment_install_remote_psc_api_spec.rb +0 -1
- data/spec/api/deployment_question_api_spec.rb +0 -1
- data/spec/api/deployment_upgrade_api_spec.rb +0 -1
- data/spec/api/inventory_datastore_api_spec.rb +0 -1
- data/spec/api/inventory_network_api_spec.rb +0 -1
- data/spec/api/iso_image_api_spec.rb +0 -2
- data/spec/api/ovf_library_item_api_spec.rb +0 -1
- data/spec/api/storage_policies_api_spec.rb +0 -1
- data/spec/api/topology_pscs_api_spec.rb +0 -1
- data/spec/api/vcha_cluster_active_api_spec.rb +0 -1
- data/spec/api/vcha_cluster_api_spec.rb +0 -1
- data/spec/api/vcha_cluster_mode_api_spec.rb +0 -1
- data/spec/api/vcha_cluster_passive_api_spec.rb +0 -1
- data/spec/api/vcha_cluster_witness_api_spec.rb +0 -1
- data/spec/api/vcha_vc_credentials_api_spec.rb +0 -1
- data/spec/api/vm_guest_power_api_spec.rb +0 -1
- data/spec/api/vm_storage_policy_compliance_api_spec.rb +0 -1
- data/spec/api/vm_template_library_items_api_spec.rb +0 -1
- data/spec/spec_helper.rb +3 -0
- data/vsphere-automation-vcenter.gemspec +2 -3
- metadata +7 -15
- data/lib/vsphere-automation-vcenter/api_client.rb +0 -390
- data/lib/vsphere-automation-vcenter/api_error.rb +0 -34
- data/lib/vsphere-automation-vcenter/configuration.rb +0 -212
- data/pkg/vsphere-automation-vcenter-0.2.1.gem +0 -0
- data/pkg/vsphere-automation-vcenter-0.2.2.gem +0 -0
- data/spec/api_client_spec.rb +0 -222
- data/spec/configuration_spec.rb +0 -38
@@ -1,34 +0,0 @@
|
|
1
|
-
# Copyright (c) 2018-2019 VMware, Inc. All Rights Reserved.
|
2
|
-
# SPDX-License-Identifier: MIT
|
3
|
-
|
4
|
-
# DO NOT MODIFY. THIS CODE IS GENERATED. CHANGES WILL BE OVERWRITTEN.
|
5
|
-
|
6
|
-
# vcenter - VMware vCenter Server provides a centralized platform for managing your VMware vSphere environments
|
7
|
-
|
8
|
-
|
9
|
-
module VSphereAutomation
|
10
|
-
class ApiError < StandardError
|
11
|
-
attr_reader :code, :response_headers, :response_body
|
12
|
-
|
13
|
-
# Usage examples:
|
14
|
-
# ApiError.new
|
15
|
-
# ApiError.new("message")
|
16
|
-
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
|
17
|
-
# ApiError.new(:code => 404, :message => "Not Found")
|
18
|
-
def initialize(arg = nil)
|
19
|
-
if arg.is_a? Hash
|
20
|
-
if arg.key?(:message) || arg.key?('message')
|
21
|
-
super(arg[:message] || arg['message'])
|
22
|
-
else
|
23
|
-
super arg
|
24
|
-
end
|
25
|
-
|
26
|
-
arg.each do |k, v|
|
27
|
-
instance_variable_set "@#{k}", v
|
28
|
-
end
|
29
|
-
else
|
30
|
-
super arg
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,212 +0,0 @@
|
|
1
|
-
# Copyright (c) 2018-2019 VMware, Inc. All Rights Reserved.
|
2
|
-
# SPDX-License-Identifier: MIT
|
3
|
-
|
4
|
-
# DO NOT MODIFY. THIS CODE IS GENERATED. CHANGES WILL BE OVERWRITTEN.
|
5
|
-
|
6
|
-
# vcenter - VMware vCenter Server provides a centralized platform for managing your VMware vSphere environments
|
7
|
-
|
8
|
-
|
9
|
-
require 'uri'
|
10
|
-
|
11
|
-
module VSphereAutomation
|
12
|
-
class Configuration
|
13
|
-
# Defines url scheme
|
14
|
-
attr_accessor :scheme
|
15
|
-
|
16
|
-
# Defines url host
|
17
|
-
attr_accessor :host
|
18
|
-
|
19
|
-
# Defines url base path
|
20
|
-
attr_accessor :base_path
|
21
|
-
|
22
|
-
# Defines API keys used with API Key authentications.
|
23
|
-
#
|
24
|
-
# @return [Hash] key: parameter name, value: parameter value (API key)
|
25
|
-
#
|
26
|
-
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
|
27
|
-
# config.api_key['api_key'] = 'xxx'
|
28
|
-
attr_accessor :api_key
|
29
|
-
|
30
|
-
# Defines API key prefixes used with API Key authentications.
|
31
|
-
#
|
32
|
-
# @return [Hash] key: parameter name, value: API key prefix
|
33
|
-
#
|
34
|
-
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
|
35
|
-
# config.api_key_prefix['api_key'] = 'Token'
|
36
|
-
attr_accessor :api_key_prefix
|
37
|
-
|
38
|
-
# Defines the username used with HTTP basic authentication.
|
39
|
-
#
|
40
|
-
# @return [String]
|
41
|
-
attr_accessor :username
|
42
|
-
|
43
|
-
# Defines the password used with HTTP basic authentication.
|
44
|
-
#
|
45
|
-
# @return [String]
|
46
|
-
attr_accessor :password
|
47
|
-
|
48
|
-
# Defines the access token (Bearer) used with OAuth2.
|
49
|
-
attr_accessor :access_token
|
50
|
-
|
51
|
-
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
52
|
-
# details will be logged with `logger.debug` (see the `logger` attribute).
|
53
|
-
# Default to false.
|
54
|
-
#
|
55
|
-
# @return [true, false]
|
56
|
-
attr_accessor :debugging
|
57
|
-
|
58
|
-
# Defines the logger used for debugging.
|
59
|
-
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
60
|
-
#
|
61
|
-
# @return [#debug]
|
62
|
-
attr_accessor :logger
|
63
|
-
|
64
|
-
# Defines the temporary folder to store downloaded files
|
65
|
-
# (for API endpoints that have file response).
|
66
|
-
# Default to use `Tempfile`.
|
67
|
-
#
|
68
|
-
# @return [String]
|
69
|
-
attr_accessor :temp_folder_path
|
70
|
-
|
71
|
-
# The time limit for HTTP request in seconds.
|
72
|
-
# Default to 0 (never times out).
|
73
|
-
attr_accessor :timeout
|
74
|
-
|
75
|
-
# Set this to false to skip client side validation in the operation.
|
76
|
-
# Default to true.
|
77
|
-
# @return [true, false]
|
78
|
-
attr_accessor :client_side_validation
|
79
|
-
|
80
|
-
### TLS/SSL setting
|
81
|
-
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
82
|
-
# Default to true.
|
83
|
-
#
|
84
|
-
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
85
|
-
#
|
86
|
-
# @return [true, false]
|
87
|
-
attr_accessor :verify_ssl
|
88
|
-
|
89
|
-
### TLS/SSL setting
|
90
|
-
# Set this to false to skip verifying SSL host name
|
91
|
-
# Default to true.
|
92
|
-
#
|
93
|
-
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
94
|
-
#
|
95
|
-
# @return [true, false]
|
96
|
-
attr_accessor :verify_ssl_host
|
97
|
-
|
98
|
-
### TLS/SSL setting
|
99
|
-
# Set this to customize the certificate file to verify the peer.
|
100
|
-
#
|
101
|
-
# @return [String] the path to the certificate file
|
102
|
-
#
|
103
|
-
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
|
104
|
-
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
105
|
-
attr_accessor :ssl_ca_cert
|
106
|
-
|
107
|
-
### TLS/SSL setting
|
108
|
-
# Client certificate file (for client certificate)
|
109
|
-
attr_accessor :cert_file
|
110
|
-
|
111
|
-
### TLS/SSL setting
|
112
|
-
# Client private key file (for client certificate)
|
113
|
-
attr_accessor :key_file
|
114
|
-
|
115
|
-
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
|
116
|
-
# Default to nil.
|
117
|
-
#
|
118
|
-
# @see The params_encoding option of Ethon. Related source code:
|
119
|
-
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
120
|
-
attr_accessor :params_encoding
|
121
|
-
|
122
|
-
attr_accessor :inject_format
|
123
|
-
|
124
|
-
attr_accessor :force_ending_format
|
125
|
-
|
126
|
-
def initialize
|
127
|
-
@scheme = 'https'
|
128
|
-
@host = '<vcenter>'
|
129
|
-
@base_path = '/rest'
|
130
|
-
@api_key = {}
|
131
|
-
@api_key_prefix = {}
|
132
|
-
@timeout = 0
|
133
|
-
@client_side_validation = true
|
134
|
-
@verify_ssl = true
|
135
|
-
@verify_ssl_host = true
|
136
|
-
@params_encoding = :multi
|
137
|
-
@cert_file = nil
|
138
|
-
@key_file = nil
|
139
|
-
@debugging = false
|
140
|
-
@inject_format = false
|
141
|
-
@force_ending_format = false
|
142
|
-
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
143
|
-
|
144
|
-
yield(self) if block_given?
|
145
|
-
end
|
146
|
-
|
147
|
-
# The default Configuration object.
|
148
|
-
def self.default
|
149
|
-
@@default ||= Configuration.new
|
150
|
-
end
|
151
|
-
|
152
|
-
def configure
|
153
|
-
yield(self) if block_given?
|
154
|
-
end
|
155
|
-
|
156
|
-
def scheme=(scheme)
|
157
|
-
# remove :// from scheme
|
158
|
-
@scheme = scheme.sub(/:\/\//, '')
|
159
|
-
end
|
160
|
-
|
161
|
-
def host=(host)
|
162
|
-
# remove http(s):// and anything after a slash
|
163
|
-
@host = host.sub(/https?:\/\//, '').split('/').first
|
164
|
-
end
|
165
|
-
|
166
|
-
def base_path=(base_path)
|
167
|
-
# Add leading and trailing slashes to base_path
|
168
|
-
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
169
|
-
@base_path = '' if @base_path == '/'
|
170
|
-
end
|
171
|
-
|
172
|
-
def base_url
|
173
|
-
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
174
|
-
URI.encode(url)
|
175
|
-
end
|
176
|
-
|
177
|
-
# Gets API key (with prefix if set).
|
178
|
-
# @param [String] param_name the parameter name of API key auth
|
179
|
-
def api_key_with_prefix(param_name)
|
180
|
-
if @api_key_prefix[param_name]
|
181
|
-
"#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
|
182
|
-
else
|
183
|
-
@api_key[param_name]
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
# Gets Basic Auth token string
|
188
|
-
def basic_auth_token
|
189
|
-
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
190
|
-
end
|
191
|
-
|
192
|
-
# Returns Auth Settings hash for api client.
|
193
|
-
def auth_settings
|
194
|
-
{
|
195
|
-
'api_key' =>
|
196
|
-
{
|
197
|
-
type: 'api_key',
|
198
|
-
in: 'header',
|
199
|
-
key: 'vmware-api-session-id',
|
200
|
-
value: api_key_with_prefix('vmware-api-session-id')
|
201
|
-
},
|
202
|
-
'basic_auth' =>
|
203
|
-
{
|
204
|
-
type: 'basic',
|
205
|
-
in: 'header',
|
206
|
-
key: 'Authorization',
|
207
|
-
value: basic_auth_token
|
208
|
-
},
|
209
|
-
}
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|
Binary file
|
Binary file
|
data/spec/api_client_spec.rb
DELETED
@@ -1,222 +0,0 @@
|
|
1
|
-
# Copyright (c) 2018-2019 VMware, Inc. All Rights Reserved.
|
2
|
-
# SPDX-License-Identifier: MIT
|
3
|
-
|
4
|
-
# DO NOT MODIFY. THIS CODE IS GENERATED. CHANGES WILL BE OVERWRITTEN.
|
5
|
-
|
6
|
-
# vcenter - VMware vCenter Server provides a centralized platform for managing your VMware vSphere environments
|
7
|
-
|
8
|
-
|
9
|
-
require 'spec_helper'
|
10
|
-
|
11
|
-
describe VSphereAutomation::ApiClient do
|
12
|
-
context 'initialization' do
|
13
|
-
context 'URL stuff' do
|
14
|
-
context 'host' do
|
15
|
-
it 'removes http from host' do
|
16
|
-
VSphereAutomation.configure { |c| c.host = 'http://example.com' }
|
17
|
-
expect(VSphereAutomation::Configuration.default.host).to eq('example.com')
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'removes https from host' do
|
21
|
-
VSphereAutomation.configure { |c| c.host = 'https://wookiee.com' }
|
22
|
-
expect(VSphereAutomation::ApiClient.default.config.host).to eq('wookiee.com')
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'removes trailing path from host' do
|
26
|
-
VSphereAutomation.configure { |c| c.host = 'hobo.com/v4' }
|
27
|
-
expect(VSphereAutomation::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
|
-
VSphereAutomation.configure { |c| c.base_path = 'v4/dog' }
|
34
|
-
expect(VSphereAutomation::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
|
-
VSphereAutomation.configure { |c| c.base_path = '/v4/dog' }
|
39
|
-
expect(VSphereAutomation::Configuration.default.base_path).to eq('/v4/dog')
|
40
|
-
end
|
41
|
-
|
42
|
-
it "ends up as a blank string if nil" do
|
43
|
-
VSphereAutomation.configure { |c| c.base_path = nil }
|
44
|
-
expect(VSphereAutomation::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) { VSphereAutomation::Configuration.new }
|
52
|
-
let(:api_client) { VSphereAutomation::ApiClient.new(config) }
|
53
|
-
|
54
|
-
it 'defaults to nil' do
|
55
|
-
expect(VSphereAutomation::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) { VSphereAutomation::Configuration.new }
|
71
|
-
let(:api_client) { VSphereAutomation::ApiClient.new(config) }
|
72
|
-
|
73
|
-
it 'defaults to 0' do
|
74
|
-
expect(VSphereAutomation::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 = VSphereAutomation::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 = VSphereAutomation::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 = VSphereAutomation::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 = VSphereAutomation::ApiClient.new
|
121
|
-
# _model = VSphereAutomation::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) { VSphereAutomation::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(proc { 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) { VSphereAutomation::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) { VSphereAutomation::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) { VSphereAutomation::ApiClient.new }
|
194
|
-
|
195
|
-
it 'works' do
|
196
|
-
expect(api_client.select_header_content_type(nil)).to eq('application/json')
|
197
|
-
expect(api_client.select_header_content_type([])).to eq('application/json')
|
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) { VSphereAutomation::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
|