vsphere-automation-cis 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +20 -0
- data/lib/vsphere-automation-cis/version.rb +1 -1
- metadata +6 -286
- data/Gemfile +0 -13
- data/Gemfile.lock +0 -78
- data/README.md +0 -180
- data/Rakefile +0 -18
- data/docs/CisSessionCreateResult.md +0 -8
- data/docs/CisSessionInfo.md +0 -10
- data/docs/CisSessionResult.md +0 -8
- data/docs/CisTaggingCategoryAddToUsedBy.md +0 -8
- data/docs/CisTaggingCategoryCreate.md +0 -8
- data/docs/CisTaggingCategoryCreateResult.md +0 -8
- data/docs/CisTaggingCategoryCreateSpec.md +0 -12
- data/docs/CisTaggingCategoryListResult.md +0 -8
- data/docs/CisTaggingCategoryListUsedCategories.md +0 -8
- data/docs/CisTaggingCategoryListUsedCategoriesResult.md +0 -8
- data/docs/CisTaggingCategoryModel.md +0 -13
- data/docs/CisTaggingCategoryModelCardinality.md +0 -7
- data/docs/CisTaggingCategoryRemoveFromUsedBy.md +0 -8
- data/docs/CisTaggingCategoryResult.md +0 -8
- data/docs/CisTaggingCategoryUpdate.md +0 -8
- data/docs/CisTaggingCategoryUpdateSpec.md +0 -11
- data/docs/CisTaggingTagAddToUsedBy.md +0 -8
- data/docs/CisTaggingTagAssociationAttach.md +0 -8
- data/docs/CisTaggingTagAssociationAttachMultipleTagsToObject.md +0 -9
- data/docs/CisTaggingTagAssociationAttachMultipleTagsToObjectResult.md +0 -8
- data/docs/CisTaggingTagAssociationAttachTagToMultipleObjects.md +0 -8
- data/docs/CisTaggingTagAssociationAttachTagToMultipleObjectsResult.md +0 -8
- data/docs/CisTaggingTagAssociationBatchResult.md +0 -9
- data/docs/CisTaggingTagAssociationDetach.md +0 -8
- data/docs/CisTaggingTagAssociationDetachMultipleTagsFromObject.md +0 -9
- data/docs/CisTaggingTagAssociationDetachMultipleTagsFromObjectResult.md +0 -8
- data/docs/CisTaggingTagAssociationDetachTagFromMultipleObjects.md +0 -8
- data/docs/CisTaggingTagAssociationDetachTagFromMultipleObjectsResult.md +0 -8
- data/docs/CisTaggingTagAssociationListAttachableTags.md +0 -8
- data/docs/CisTaggingTagAssociationListAttachableTagsResult.md +0 -8
- data/docs/CisTaggingTagAssociationListAttachedObjectsOnTags.md +0 -8
- data/docs/CisTaggingTagAssociationListAttachedObjectsOnTagsResult.md +0 -8
- data/docs/CisTaggingTagAssociationListAttachedObjectsResult.md +0 -8
- data/docs/CisTaggingTagAssociationListAttachedTags.md +0 -8
- data/docs/CisTaggingTagAssociationListAttachedTagsOnObjects.md +0 -8
- data/docs/CisTaggingTagAssociationListAttachedTagsOnObjectsResult.md +0 -8
- data/docs/CisTaggingTagAssociationListAttachedTagsResult.md +0 -8
- data/docs/CisTaggingTagAssociationObjectToTags.md +0 -9
- data/docs/CisTaggingTagAssociationTagToObjects.md +0 -9
- data/docs/CisTaggingTagCreate.md +0 -8
- data/docs/CisTaggingTagCreateResult.md +0 -8
- data/docs/CisTaggingTagCreateSpec.md +0 -11
- data/docs/CisTaggingTagListResult.md +0 -8
- data/docs/CisTaggingTagListTagsForCategoryResult.md +0 -8
- data/docs/CisTaggingTagListUsedTags.md +0 -8
- data/docs/CisTaggingTagListUsedTagsResult.md +0 -8
- data/docs/CisTaggingTagModel.md +0 -12
- data/docs/CisTaggingTagRemoveFromUsedBy.md +0 -8
- data/docs/CisTaggingTagResult.md +0 -8
- data/docs/CisTaggingTagUpdate.md +0 -8
- data/docs/CisTaggingTagUpdateSpec.md +0 -9
- data/docs/CisTaskInfo.md +0 -19
- data/docs/CisTaskProgress.md +0 -10
- data/docs/CisTaskStatus.md +0 -7
- data/docs/CisTasksFilterSpec.md +0 -12
- data/docs/CisTasksGetSpec.md +0 -9
- data/docs/CisTasksListResult.md +0 -8
- data/docs/CisTasksListResultValue.md +0 -9
- data/docs/CisTasksResult.md +0 -8
- data/docs/FilterSpecTargets.md +0 -9
- data/docs/SessionApi.md +0 -151
- data/docs/TaggingCategoryApi.md +0 -464
- data/docs/TaggingTagApi.md +0 -515
- data/docs/TaggingTagAssociationApi.md +0 -575
- data/docs/TasksApi.md +0 -180
- data/docs/VapiStdDynamicID.md +0 -9
- data/docs/VapiStdErrorsAlreadyExists.md +0 -9
- data/docs/VapiStdErrorsAlreadyExistsError.md +0 -9
- data/docs/VapiStdErrorsError.md +0 -9
- data/docs/VapiStdErrorsErrorError.md +0 -9
- data/docs/VapiStdErrorsInvalidArgument.md +0 -9
- data/docs/VapiStdErrorsInvalidArgumentError.md +0 -9
- data/docs/VapiStdErrorsNotAllowedInCurrentState.md +0 -9
- data/docs/VapiStdErrorsNotAllowedInCurrentStateError.md +0 -9
- data/docs/VapiStdErrorsNotFound.md +0 -9
- data/docs/VapiStdErrorsNotFoundError.md +0 -9
- data/docs/VapiStdErrorsResourceInaccessible.md +0 -9
- data/docs/VapiStdErrorsResourceInaccessibleError.md +0 -9
- data/docs/VapiStdErrorsServiceUnavailable.md +0 -9
- data/docs/VapiStdErrorsServiceUnavailableError.md +0 -9
- data/docs/VapiStdErrorsUnauthenticated.md +0 -9
- data/docs/VapiStdErrorsUnauthenticatedError.md +0 -9
- data/docs/VapiStdErrorsUnauthorized.md +0 -9
- data/docs/VapiStdErrorsUnauthorizedError.md +0 -9
- data/docs/VapiStdErrorsUnsupported.md +0 -9
- data/docs/VapiStdErrorsUnsupportedError.md +0 -9
- data/docs/VapiStdLocalizableMessage.md +0 -10
- data/git_push.sh +0 -55
- data/lib/vsphere-automation-cis/api_client.rb +0 -260
- data/lib/vsphere-automation-cis/api_error.rb +0 -34
- data/lib/vsphere-automation-cis/configuration.rb +0 -212
- data/pkg/vsphere-automation-cis-0.4.1.gem +0 -0
- data/pkg/vsphere-automation-cis-0.4.2.gem +0 -0
- data/pkg/vsphere-automation-cis-0.4.3.gem +0 -0
- data/pkg/vsphere-automation-cis-0.4.4.gem +0 -0
- data/pkg/vsphere-automation-cis-0.4.5.gem +0 -0
- data/spec/api/session_api_spec.rb +0 -62
- data/spec/api/tagging_category_api_spec.rb +0 -132
- data/spec/api/tagging_tag_api_spec.rb +0 -143
- data/spec/api/tagging_tag_association_api_spec.rb +0 -156
- data/spec/api/tasks_api_spec.rb +0 -72
- data/spec/api_client_spec.rb +0 -248
- data/spec/configuration_spec.rb +0 -38
- data/spec/models/cis_session_create_result_spec.rb +0 -37
- data/spec/models/cis_session_info_spec.rb +0 -49
- data/spec/models/cis_session_result_spec.rb +0 -37
- data/spec/models/cis_tagging_category_add_to_used_by_spec.rb +0 -37
- data/spec/models/cis_tagging_category_create_result_spec.rb +0 -37
- data/spec/models/cis_tagging_category_create_spec.rb +0 -37
- data/spec/models/cis_tagging_category_create_spec_spec.rb +0 -61
- data/spec/models/cis_tagging_category_list_result_spec.rb +0 -37
- data/spec/models/cis_tagging_category_list_used_categories_result_spec.rb +0 -37
- data/spec/models/cis_tagging_category_list_used_categories_spec.rb +0 -37
- data/spec/models/cis_tagging_category_model_cardinality_spec.rb +0 -31
- data/spec/models/cis_tagging_category_model_spec.rb +0 -67
- data/spec/models/cis_tagging_category_remove_from_used_by_spec.rb +0 -37
- data/spec/models/cis_tagging_category_result_spec.rb +0 -37
- data/spec/models/cis_tagging_category_update_spec.rb +0 -37
- data/spec/models/cis_tagging_category_update_spec_spec.rb +0 -55
- data/spec/models/cis_tagging_tag_add_to_used_by_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_attach_multiple_tags_to_object_result_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_attach_multiple_tags_to_object_spec.rb +0 -43
- data/spec/models/cis_tagging_tag_association_attach_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_attach_tag_to_multiple_objects_result_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_attach_tag_to_multiple_objects_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_batch_result_spec.rb +0 -43
- data/spec/models/cis_tagging_tag_association_detach_multiple_tags_from_object_result_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_detach_multiple_tags_from_object_spec.rb +0 -43
- data/spec/models/cis_tagging_tag_association_detach_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_detach_tag_from_multiple_objects_result_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_detach_tag_from_multiple_objects_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_list_attachable_tags_result_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_list_attachable_tags_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_list_attached_objects_on_tags_result_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_list_attached_objects_on_tags_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_list_attached_objects_result_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_list_attached_tags_on_objects_result_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_list_attached_tags_on_objects_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_list_attached_tags_result_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_list_attached_tags_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_association_object_to_tags_spec.rb +0 -43
- data/spec/models/cis_tagging_tag_association_tag_to_objects_spec.rb +0 -43
- data/spec/models/cis_tagging_tag_create_result_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_create_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_create_spec_spec.rb +0 -55
- data/spec/models/cis_tagging_tag_list_result_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_list_tags_for_category_result_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_list_used_tags_result_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_list_used_tags_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_model_spec.rb +0 -61
- data/spec/models/cis_tagging_tag_remove_from_used_by_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_result_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_update_spec.rb +0 -37
- data/spec/models/cis_tagging_tag_update_spec_spec.rb +0 -43
- data/spec/models/cis_task_info_spec.rb +0 -103
- data/spec/models/cis_task_progress_spec.rb +0 -49
- data/spec/models/cis_task_status_spec.rb +0 -31
- data/spec/models/cis_tasks_filter_spec_spec.rb +0 -61
- data/spec/models/cis_tasks_get_spec_spec.rb +0 -43
- data/spec/models/cis_tasks_list_result_spec.rb +0 -37
- data/spec/models/cis_tasks_list_result_value_spec.rb +0 -43
- data/spec/models/cis_tasks_result_spec.rb +0 -37
- data/spec/models/filter_spec_targets_spec.rb +0 -43
- data/spec/models/vapi_std_dynamic_id_spec.rb +0 -43
- data/spec/models/vapi_std_errors_already_exists_error_spec.rb +0 -43
- data/spec/models/vapi_std_errors_already_exists_spec.rb +0 -43
- data/spec/models/vapi_std_errors_error_error_spec.rb +0 -43
- data/spec/models/vapi_std_errors_error_spec.rb +0 -43
- data/spec/models/vapi_std_errors_invalid_argument_error_spec.rb +0 -43
- data/spec/models/vapi_std_errors_invalid_argument_spec.rb +0 -43
- data/spec/models/vapi_std_errors_not_allowed_in_current_state_error_spec.rb +0 -43
- data/spec/models/vapi_std_errors_not_allowed_in_current_state_spec.rb +0 -43
- data/spec/models/vapi_std_errors_not_found_error_spec.rb +0 -43
- data/spec/models/vapi_std_errors_not_found_spec.rb +0 -43
- data/spec/models/vapi_std_errors_resource_inaccessible_error_spec.rb +0 -43
- data/spec/models/vapi_std_errors_resource_inaccessible_spec.rb +0 -43
- data/spec/models/vapi_std_errors_service_unavailable_error_spec.rb +0 -43
- data/spec/models/vapi_std_errors_service_unavailable_spec.rb +0 -43
- data/spec/models/vapi_std_errors_unauthenticated_error_spec.rb +0 -43
- data/spec/models/vapi_std_errors_unauthenticated_spec.rb +0 -43
- data/spec/models/vapi_std_errors_unauthorized_error_spec.rb +0 -43
- data/spec/models/vapi_std_errors_unauthorized_spec.rb +0 -43
- data/spec/models/vapi_std_errors_unsupported_error_spec.rb +0 -43
- data/spec/models/vapi_std_errors_unsupported_spec.rb +0 -43
- data/spec/models/vapi_std_localizable_message_spec.rb +0 -49
- data/spec/spec_helper.rb +0 -110
- data/vsphere-automation-cis.gemspec +0 -39
data/spec/api/tasks_api_spec.rb
DELETED
@@ -1,72 +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
|
-
# cis - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
7
|
-
|
8
|
-
|
9
|
-
require 'spec_helper'
|
10
|
-
require 'json'
|
11
|
-
|
12
|
-
# Unit tests for VSphereAutomation::CIS::TasksApi
|
13
|
-
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
14
|
-
# Please update as you see appropriate
|
15
|
-
describe 'TasksApi' do
|
16
|
-
before do
|
17
|
-
# run before each test
|
18
|
-
@instance = VSphereAutomation::CIS::TasksApi.new
|
19
|
-
end
|
20
|
-
|
21
|
-
after do
|
22
|
-
# run after each test
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'test an instance of TasksApi' do
|
26
|
-
it 'should create an instance of TasksApi' do
|
27
|
-
expect(@instance).to be_instance_of(VSphereAutomation::CIS::TasksApi)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# unit tests for cancel
|
32
|
-
# Cancel a running operation associated with the task. This is the best effort attempt. Operation may not be cancelled anymore once it reaches certain stage.
|
33
|
-
# @param task Task identifier. The parameter must be an identifier for the resource type: cis.task.
|
34
|
-
# @param [Hash] opts the optional parameters
|
35
|
-
# @return [nil]
|
36
|
-
describe 'cancel test' do
|
37
|
-
it 'should work' do
|
38
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# unit tests for get
|
43
|
-
# Returns information about a task.
|
44
|
-
# @param task Task identifier. The parameter must be an identifier for the resource type: cis.task.
|
45
|
-
# @param [Hash] opts the optional parameters
|
46
|
-
# @option opts [Boolean] :spec_return_all If true, all data, including operation-specific data, will be returned, otherwise only the data described in Info will be returned. If unset, only the data described in Info will be returned.
|
47
|
-
# @option opts [Boolean] :spec_exclude_result If true, the result will not be included in the task information, otherwise it will be included. If unset, the result of the operation will be included in the task information.
|
48
|
-
# @return [CisTasksResult]
|
49
|
-
describe 'get test' do
|
50
|
-
it 'should work' do
|
51
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# unit tests for list
|
56
|
-
# Returns information about at most 1000 visible (subject to permission checks) tasks matching the Tasks.FilterSpec. All tasks must be in the same provider.
|
57
|
-
# @param [Hash] opts the optional parameters
|
58
|
-
# @option opts [Array<String>] :filter_spec_tasks Identifiers of tasks that can match the filter. This field may be unset if Tasks.FilterSpec.services is specified. Currently all tasks must be from the same provider. If unset or empty, tasks with any identifier will match the filter. When clients pass a value of this structure as a parameter, the field must contain identifiers for the resource type: cis.task. When operations return a value of this structure as a result, the field will contain identifiers for the resource type: cis.task.
|
59
|
-
# @option opts [Boolean] :result_spec_return_all If true, all data, including operation-specific data, will be returned, otherwise only the data described in Info will be returned. If unset, only the data described in Info will be returned.
|
60
|
-
# @option opts [Boolean] :result_spec_exclude_result If true, the result will not be included in the task information, otherwise it will be included. If unset, the result of the operation will be included in the task information.
|
61
|
-
# @option opts [Array<String>] :filter_spec_services Identifiers of services. Tasks created by operations in these services match the filter (see CommonInfo.service). This field may be unset if Tasks.FilterSpec.tasks is specified. Currently all services must be from the same provider. If this field is unset or empty, tasks for all services will match the filter. When clients pass a value of this structure as a parameter, the field must contain identifiers for the resource type: vapi.service. When operations return a value of this structure as a result, the field will contain identifiers for the resource type: vapi.service.
|
62
|
-
# @option opts [Array<String>] :filter_spec_status Status that a task must have to match the filter (see CommonInfo.status). If unset or empty, tasks with any status match the filter.
|
63
|
-
# @option opts [Array<FilterSpecTargets>] :filter_spec_targets Identifiers of the targets the operation for the associated task created or was performed on (see CommonInfo.target). If unset or empty, tasks associated with operations on any target match the filter.
|
64
|
-
# @option opts [Array<String>] :filter_spec_users Users who must have initiated the operation for the associated task to match the filter (see CommonInfo.user). If unset or empty, tasks associated with operations initiated by any user match the filter.
|
65
|
-
# @return [CisTasksListResult]
|
66
|
-
describe 'list test' do
|
67
|
-
it 'should work' do
|
68
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
data/spec/api_client_spec.rb
DELETED
@@ -1,248 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe VSphereAutomation::ApiClient do
|
4
|
-
describe '.default' do
|
5
|
-
it 'returns the same instance every time' do
|
6
|
-
first_instance = VSphereAutomation::ApiClient.default
|
7
|
-
second_instance = VSphereAutomation::ApiClient.default
|
8
|
-
third_instance = VSphereAutomation::ApiClient.default
|
9
|
-
expect(first_instance).to be(second_instance)
|
10
|
-
expect(first_instance).to be(third_instance)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#build_collection_param' do
|
15
|
-
context 'when called with format :multi' do
|
16
|
-
it 'returns the collection' do
|
17
|
-
params = { foo: 'bar', baz: 'quux' }
|
18
|
-
expect(subject.build_collection_param(params, :multi)).to eq(params)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#call_api' do
|
24
|
-
let(:host) { 'example.com' }
|
25
|
-
let(:config) do
|
26
|
-
VSphereAutomation::Configuration.new.tap do |c|
|
27
|
-
c.scheme = 'https'
|
28
|
-
c.host = host
|
29
|
-
end
|
30
|
-
end
|
31
|
-
let(:url) { 'https://example.com/rest/test' }
|
32
|
-
subject { VSphereAutomation::ApiClient.new(config) }
|
33
|
-
|
34
|
-
it 'adds headers to request' do
|
35
|
-
headers = { 'foo' => 'bar' }
|
36
|
-
stub_request(:get, url).with(headers: headers)
|
37
|
-
|
38
|
-
subject.call_api(:GET, '/test', header_params: headers)
|
39
|
-
|
40
|
-
expect(a_request(:get, url).with(headers: headers)).to have_been_made
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'adds query parameters to request' do
|
44
|
-
query_params = { 'foo' => 'bar' }
|
45
|
-
stub_request(:get, url).with(query: query_params)
|
46
|
-
|
47
|
-
subject.call_api(:GET, '/test', query_params: query_params)
|
48
|
-
|
49
|
-
expect(a_request(:get, url).with(query: query_params)).to have_been_made
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'keeps query parameters from the path to request' do
|
53
|
-
# The specs have some paths that contain query parameters already. This
|
54
|
-
# test is to make sure they don't get overwritten.
|
55
|
-
key = '~foo'
|
56
|
-
value = 'bar'
|
57
|
-
query_params = { key => value }
|
58
|
-
stub_request(:post, url).with(query: query_params)
|
59
|
-
|
60
|
-
subject.call_api(:POST, "/test?#{key}=#{value}")
|
61
|
-
|
62
|
-
expect(a_request(:post, url).with(query: query_params)).to have_been_made
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'adds form parameters to the request body' do
|
66
|
-
form_params = { 'foo' => 'bar' }
|
67
|
-
body = form_params.to_a.map { |e| e.join('=') }.join('&')
|
68
|
-
stub_request(:get, url).with(body: body)
|
69
|
-
|
70
|
-
subject.call_api(:GET, '/test', form_params: form_params)
|
71
|
-
|
72
|
-
expect(a_request(:get, url).with(body: body)).to have_been_made
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'uses basic auth information from configuration' do
|
76
|
-
auth_name = 'basic_auth'
|
77
|
-
auth_header = { config.auth_settings[auth_name][:key] =>
|
78
|
-
config.auth_settings[auth_name][:value] }
|
79
|
-
stub_request(:get, url).with(headers: auth_header)
|
80
|
-
|
81
|
-
subject.call_api(:GET, '/test', auth_names: [auth_name])
|
82
|
-
|
83
|
-
expect(a_request(:get, url)
|
84
|
-
.with(headers: auth_header)).to have_been_made
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'use API key information from configuration' do
|
88
|
-
auth_name = 'api_key'
|
89
|
-
config.api_key[config.auth_settings[auth_name][:key]] = 'foo'
|
90
|
-
auth_header = { config.auth_settings[auth_name][:key] =>
|
91
|
-
config.auth_settings[auth_name][:value] }
|
92
|
-
stub_request(:get, url).with(headers: auth_header)
|
93
|
-
|
94
|
-
subject.call_api(:GET, '/test', auth_names: [auth_name])
|
95
|
-
|
96
|
-
expect(a_request(:get, url)
|
97
|
-
.with(headers: auth_header)).to have_been_made
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'updates api_key from responses with set-cookie header' do
|
101
|
-
key = config.auth_settings['api_key'][:key]
|
102
|
-
value = 'foo'
|
103
|
-
cookie = "#{key}=#{value};Path=/rest;Secure;HttpOnly"
|
104
|
-
set_cookie_header = { 'set-cookie' => cookie }
|
105
|
-
stub_request(:get, url + '1').to_return(headers: set_cookie_header)
|
106
|
-
stub_request(:get, url + '2')
|
107
|
-
|
108
|
-
subject.call_api(:GET, '/test1')
|
109
|
-
subject.call_api(:GET, '/test2', auth_names: ['api_key'])
|
110
|
-
|
111
|
-
expect(a_request(:get, url + '1')).to have_been_made
|
112
|
-
expect(a_request(:get, url + '2')).to have_been_made
|
113
|
-
expect(subject.config.api_key[key]).to eq(value)
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'updates api_key from responses with api_key header' do
|
117
|
-
key = config.auth_settings['api_key'][:key]
|
118
|
-
value = 'foo'
|
119
|
-
auth_header = { key => value }
|
120
|
-
|
121
|
-
stub_request(:get, url + '1').to_return(headers: auth_header)
|
122
|
-
stub_request(:get, url + '2').with(headers: auth_header)
|
123
|
-
|
124
|
-
subject.call_api(:GET, '/test1')
|
125
|
-
subject.call_api(:GET, '/test2', auth_names: ['api_key'])
|
126
|
-
|
127
|
-
expect(a_request(:get, url + '1')).to have_been_made
|
128
|
-
expect(a_request(:get, url + '2')
|
129
|
-
.with(headers: auth_header)).to have_been_made
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'adds the body to requests when available' do
|
133
|
-
body = { foo: 'bar' }.to_json
|
134
|
-
stub_request(:post, url).with(body: body)
|
135
|
-
|
136
|
-
subject.call_api(:POST, '/test', body: body)
|
137
|
-
|
138
|
-
expect(a_request(:post, url).with(body: body)).to have_been_made
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'sets the Content-Type on requests when available' do
|
142
|
-
content_type = { 'Content-Type' => 'application/json' }
|
143
|
-
body = { foo: 'bar' }.to_json
|
144
|
-
|
145
|
-
stub_request(:post, url).with(body: body, headers: content_type)
|
146
|
-
|
147
|
-
subject.call_api(:POST, '/test', body: body, header_params: content_type)
|
148
|
-
|
149
|
-
expect(a_request(:post, url)
|
150
|
-
.with(body: body, headers: content_type)).to have_been_made
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe '#object_to_http_body' do
|
155
|
-
context 'when given nil' do
|
156
|
-
it 'returns the object as is' do
|
157
|
-
expect(subject.object_to_http_body(nil)).to be_nil
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
context 'when given a string' do
|
162
|
-
it 'returns the object as is' do
|
163
|
-
expect(subject.object_to_http_body('asdf')).to eq('asdf')
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
context 'when given an object that responds to `to_hash`' do
|
168
|
-
it 'returns that object as JSON' do
|
169
|
-
obj = OpenStruct.new(foo: 'bar', baz: 'quux')
|
170
|
-
obj.to_hash = obj.to_h
|
171
|
-
json = obj.to_hash.to_json
|
172
|
-
|
173
|
-
expect(subject.object_to_http_body(obj)).to eq(json)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
context 'when given an array' do
|
178
|
-
it 'returns a JSON array of objects' do
|
179
|
-
obj = OpenStruct.new(foo: 'bar', baz: 'quux')
|
180
|
-
obj.to_hash = obj.to_h
|
181
|
-
json = obj.to_hash.to_json
|
182
|
-
|
183
|
-
expect(subject.object_to_http_body([obj])).to eq([json])
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
describe '#select_header_accept' do
|
189
|
-
context 'when given anything other than an array' do
|
190
|
-
it 'returns application/json as a default' do
|
191
|
-
expect(subject.select_header_accept(nil)).to eq('application/json')
|
192
|
-
expect(subject.select_header_accept('')).to eq('application/json')
|
193
|
-
expect(subject.select_header_accept(1)).to eq('application/json')
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
context 'when given a list of types' do
|
198
|
-
context 'that includes a JSON type' do
|
199
|
-
it 'returns the first type containing JSON' do
|
200
|
-
xml = 'application/xml'
|
201
|
-
json = 'application/json'
|
202
|
-
|
203
|
-
expect(subject.select_header_accept([xml, json])).to eq(json)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
context 'that does not include a JSON type' do
|
208
|
-
it 'returns the all of the types' do
|
209
|
-
xml = 'application/xml'
|
210
|
-
html = 'text/html'
|
211
|
-
result = [xml, html].join(', ')
|
212
|
-
|
213
|
-
expect(subject.select_header_accept([xml, html])).to eq(result)
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
describe '#select_header_content_type' do
|
220
|
-
context 'when given anything other than an array' do
|
221
|
-
it 'returns application/json as a default' do
|
222
|
-
expect(subject.select_header_content_type(nil)).to eq('application/json')
|
223
|
-
expect(subject.select_header_content_type('')).to eq('application/json')
|
224
|
-
expect(subject.select_header_content_type(1)).to eq('application/json')
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
context 'when given a list of types' do
|
229
|
-
context 'that includes a JSON type' do
|
230
|
-
it 'returns the first type containing JSON' do
|
231
|
-
xml = 'application/xml'
|
232
|
-
json = 'application/json'
|
233
|
-
|
234
|
-
expect(subject.select_header_content_type([xml, json])).to eq(json)
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
context 'that does not include a JSON type' do
|
239
|
-
it 'returns the first type' do
|
240
|
-
xml = 'application/xml'
|
241
|
-
html = 'text/html'
|
242
|
-
|
243
|
-
expect(subject.select_header_content_type([xml, html])).to eq(xml)
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|
248
|
-
end
|
data/spec/configuration_spec.rb
DELETED
@@ -1,38 +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
|
-
# cis - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
7
|
-
|
8
|
-
|
9
|
-
require 'spec_helper'
|
10
|
-
|
11
|
-
describe VSphereAutomation::Configuration do
|
12
|
-
let(:config) { VSphereAutomation::Configuration.default }
|
13
|
-
|
14
|
-
before(:each) do
|
15
|
-
# uncomment below to setup host and base_path
|
16
|
-
# require 'URI'
|
17
|
-
# uri = URI.parse("https://<vcenter>/rest")
|
18
|
-
# VSphereAutomation.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("https://<vcenter>/rest")
|
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("https://<vcenter>/rest")
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,37 +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
|
-
# cis - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
7
|
-
|
8
|
-
|
9
|
-
require 'spec_helper'
|
10
|
-
require 'json'
|
11
|
-
require 'date'
|
12
|
-
|
13
|
-
# Unit tests for VSphereAutomation::CIS::CisSessionCreateResult
|
14
|
-
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
15
|
-
# Please update as you see appropriate
|
16
|
-
describe 'CisSessionCreateResult' do
|
17
|
-
before do
|
18
|
-
# run before each test
|
19
|
-
@instance = VSphereAutomation::CIS::CisSessionCreateResult.new
|
20
|
-
end
|
21
|
-
|
22
|
-
after do
|
23
|
-
# run after each test
|
24
|
-
end
|
25
|
-
|
26
|
-
describe 'test an instance of CisSessionCreateResult' do
|
27
|
-
it 'should create an instance of CisSessionCreateResult' do
|
28
|
-
expect(@instance).to be_instance_of(VSphereAutomation::CIS::CisSessionCreateResult)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
describe 'test attribute "value"' do
|
32
|
-
it 'should work' do
|
33
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
@@ -1,49 +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
|
-
# cis - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
7
|
-
|
8
|
-
|
9
|
-
require 'spec_helper'
|
10
|
-
require 'json'
|
11
|
-
require 'date'
|
12
|
-
|
13
|
-
# Unit tests for VSphereAutomation::CIS::CisSessionInfo
|
14
|
-
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
15
|
-
# Please update as you see appropriate
|
16
|
-
describe 'CisSessionInfo' do
|
17
|
-
before do
|
18
|
-
# run before each test
|
19
|
-
@instance = VSphereAutomation::CIS::CisSessionInfo.new
|
20
|
-
end
|
21
|
-
|
22
|
-
after do
|
23
|
-
# run after each test
|
24
|
-
end
|
25
|
-
|
26
|
-
describe 'test an instance of CisSessionInfo' do
|
27
|
-
it 'should create an instance of CisSessionInfo' do
|
28
|
-
expect(@instance).to be_instance_of(VSphereAutomation::CIS::CisSessionInfo)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
describe 'test attribute "user"' do
|
32
|
-
it 'should work' do
|
33
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'test attribute "created_time"' do
|
38
|
-
it 'should work' do
|
39
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'test attribute "last_accessed_time"' do
|
44
|
-
it 'should work' do
|
45
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|