From f79513c03f8f512739010056053abe2c278f95af Mon Sep 17 00:00:00 2001 From: Tim Wade Date: Wed, 13 Sep 2017 09:35:08 -0400 Subject: [PATCH] Run rubocop --only Rails/HttpPositionalArguments --auto-correct --- spec/requests/actions_spec.rb | 22 +- spec/requests/alert_definitions_spec.rb | 51 +-- spec/requests/alerts_spec.rb | 16 +- spec/requests/authentication_spec.rb | 25 +- spec/requests/authentications_spec.rb | 46 +-- spec/requests/automate_domains_spec.rb | 10 +- spec/requests/automate_spec.rb | 10 +- spec/requests/automation_requests_spec.rb | 34 +- spec/requests/blueprints_spec.rb | 58 ++-- spec/requests/categories_spec.rb | 26 +- spec/requests/chargebacks_spec.rb | 61 ++-- spec/requests/cloud_networks_spec.rb | 6 +- spec/requests/cloud_volumes_spec.rb | 6 +- spec/requests/collections_spec.rb | 10 +- spec/requests/conditions_spec.rb | 34 +- .../configuration_script_payloads_spec.rb | 10 +- .../configuration_script_sources_spec.rb | 46 +-- spec/requests/container_deployments_spec.rb | 2 +- spec/requests/custom_actions_spec.rb | 16 +- spec/requests/custom_attributes_spec.rb | 2 +- spec/requests/events_spec.rb | 6 +- spec/requests/floating_ips_spec.rb | 2 +- .../generic_object_definitions_spec.rb | 22 +- spec/requests/groups_spec.rb | 52 +-- spec/requests/hosts_spec.rb | 12 +- spec/requests/instances_spec.rb | 88 +++--- spec/requests/logging_spec.rb | 2 +- spec/requests/metric_rollups_spec.rb | 65 ++-- spec/requests/network_routers_spec.rb | 2 +- spec/requests/notifications_spec.rb | 20 +- spec/requests/orchestration_template_spec.rb | 28 +- spec/requests/physical_servers_spec.rb | 40 +-- spec/requests/picture_spec.rb | 22 +- spec/requests/policies_assignment_spec.rb | 18 +- spec/requests/policies_spec.rb | 28 +- spec/requests/policy_actions_spec.rb | 6 +- spec/requests/providers_spec.rb | 134 ++++---- spec/requests/provision_requests_spec.rb | 38 +-- spec/requests/queries_spec.rb | 8 +- spec/requests/querying_spec.rb | 222 ++++++++----- spec/requests/reports_spec.rb | 32 +- spec/requests/requests_spec.rb | 88 +++--- spec/requests/roles_spec.rb | 54 ++-- spec/requests/service_catalogs_spec.rb | 85 ++--- spec/requests/service_dialogs_spec.rb | 78 +++-- spec/requests/service_orders_spec.rb | 165 ++++++---- spec/requests/service_requests_spec.rb | 114 ++++--- spec/requests/service_templates_spec.rb | 48 +-- spec/requests/services_spec.rb | 144 ++++----- spec/requests/set_ownership_spec.rb | 72 ++--- spec/requests/snapshots_spec.rb | 68 ++-- spec/requests/tag_collections_spec.rb | 176 ++++++----- spec/requests/tags_spec.rb | 36 +-- spec/requests/templates_spec.rb | 18 +- spec/requests/tenant_quotas_spec.rb | 24 +- spec/requests/tenants_spec.rb | 26 +- spec/requests/users_spec.rb | 64 ++-- spec/requests/vms_spec.rb | 297 +++++++++--------- 58 files changed, 1578 insertions(+), 1317 deletions(-) diff --git a/spec/requests/actions_spec.rb b/spec/requests/actions_spec.rb index b51d6f805d..fd44d708ef 100644 --- a/spec/requests/actions_spec.rb +++ b/spec/requests/actions_spec.rb @@ -23,7 +23,7 @@ it "creates new action" do api_basic_authorize collection_action_identifier(:actions, :create) - post(api_actions_url, sample_action) + post(api_actions_url, :params => sample_action) expect(response).to have_http_status(:ok) @@ -34,8 +34,8 @@ it "creates new actions" do api_basic_authorize collection_action_identifier(:actions, :create) - post(api_actions_url, gen_request(:create, [sample_action, - sample_action.merge(:name => "foo", :description => "bar")])) + post(api_actions_url, :params => gen_request(:create, [sample_action, + sample_action.merge(:name => "foo", :description => "bar")])) expect(response).to have_http_status(:ok) expect(response.parsed_body["results"].count).to eq(2) @@ -54,7 +54,7 @@ it "deletes action" do api_basic_authorize collection_action_identifier(:actions, :delete) - post(api_actions_url, gen_request(:delete, "name" => action.name, "href" => action_url)) + post(api_actions_url, :params => gen_request(:delete, "name" => action.name, "href" => action_url)) expect(response).to have_http_status(:ok) @@ -63,10 +63,10 @@ it "deletes actions" do api_basic_authorize collection_action_identifier(:actions, :delete) - post(api_actions_url, gen_request(:delete, [{"name" => actions.first.name, - "href" => api_action_url(nil, actions.first)}, - {"name" => actions.second.name, - "href" => api_action_url(nil, actions.second)}])) + post(api_actions_url, :params => gen_request(:delete, [{"name" => actions.first.name, + "href" => api_action_url(nil, actions.first)}, + {"name" => actions.second.name, + "href" => api_action_url(nil, actions.second)}])) expect(response).to have_http_status(:ok) @@ -84,7 +84,7 @@ it "edits new action" do api_basic_authorize collection_action_identifier(:actions, :edit) - post(action_url, gen_request(:edit, "description" => "change")) + post(action_url, :params => gen_request(:edit, "description" => "change")) expect(response).to have_http_status(:ok) @@ -93,8 +93,8 @@ it "edits new actions" do api_basic_authorize collection_action_identifier(:actions, :edit) - post(api_actions_url, gen_request(:edit, [{"id" => actions.first.id, "description" => "change"}, - {"id" => actions.second.id, "description" => "change2"}])) + post(api_actions_url, :params => gen_request(:edit, [{"id" => actions.first.id, "description" => "change"}, + {"id" => actions.second.id, "description" => "change2"}])) expect(response).to have_http_status(:ok) expect(response.parsed_body["results"].count).to eq(2) diff --git a/spec/requests/alert_definitions_spec.rb b/spec/requests/alert_definitions_spec.rb index 699f7048f7..65dc618dac 100644 --- a/spec/requests/alert_definitions_spec.rb +++ b/spec/requests/alert_definitions_spec.rb @@ -63,7 +63,7 @@ "description" => "Test Alert Definition", "db" => "ContainerNode" } - post(api_alert_definitions_url, alert_definition) + post(api_alert_definitions_url, :params => alert_definition) expect(response).to have_http_status(:forbidden) end @@ -76,7 +76,7 @@ "enabled" => true } api_basic_authorize collection_action_identifier(:alert_definitions, :create) - post(api_alert_definitions_url, sample_alert_definition) + post(api_alert_definitions_url, :params => sample_alert_definition) expect(response).to have_http_status(:ok) alert_definition = MiqAlert.find(ApplicationRecord.uncompress_id(response.parsed_body["results"].first["id"])) expect(alert_definition).to be_truthy @@ -94,7 +94,7 @@ it "deletes an alert definition via POST" do api_basic_authorize action_identifier(:alert_definitions, :delete, :resource_actions, :post) alert_definition = FactoryGirl.create(:miq_alert) - post(api_alert_definition_url(nil, alert_definition), gen_request(:delete)) + post(api_alert_definition_url(nil, alert_definition), :params => gen_request(:delete)) expect(response).to have_http_status(:ok) expect_single_action_result(:success => true, :message => "alert_definitions id: #{alert_definition.id} deleting", @@ -112,8 +112,8 @@ it "deletes alert definitions" do api_basic_authorize collection_action_identifier(:alert_definitions, :delete) alert_definitions = FactoryGirl.create_list(:miq_alert, 2) - post(api_alert_definitions_url, gen_request(:delete, [{"id" => alert_definitions.first.id}, - {"id" => alert_definitions.second.id}])) + post(api_alert_definitions_url, :params => gen_request(:delete, [{"id" => alert_definitions.first.id}, + {"id" => alert_definitions.second.id}])) expect(response).to have_http_status(:ok) expect(response.parsed_body["results"].count).to eq(2) end @@ -128,8 +128,15 @@ post( api_alert_definition_url(nil, alert_definition), - :action => "edit", - :options => { :notifications => {:delay_next_evaluation => 60, :evm_event => {} } } + :params => { + :action => "edit", + :options => { + :notifications => { + :delay_next_evaluation => 60, + :evm_event => {} + } + } + } ) expected = { @@ -152,10 +159,10 @@ it "edits alert definitions" do api_basic_authorize collection_action_identifier(:alert_definitions, :edit) alert_definitions = FactoryGirl.create_list(:miq_alert, 2) - post(api_alert_definitions_url, gen_request(:edit, [{"id" => alert_definitions.first.id, - "description" => "Updated Test Alert 1"}, - {"id" => alert_definitions.second.id, - "description" => "Updated Test Alert 2"}])) + post(api_alert_definitions_url, :params => gen_request(:edit, [{"id" => alert_definitions.first.id, + "description" => "Updated Test Alert 1"}, + {"id" => alert_definitions.second.id, + "description" => "Updated Test Alert 2"}])) expect(response).to have_http_status(:ok) expect(response.parsed_body["results"].count).to eq(2) @@ -212,7 +219,7 @@ alert_definitions = FactoryGirl.create_list(:miq_alert, 2) alert_definition_profile = FactoryGirl.create(:miq_alert_set, :alerts => alert_definitions) - get(api_alert_definition_profile_alert_definitions_url(nil, alert_definition_profile), :expand => "resources") + get(api_alert_definition_profile_alert_definitions_url(nil, alert_definition_profile), :params => { :expand => "resources" }) expect(response).to have_http_status(:ok) expect_result_resources_to_include_hrefs( @@ -227,7 +234,7 @@ alert_definition = FactoryGirl.create(:miq_alert) alert_definition_profile = FactoryGirl.create(:miq_alert_set, :alerts => [alert_definition]) - get(api_alert_definition_profile_url(nil, alert_definition_profile), :expand => "alert_definitions") + get(api_alert_definition_profile_url(nil, alert_definition_profile), :params => { :expand => "alert_definitions" }) expect(response).to have_http_status(:ok) expect_single_resource_query( @@ -245,7 +252,7 @@ "mode" => "ContainerNode", } api_basic_authorize collection_action_identifier(:alert_definition_profiles, :create) - post(api_alert_definition_profiles_url, sample_alert_definition_profile) + post(api_alert_definition_profiles_url, :params => sample_alert_definition_profile) expect(response).to have_http_status(:ok) id = ApplicationRecord.uncompress_id(response.parsed_body["results"].first["id"]) @@ -260,7 +267,7 @@ it "deletes an alert definition profile via POST" do api_basic_authorize action_identifier(:alert_definition_profiles, :delete, :resource_actions, :post) alert_definition_profile = FactoryGirl.create(:miq_alert_set) - post(api_alert_definition_profile_url(nil, alert_definition_profile), gen_request(:delete)) + post(api_alert_definition_profile_url(nil, alert_definition_profile), :params => gen_request(:delete)) expect(response).to have_http_status(:ok) expect_single_action_result(:success => true, @@ -280,8 +287,8 @@ it "deletes alert definition profiles" do api_basic_authorize collection_action_identifier(:alert_definition_profiles, :delete) alert_definition_profiles = FactoryGirl.create_list(:miq_alert_set, 2) - post(api_alert_definition_profiles_url, gen_request(:delete, [{"id" => alert_definition_profiles.first.id}, - {"id" => alert_definition_profiles.second.id}])) + post(api_alert_definition_profiles_url, :params => gen_request(:delete, [{"id" => alert_definition_profiles.first.id}, + {"id" => alert_definition_profiles.second.id}])) expect(response).to have_http_status(:ok) expect(response.parsed_body["results"].count).to eq(2) end @@ -289,11 +296,11 @@ it "edits alert definition profiles" do api_basic_authorize action_identifier(:alert_definition_profiles, :edit, :resource_actions, :post) alert_definition_profiles = FactoryGirl.create_list(:miq_alert_set, 2) - post(api_alert_definition_profiles_url, gen_request(:edit, - [{"id" => alert_definition_profiles.first.id, - "description" => "Updated Test Alert Profile 1"}, - {"id" => alert_definition_profiles.second.id, - "description" => "Updated Test Alert Profile 2"}])) + post(api_alert_definition_profiles_url, :params => gen_request(:edit, + [{"id" => alert_definition_profiles.first.id, + "description" => "Updated Test Alert Profile 1"}, + {"id" => alert_definition_profiles.second.id, + "description" => "Updated Test Alert Profile 2"}])) expect(response).to have_http_status(:ok) expect(response.parsed_body["results"].count).to eq(2) expect(alert_definition_profiles.first.reload.description).to eq("Updated Test Alert Profile 1") diff --git a/spec/requests/alerts_spec.rb b/spec/requests/alerts_spec.rb index a9fb7dc13c..d9abd61de8 100644 --- a/spec/requests/alerts_spec.rb +++ b/spec/requests/alerts_spec.rb @@ -90,8 +90,10 @@ api_basic_authorize post( api_alert_alert_actions_url(nil, alert), - "action_type" => "comment", - "comment" => "comment text", + :params => { + "action_type" => "comment", + "comment" => "comment text" + } ) expect(response).to have_http_status(:forbidden) end @@ -102,7 +104,7 @@ "comment" => "comment text", } api_basic_authorize subcollection_action_identifier(:alerts, :alert_actions, :create, :post) - post(api_alert_alert_actions_url(nil, alert), attributes) + post(api_alert_alert_actions_url(nil, alert), :params => attributes) expect(response).to have_http_status(:ok) expected = { "results" => [ @@ -120,7 +122,7 @@ "user_id" => user.id # should be ignored } api_basic_authorize subcollection_action_identifier(:alerts, :alert_actions, :create, :post) - post(api_alert_alert_actions_url(nil, alert), attributes) + post(api_alert_alert_actions_url(nil, alert), :params => attributes) expect(response).to have_http_status(:ok) expected = { "results" => [ @@ -137,7 +139,7 @@ "assignee" => { "id" => assignee.compressed_id } } api_basic_authorize subcollection_action_identifier(:alerts, :alert_actions, :create, :post) - post(api_alert_alert_actions_url(nil, alert), attributes) + post(api_alert_alert_actions_url(nil, alert), :params => attributes) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include(expected_assignee) end @@ -148,7 +150,7 @@ "assignee" => { "href" => api_user_url(nil, assignee.compressed_id) } } api_basic_authorize subcollection_action_identifier(:alerts, :alert_actions, :create, :post) - post(api_alert_alert_actions_url(nil, alert), attributes) + post(api_alert_alert_actions_url(nil, alert), :params => attributes) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include(expected_assignee) end @@ -157,7 +159,7 @@ api_basic_authorize subcollection_action_identifier(:alerts, :alert_actions, :create, :post) post( api_alert_alert_actions_url(nil, alert), - "action_type" => "assign", + :params => { "action_type" => "assign"} ) expect(response).to have_http_status(:bad_request) expect(response.parsed_body).to include_error_with_message( diff --git a/spec/requests/authentication_spec.rb b/spec/requests/authentication_spec.rb index 4dd9f593c4..4e7be629ce 100644 --- a/spec/requests/authentication_spec.rb +++ b/spec/requests/authentication_spec.rb @@ -112,7 +112,7 @@ it "querying user's authorization" do api_basic_authorize - get api_entrypoint_url, :attributes => "authorization" + get api_entrypoint_url, :params => { :attributes => "authorization" } expect(response).to have_http_status(:ok) expected = {"authorization" => hash_including("product_features")} @@ -191,7 +191,7 @@ it "gets a token based identifier with an invalid requester_type" do api_basic_authorize - get api_auth_url, :requester_type => "bogus_type" + get api_auth_url, :params => { :requester_type => "bogus_type" } expect_bad_request(/invalid requester_type/i) end @@ -199,7 +199,7 @@ it "gets a token based identifier with a UI based token_ttl" do api_basic_authorize - get api_auth_url, :requester_type => "ui" + get api_auth_url, :params => { :requester_type => "ui" } expect(response).to have_http_status(:ok) expect_result_to_have_keys(%w(auth_token token_ttl expires_on)) @@ -221,7 +221,7 @@ it 'gets a UI based token_ttl when requesting token for web sockets' do api_basic_authorize - get api_auth_url, :requester_type => 'ws' + get api_auth_url, :params => { :requester_type => 'ws' } expect(response).to have_http_status(:ok) expect_result_to_have_keys(%w(auth_token token_ttl expires_on)) expect(response.parsed_body["token_ttl"]).to eq(::Settings.session.timeout.to_i_with_method) @@ -229,7 +229,7 @@ it 'cannot authorize user to api based on token that is dedicated for web sockets' do api_basic_authorize - get api_auth_url, :requester_type => 'ws' + get api_auth_url, :params => { :requester_type => 'ws' } ws_token = response.parsed_body["auth_token"] get api_entrypoint_url, :headers => {Api::HttpHeaders::AUTH_TOKEN => ws_token} @@ -249,8 +249,7 @@ def systoken(server_guid, userid, timestamp) end it "authentication using a bad token" do - get api_entrypoint_url, - :headers => {Api::HttpHeaders::MIQ_TOKEN => "badtoken"} + get api_entrypoint_url, :headers => {Api::HttpHeaders::MIQ_TOKEN => "badtoken"} expect(response).to have_http_status(:unauthorized) expect(response.parsed_body).to include( @@ -259,8 +258,10 @@ def systoken(server_guid, userid, timestamp) end it "authentication using a token with a bad server guid" do - get api_entrypoint_url, - :headers => {Api::HttpHeaders::MIQ_TOKEN => systoken("bad_server_guid", api_config(:user), Time.now.utc)} + get( + api_entrypoint_url, + :headers => {Api::HttpHeaders::MIQ_TOKEN => systoken("bad_server_guid", api_config(:user), Time.now.utc)} + ) expect(response).to have_http_status(:unauthorized) expect(response.parsed_body).to include( @@ -269,8 +270,10 @@ def systoken(server_guid, userid, timestamp) end it "authentication using a token with bad user" do - get api_entrypoint_url, - :headers => {Api::HttpHeaders::MIQ_TOKEN => systoken(MiqServer.first.guid, "bad_user_id", Time.now.utc)} + get( + api_entrypoint_url, + :headers => {Api::HttpHeaders::MIQ_TOKEN => systoken(MiqServer.first.guid, "bad_user_id", Time.now.utc)} + ) expect(response).to have_http_status(:unauthorized) expect(response.parsed_body).to include( diff --git a/spec/requests/authentications_spec.rb b/spec/requests/authentications_spec.rb index 6e0421ffbd..b63430341f 100644 --- a/spec/requests/authentications_spec.rb +++ b/spec/requests/authentications_spec.rb @@ -73,7 +73,7 @@ ) ] } - post(api_authentications_url, :action => 'delete', :resources => [{ 'id' => auth.id }]) + post(api_authentications_url, :params => { :action => 'delete', :resources => [{ 'id' => auth.id }] }) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) @@ -83,7 +83,7 @@ api_basic_authorize collection_action_identifier(:authentications, :delete, :post) auth = FactoryGirl.create(:authentication) - post(api_authentications_url, :action => 'delete', :resources => [{ 'id' => auth.id }]) + post(api_authentications_url, :params => { :action => 'delete', :resources => [{ 'id' => auth.id }] }) expected = { 'results' => [ @@ -114,7 +114,7 @@ ) ] } - post(api_authentications_url, :action => 'delete', :resources => [{ 'id' => auth.id }, { 'id' => auth_2.id }]) + post(api_authentications_url, :params => { :action => 'delete', :resources => [{ 'id' => auth.id }, { 'id' => auth_2.id }] }) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) @@ -124,14 +124,14 @@ auth = FactoryGirl.create(:authentication) api_basic_authorize - post(api_authentications_url, :action => 'delete', :resources => [{ 'id' => auth.id }]) + post(api_authentications_url, :params => { :action => 'delete', :resources => [{ 'id' => auth.id }] }) expect(response).to have_http_status(:forbidden) end it 'can update an authentication with an appropriate role' do api_basic_authorize collection_action_identifier(:authentications, :edit) - post(api_authentications_url, :action => 'edit', :resources => [params]) + post(api_authentications_url, :params => { :action => 'edit', :resources => [params] }) expected = { 'results' => [ @@ -150,7 +150,7 @@ params2 = params.dup.merge(:id => auth_2.id) api_basic_authorize collection_action_identifier(:authentications, :edit) - post(api_authentications_url, :action => 'edit', :resources => [params, params2]) + post(api_authentications_url, :params => { :action => 'edit', :resources => [params, params2] }) expected = { 'results' => [ @@ -173,7 +173,7 @@ it 'will forbid update to an authentication without appropriate role' do api_basic_authorize - post(api_authentications_url, :action => 'edit', :resources => [params]) + post(api_authentications_url, :params => { :action => 'edit', :resources => [params] }) expect(response).to have_http_status(:forbidden) end @@ -192,7 +192,7 @@ it 'requires a manager resource when creating an authentication' do api_basic_authorize collection_action_identifier(:authentications, :create, :post) - post(api_authentications_url, :action => 'create', :type => 'Authentication') + post(api_authentications_url, :params => { :action => 'create', :type => 'Authentication' }) expected = { 'results' => [ @@ -206,7 +206,7 @@ it 'requires that the type support create_in_provider_queue' do api_basic_authorize collection_action_identifier(:authentications, :create, :post) - post(api_authentications_url, :action => 'create', :type => 'Authentication', :manager_resource => { :href => api_provider_url(nil, manager) }) + post(api_authentications_url, :params => { :action => 'create', :type => 'Authentication', :manager_resource => { :href => api_provider_url(nil, manager) } }) expected = { 'results' => [ @@ -227,7 +227,7 @@ 'task_id' => a_kind_of(String) )] } - post(api_authentications_url, create_params) + post(api_authentications_url, :params => create_params) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include(expected) @@ -250,7 +250,7 @@ ) ] } - post(api_authentications_url, :resources => [create_params, create_params]) + post(api_authentications_url, :params => { :resources => [create_params, create_params] }) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include(expected) @@ -268,7 +268,7 @@ ) ] } - post(api_authentications_url, :resources => [create_params]) + post(api_authentications_url, :params => { :resources => [create_params] }) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include(expected) @@ -277,7 +277,7 @@ it 'will forbid creation of an authentication without appropriate role' do api_basic_authorize - post(api_authentications_url, :action => 'create') + post(api_authentications_url, :params => { :action => 'create' }) expect(response).to have_http_status(:forbidden) end @@ -285,7 +285,7 @@ it 'can refresh multiple authentications with an appropriate role' do api_basic_authorize collection_action_identifier(:authentications, :refresh, :post) - post(api_authentications_url, :action => :refresh, :resources => [{ :id => auth.id}, {:id => auth_2.id}]) + post(api_authentications_url, :params => { :action => :refresh, :resources => [{ :id => auth.id}, {:id => auth_2.id}] }) expected = { 'results' => [ @@ -321,7 +321,7 @@ it 'can update an authentication with an appropriate role' do api_basic_authorize collection_action_identifier(:authentications, :edit) - put(api_authentication_url(nil, auth), :resource => params) + put(api_authentication_url(nil, auth), :params => { :resource => params }) expected = { 'success' => true, @@ -345,7 +345,7 @@ it 'can update an authentication with an appropriate role' do api_basic_authorize collection_action_identifier(:authentications, :edit) - patch(api_authentication_url(nil, auth), [params]) + patch(api_authentication_url(nil, auth), :params => [params]) expected = { 'success' => true, @@ -368,7 +368,7 @@ it 'will delete an authentication' do api_basic_authorize action_identifier(:authentications, :delete, :resource_actions, :post) - post(api_authentication_url(nil, auth), :action => 'delete') + post(api_authentication_url(nil, auth), :params => { :action => 'delete' }) expected = { 'success' => true, @@ -382,7 +382,7 @@ it 'will not delete an authentication without an appropriate role' do api_basic_authorize - post(api_authentication_url(nil, auth), :action => 'delete') + post(api_authentication_url(nil, auth), :params => { :action => 'delete' }) expect(response).to have_http_status(:forbidden) end @@ -390,7 +390,7 @@ it 'can update an authentication with an appropriate role' do api_basic_authorize collection_action_identifier(:authentications, :edit) - post(api_authentication_url(nil, auth), :action => 'edit', :resource => params) + post(api_authentication_url(nil, auth), :params => { :action => 'edit', :resource => params }) expected = { 'success' => true, @@ -405,7 +405,7 @@ api_basic_authorize collection_action_identifier(:authentications, :edit) auth = FactoryGirl.create(:authentication) - post(api_authentication_url(nil, auth), :action => 'edit', :resource => params) + post(api_authentication_url(nil, auth), :params => { :action => 'edit', :resource => params }) expected = { 'success' => false, @@ -418,7 +418,7 @@ it 'will forbid update to an authentication without appropriate role' do api_basic_authorize - post(api_authentication_url(nil, auth), :action => 'edit', :resource => params) + post(api_authentication_url(nil, auth), :params => { :action => 'edit', :resource => params }) expect(response).to have_http_status(:forbidden) end @@ -426,7 +426,7 @@ it 'forbids refresh without an appropriate role' do api_basic_authorize - post(api_authentication_url(nil, auth), :action => :refresh) + post(api_authentication_url(nil, auth), :params => { :action => :refresh }) expect(response).to have_http_status(:forbidden) end @@ -434,7 +434,7 @@ it 'can refresh a authentications with an appropriate role' do api_basic_authorize action_identifier(:authentications, :refresh) - post(api_authentication_url(nil, auth), :action => :refresh) + post(api_authentication_url(nil, auth), :params => { :action => :refresh }) expected = { 'success' => true, diff --git a/spec/requests/automate_domains_spec.rb b/spec/requests/automate_domains_spec.rb index 4f08073b7e..cdcb70d23d 100644 --- a/spec/requests/automate_domains_spec.rb +++ b/spec/requests/automate_domains_spec.rb @@ -7,7 +7,7 @@ it 'forbids access for users without proper permissions' do api_basic_authorize - post(api_automate_domain_url(nil, git_domain), gen_request(:refresh_from_source)) + post(api_automate_domain_url(nil, git_domain), :params => gen_request(:refresh_from_source)) expect(response).to have_http_status(:forbidden) end @@ -16,7 +16,7 @@ api_basic_authorize action_identifier(:automate_domains, :refresh_from_source) expect(GitBasedDomainImportService).to receive(:available?).and_return(false) - post(api_automate_domain_url(nil, git_domain), gen_request(:refresh_from_source)) + post(api_automate_domain_url(nil, git_domain), :params => gen_request(:refresh_from_source)) expect_single_action_result(:success => false, :message => 'Git owner role is not enabled to be able to import git repositories') end @@ -30,7 +30,7 @@ it 'fails to refresh when domain did not originate from git' do api_basic_authorize action_identifier(:automate_domains, :refresh_from_source) - post(api_automate_domain_url(nil, non_git_domain), gen_request(:refresh_from_source)) + post(api_automate_domain_url(nil, non_git_domain), :params => gen_request(:refresh_from_source)) expect_single_action_result( :success => false, :message => a_string_matching(/Automate Domain .* did not originate from git repository/) @@ -41,7 +41,7 @@ api_basic_authorize action_identifier(:automate_domains, :refresh_from_source) expect_any_instance_of(GitBasedDomainImportService).to receive(:queue_refresh_and_import) - post(api_automate_domain_url(nil, git_domain), gen_request(:refresh_from_source)) + post(api_automate_domain_url(nil, git_domain), :params => gen_request(:refresh_from_source)) expect_single_action_result( :success => true, :message => a_string_matching(/Refreshing Automate Domain .* from git repository/), @@ -53,7 +53,7 @@ api_basic_authorize action_identifier(:automate_domains, :refresh_from_source) expect_any_instance_of(GitBasedDomainImportService).to receive(:queue_refresh_and_import) - post(api_automate_domain_url(nil, git_domain.name), gen_request(:refresh_from_source)) + post(api_automate_domain_url(nil, git_domain.name), :params => gen_request(:refresh_from_source)) expect_single_action_result( :success => true, :message => a_string_matching(/Refreshing Automate Domain .* from git repository/), diff --git a/spec/requests/automate_spec.rb b/spec/requests/automate_spec.rb index da8ed94da0..f0ff135881 100644 --- a/spec/requests/automate_spec.rb +++ b/spec/requests/automate_spec.rb @@ -31,7 +31,7 @@ it 'returns only the requested attributes' do api_basic_authorize action_identifier(:automate, :read, :collection_actions, :get) - get api_automates_url, :expand => 'resources', :attributes => 'name' + get api_automates_url, :params => { :expand => 'resources', :attributes => 'name' } expect(response).to have_http_status(:ok) response.parsed_body['resources'].each { |res| expect_hash_to_have_only_keys(res, %w(fqname name)) } @@ -51,7 +51,7 @@ it "supports depth 1" do api_basic_authorize action_identifier(:automate, :read, :collection_actions, :get) - get(api_automate_url(nil, "custom"), :depth => 1) + get(api_automate_url(nil, "custom"), :params => { :depth => 1 }) expect(response).to have_http_status(:ok) expect(response.parsed_body["resources"]).to match_array( @@ -63,7 +63,7 @@ it "supports depth -1" do api_basic_authorize action_identifier(:automate, :read, :collection_actions, :get) - get(api_automates_url, :depth => -1) + get(api_automates_url, :params => { :depth => -1 }) expect(response).to have_http_status(:ok) expect(response.parsed_body["resources"]).to match_array( @@ -76,7 +76,7 @@ it "supports state_machines search option" do api_basic_authorize action_identifier(:automate, :read, :collection_actions, :get) - get(api_automates_url, :depth => -1, :search_options => "state_machines") + get(api_automates_url, :params => { :depth => -1, :search_options => "state_machines" }) expect(response).to have_http_status(:ok) expect(response.parsed_body["resources"]).to match_array( @@ -88,7 +88,7 @@ it "always return the fqname" do api_basic_authorize action_identifier(:automate, :read, :collection_actions, :get) - get(api_automate_url(nil, "custom/system"), :attributes => "name") + get(api_automate_url(nil, "custom/system"), :params => { :attributes => "name" }) expect(response).to have_http_status(:ok) expect(response.parsed_body["resources"]).to match_array([{"name" => "System", "fqname" => "/Custom/System"}]) diff --git a/spec/requests/automation_requests_spec.rb b/spec/requests/automation_requests_spec.rb index d8fc2f5dd4..31332e28b2 100644 --- a/spec/requests/automation_requests_spec.rb +++ b/spec/requests/automation_requests_spec.rb @@ -95,7 +95,7 @@ it "supports single request with normal post" do api_basic_authorize - post(api_automation_requests_url, single_automation_request) + post(api_automation_requests_url, :params => single_automation_request) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", %w(id approval_state type request_type status options)) @@ -108,7 +108,7 @@ it "supports single request with create action" do api_basic_authorize - post(api_automation_requests_url, gen_request(:create, single_automation_request)) + post(api_automation_requests_url, :params => gen_request(:create, single_automation_request)) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", %w(id approval_state type request_type status options)) @@ -121,7 +121,7 @@ it "supports multiple requests" do api_basic_authorize - post(api_automation_requests_url, gen_request(:create, [single_automation_request, single_automation_request])) + post(api_automation_requests_url, :params => gen_request(:create, [single_automation_request, single_automation_request])) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", %w(id approval_state type request_type status options)) @@ -138,7 +138,7 @@ automation_request = FactoryGirl.create(:automation_request, :requester => @user, :options => {:foo => "bar"}) api_basic_authorize - post(api_automation_request_url(nil, automation_request), :action => "edit", :options => {:baz => "qux"}) + post(api_automation_request_url(nil, automation_request), :params => { :action => "edit", :options => {:baz => "qux"} }) expect(response).to have_http_status(:forbidden) end @@ -147,7 +147,7 @@ automation_request = FactoryGirl.create(:automation_request, :requester => @user, :options => {:foo => "bar"}) api_basic_authorize(action_identifier(:automation_requests, :edit)) - post(api_automation_request_url(nil, automation_request), :action => "edit", :options => {:baz => "qux"}) + post(api_automation_request_url(nil, automation_request), :params => { :action => "edit", :options => {:baz => "qux"} }) expected = { "id" => automation_request.compressed_id, @@ -166,11 +166,13 @@ post( api_automation_requests_url, - :action => "edit", - :resources => [ - {:id => automation_request.id, :options => {:baz => "qux"}}, - {:id => automation_request2.id, :options => {:quux => "quuz"}} - ] + :params => { + :action => "edit", + :resources => [ + {:id => automation_request.id, :options => {:baz => "qux"}}, + {:id => automation_request2.id, :options => {:quux => "quuz"}} + ] + } ) expected = { @@ -195,7 +197,7 @@ it "supports approving a request" do api_basic_authorize collection_action_identifier(:automation_requests, :approve) - post(request1_url, gen_request(:approve, :reason => "approve reason")) + post(request1_url, :params => gen_request(:approve, :reason => "approve reason")) expected_msg = "Automation request #{request1.id} approved" expect_single_action_result(:success => true, :message => expected_msg, :href => api_automation_request_url(nil, request1.compressed_id)) @@ -204,7 +206,7 @@ it "supports denying a request" do api_basic_authorize collection_action_identifier(:automation_requests, :deny) - post(request2_url, gen_request(:deny, :reason => "deny reason")) + post(request2_url, :params => gen_request(:deny, :reason => "deny reason")) expected_msg = "Automation request #{request2.id} denied" expect_single_action_result(:success => true, :message => expected_msg, :href => api_automation_request_url(nil, request2.compressed_id)) @@ -213,8 +215,8 @@ it "supports approving multiple requests" do api_basic_authorize collection_action_identifier(:automation_requests, :approve) - post(api_automation_requests_url, gen_request(:approve, [{"href" => request1_url, "reason" => "approve reason"}, - {"href" => request2_url, "reason" => "approve reason"}])) + post(api_automation_requests_url, :params => gen_request(:approve, [{"href" => request1_url, "reason" => "approve reason"}, + {"href" => request2_url, "reason" => "approve reason"}])) expected = { "results" => a_collection_containing_exactly( @@ -237,8 +239,8 @@ it "supports denying multiple requests" do api_basic_authorize collection_action_identifier(:automation_requests, :deny) - post(api_automation_requests_url, gen_request(:deny, [{"href" => request1_url, "reason" => "deny reason"}, - {"href" => request2_url, "reason" => "deny reason"}])) + post(api_automation_requests_url, :params => gen_request(:deny, [{"href" => request1_url, "reason" => "deny reason"}, + {"href" => request2_url, "reason" => "deny reason"}])) expected = { "results" => a_collection_containing_exactly( diff --git a/spec/requests/blueprints_spec.rb b/spec/requests/blueprints_spec.rb index 726f0a229c..f155e0af11 100644 --- a/spec/requests/blueprints_spec.rb +++ b/spec/requests/blueprints_spec.rb @@ -59,7 +59,7 @@ :chart_data_model => {} } - post(api_blueprints_url, :name => "foo", :description => "bar", :ui_properties => ui_properties) + post(api_blueprints_url, :params => { :name => "foo", :description => "bar", :ui_properties => ui_properties }) expected = { "results" => [ @@ -82,7 +82,7 @@ it "rejects blueprint creation with id specified" do api_basic_authorize collection_action_identifier(:blueprints, :create) - post(api_blueprints_url, :name => "foo", :description => "bar", :id => 123) + post(api_blueprints_url, :params => { :name => "foo", :description => "bar", :id => 123 }) expected = { "error" => a_hash_including( @@ -97,7 +97,7 @@ it "rejects blueprint creation with an href specified" do api_basic_authorize collection_action_identifier(:blueprints, :create) - post(api_blueprints_url, :name => "foo", :description => "bar", :href => api_blueprint_url(nil, 123)) + post(api_blueprints_url, :params => { :name => "foo", :description => "bar", :href => api_blueprint_url(nil, 123) }) expected = { "error" => a_hash_including( @@ -120,10 +120,12 @@ post( api_blueprints_url, - :resources => [ - {:name => "foo", :description => "bar", :ui_properties => ui_properties}, - {:name => "baz", :description => "qux", :ui_properties => ui_properties} - ] + :params => { + :resources => [ + {:name => "foo", :description => "bar", :ui_properties => ui_properties}, + {:name => "baz", :description => "qux", :ui_properties => ui_properties} + ] + } ) expected = { @@ -139,7 +141,7 @@ it "forbids blueprint creation without an appropriate role" do api_basic_authorize - post(api_blueprints_url, :name => "foo", :description => "bar", :ui_properties => {:some => {:json => "baz"}}) + post(api_blueprints_url, :params => { :name => "foo", :description => "bar", :ui_properties => {:some => {:json => "baz"}} }) expect(response).to have_http_status(:forbidden) end @@ -151,8 +153,16 @@ blueprint2 = FactoryGirl.create(:blueprint, :name => "bar") api_basic_authorize collection_action_identifier(:blueprints, :edit) - post(api_blueprints_url, :action => "edit", :resources => [{:id => blueprint1.id, :name => "baz"}, - {:id => blueprint2.id, :name => "qux"}]) + post( + api_blueprints_url, + :params => { + :action => "edit", + :resources => [ + {:id => blueprint1.id, :name => "baz"}, + {:id => blueprint2.id, :name => "qux"} + ] + } + ) expected = { "results" => a_collection_containing_exactly( @@ -175,8 +185,16 @@ blueprint2 = FactoryGirl.create(:blueprint, :name => "bar") api_basic_authorize - post(api_blueprints_url, :action => "edit", :resources => [{:id => blueprint1.id, :name => "baz"}, - {:id => blueprint2.id, :name => "qux"}]) + post( + api_blueprints_url, + :params => { + :action => "edit", + :resources => [ + {:id => blueprint1.id, :name => "baz"}, + {:id => blueprint2.id, :name => "qux"} + ] + } + ) expect(response).to have_http_status(:forbidden) end @@ -185,7 +203,7 @@ blueprint1, blueprint2 = FactoryGirl.create_list(:blueprint, 2) api_basic_authorize collection_action_identifier(:blueprints, :delete) - post(api_blueprints_url, :action => "delete", :resources => [{:id => blueprint1.id}, {:id => blueprint2.id}]) + post(api_blueprints_url, :params => { :action => "delete", :resources => [{:id => blueprint1.id}, {:id => blueprint2.id}] }) expect(response).to have_http_status(:ok) end @@ -194,7 +212,7 @@ blueprint1, blueprint2 = FactoryGirl.create_list(:blueprint, 2) api_basic_authorize - post(api_blueprints_url, :action => "delete", :resources => [{:id => blueprint1.id}, {:id => blueprint2.id}]) + post(api_blueprints_url, :params => { :action => "delete", :resources => [{:id => blueprint1.id}, {:id => blueprint2.id}] }) expect(response).to have_http_status(:forbidden) end @@ -218,7 +236,7 @@ api_basic_authorize collection_action_identifier(:blueprints, :publish) - post(api_blueprints_url, :action => "publish", :resources => [{:id => blueprint1.id}, {:id => blueprint2.id}]) + post(api_blueprints_url, :params => { :action => "publish", :resources => [{:id => blueprint1.id}, {:id => blueprint2.id}] }) expected = { "results" => a_collection_containing_exactly( @@ -237,7 +255,7 @@ blueprint = FactoryGirl.create(:blueprint, :name => "foo", :description => "bar") api_basic_authorize - post(api_blueprint_url(nil, blueprint), :action => "edit", :resource => {:name => "baz", :description => "qux"}) + post(api_blueprint_url(nil, blueprint), :params => { :action => "edit", :resource => {:name => "baz", :description => "qux"} }) expect(response).to have_http_status(:forbidden) end @@ -246,7 +264,7 @@ blueprint = FactoryGirl.create(:blueprint) api_basic_authorize action_identifier(:blueprints, :delete) - post(api_blueprint_url(nil, blueprint), :action => "delete") + post(api_blueprint_url(nil, blueprint), :params => { :action => "delete" }) expect(response).to have_http_status(:ok) end @@ -255,7 +273,7 @@ blueprint = FactoryGirl.create(:blueprint) api_basic_authorize - post(api_blueprint_url(nil, blueprint), :action => "delete") + post(api_blueprint_url(nil, blueprint), :params => { :action => "delete" }) expect(response).to have_http_status(:forbidden) end @@ -278,7 +296,7 @@ blueprint = FactoryGirl.create(:blueprint, :ui_properties => ui_properties) api_basic_authorize action_identifier(:blueprints, :publish) - post(api_blueprint_url(nil, blueprint), :action => "publish") + post(api_blueprint_url(nil, blueprint), :params => { :action => "publish" }) expected = { "id" => blueprint.compressed_id, @@ -292,7 +310,7 @@ blueprint = FactoryGirl.create(:blueprint) api_basic_authorize action_identifier(:blueprints, :publish) - post(api_blueprint_url(nil, blueprint), :action => "publish") + post(api_blueprint_url(nil, blueprint), :params => { :action => "publish" }) expected = { "error" => a_hash_including( diff --git a/spec/requests/categories_spec.rb b/spec/requests/categories_spec.rb index c95b9c9326..9b025a3e57 100644 --- a/spec/requests/categories_spec.rb +++ b/spec/requests/categories_spec.rb @@ -17,7 +17,7 @@ _category_2 = FactoryGirl.create(:category, :name => "bar") api_basic_authorize collection_action_identifier(:categories, :read, :get) - get api_categories_url, :filter => ["name=foo"] + get api_categories_url, :params => { :filter => ["name=foo"] } expect_query_result(:categories, 1, 2) expect_result_resources_to_include_hrefs("resources", [api_category_url(nil, category_1.compressed_id)]) @@ -27,7 +27,7 @@ FactoryGirl.create(:category) api_basic_authorize collection_action_identifier(:categories, :read, :get) - get api_categories_url, :filter => ["not_an_attribute=foo"] + get api_categories_url, :params => { :filter => ["not_an_attribute=foo"] } expect_bad_request(/attribute not_an_attribute does not exist/) end @@ -50,7 +50,7 @@ FactoryGirl.create(:category, :example_text => 'foo') api_basic_authorize collection_action_identifier(:categories, :read, :get) - get api_categories_url, :expand => 'resources', :attributes => 'example_text' + get api_categories_url, :params => { :expand => 'resources', :attributes => 'example_text' } expect(response).to have_http_status(:ok) response.parsed_body['resources'].each { |res| expect_hash_to_have_only_keys(res, %w(href id example_text)) } @@ -77,7 +77,7 @@ api_basic_authorize collection_action_identifier(:categories, :create) expect do - post api_categories_url, :name => "test", :description => "Test" + post api_categories_url, :params => { :name => "test", :description => "Test" } end.to change(Category, :count).by(1) expect(response).to have_http_status(:ok) @@ -93,7 +93,7 @@ :show => true, :single_value => true } - post api_categories_url, options + post api_categories_url, :params => options expect_result_to_match_hash( response.parsed_body["results"].first, @@ -106,7 +106,7 @@ it "can create an associated tag" do api_basic_authorize collection_action_identifier(:categories, :create) - post api_categories_url, :name => "test", :description => "Test" + post api_categories_url, :params => { :name => "test", :description => "Test" } category = Category.find(ApplicationRecord.uncompress_id(response.parsed_body["results"].first["id"])) expect(category.tag.name).to eq("/managed/test") @@ -117,7 +117,7 @@ api_basic_authorize action_identifier(:categories, :edit) expect do - post api_category_url(nil, category), gen_request(:edit, :description => "New description") + post api_category_url(nil, category), :params => gen_request(:edit, :description => "New description") end.to change { category.reload.description }.to("New description") expect(response).to have_http_status(:ok) @@ -129,7 +129,7 @@ api_basic_authorize action_identifier(:categories, :delete) expect do - post api_category_url(nil, category), gen_request(:delete) + post api_category_url(nil, category), :params => gen_request(:delete) end.to change(Category, :count).by(-1) expect(response).to have_http_status(:ok) @@ -152,7 +152,7 @@ api_basic_authorize action_identifier(:categories, :delete) expect do - post api_category_url(nil, category), gen_request(:delete) + post api_category_url(nil, category), :params => gen_request(:delete) end.not_to change(Category, :count) expect(response).to have_http_status(:forbidden) @@ -163,7 +163,7 @@ api_basic_authorize action_identifier(:categories, :edit) expect do - post api_category_url(nil, category), gen_request(:edit, :description => "new description") + post api_category_url(nil, category), :params => gen_request(:edit, :description => "new description") end.not_to change { category.reload.description } expect(response).to have_http_status(:forbidden) @@ -175,7 +175,7 @@ api_basic_authorize expect do - post api_categories_url, :name => "test", :description => "Test" + post api_categories_url, :params => { :name => "test", :description => "Test" } end.not_to change(Category, :count) expect(response).to have_http_status(:forbidden) @@ -186,7 +186,7 @@ api_basic_authorize expect do - post api_category_url(nil, category), gen_request(:edit, :description => "New description") + post api_category_url(nil, category), :params => gen_request(:edit, :description => "New description") end.not_to change { category.reload.description } expect(response).to have_http_status(:forbidden) @@ -197,7 +197,7 @@ api_basic_authorize expect do - post api_category_url(nil, category), gen_request(:delete) + post api_category_url(nil, category), :params => gen_request(:delete) end.not_to change(Category, :count) expect(response).to have_http_status(:forbidden) diff --git a/spec/requests/chargebacks_spec.rb b/spec/requests/chargebacks_spec.rb index 919c5725b8..29c72d8152 100644 --- a/spec/requests/chargebacks_spec.rb +++ b/spec/requests/chargebacks_spec.rb @@ -132,9 +132,13 @@ api_basic_authorize action_identifier(:chargebacks, :create, :collection_actions) expect do - post api_chargebacks_url, - :description => "chargeback_0", - :rate_type => "Storage" + post( + api_chargebacks_url, + :params => { + :description => "chargeback_0", + :rate_type => "Storage" + } + ) end.to change(ChargebackRate, :count).by(1) expect_result_to_match_hash(response.parsed_body["results"].first, "description" => "chargeback_0", "rate_type" => "Storage", @@ -146,8 +150,7 @@ api_basic_authorize action_identifier(:chargebacks, :create, :collection_actions) expect do - post api_chargebacks_url, - :rate_type => "Storage" + post api_chargebacks_url, :params => { :rate_type => "Storage" } end.not_to change(ChargebackRate, :count) expect_bad_request(/description can't be blank/i) end @@ -156,7 +159,7 @@ chargeback_rate = FactoryGirl.create(:chargeback_rate, :description => "chargeback_0") api_basic_authorize action_identifier(:chargebacks, :edit) - post api_chargeback_url(nil, chargeback_rate), gen_request(:edit, :description => "chargeback_1") + post api_chargeback_url(nil, chargeback_rate), :params => gen_request(:edit, :description => "chargeback_1") expect(response.parsed_body["description"]).to eq("chargeback_1") expect(response).to have_http_status(:ok) @@ -167,9 +170,9 @@ chargeback_rate = FactoryGirl.create(:chargeback_rate, :description => "chargeback_0") api_basic_authorize action_identifier(:chargebacks, :edit) - patch api_chargeback_url(nil, chargeback_rate), [{:action => "edit", - :path => "description", - :value => "chargeback_1"}] + patch api_chargeback_url(nil, chargeback_rate), :params => [{:action => "edit", + :path => "description", + :value => "chargeback_1"}] expect(response.parsed_body["description"]).to eq("chargeback_1") expect(response).to have_http_status(:ok) @@ -193,7 +196,7 @@ api_basic_authorize action_identifier(:chargebacks, :delete) expect do - post api_chargeback_url(nil, chargeback_rate), :action => "delete" + post api_chargeback_url(nil, chargeback_rate), :params => { :action => "delete" } end.to change(ChargebackRate, :count).by(-1) expect(response).to have_http_status(:ok) end @@ -203,13 +206,17 @@ chargeback_rate = FactoryGirl.create(:chargeback_rate) expect do - post api_rates_url, - :description => "rate_0", - :group => "fixed", - :chargeback_rate_id => chargeback_rate.id, - :chargeable_field_id => field.id, - :source => "used", - :enabled => true + post( + api_rates_url, + :params => { + :description => "rate_0", + :group => "fixed", + :chargeback_rate_id => chargeback_rate.id, + :chargeable_field_id => field.id, + :source => "used", + :enabled => true + } + ) end.to change(ChargebackRateDetail, :count).by(1) expect_result_to_match_hash(response.parsed_body["results"].first, "description" => "rate_0", "enabled" => true) expect(response).to have_http_status(:ok) @@ -219,9 +226,7 @@ api_basic_authorize action_identifier(:rates, :create, :collection_actions) expect do - post api_rates_url, - :description => "rate_0", - :enabled => true + post api_rates_url, :params => { :description => "rate_0", :enabled => true } end.not_to change(ChargebackRateDetail, :count) expect_bad_request(/Chargeback rate can't be blank/i) expect_bad_request(/Chargeable field can't be blank/i) @@ -236,7 +241,7 @@ chargeback_rate_detail.save api_basic_authorize action_identifier(:rates, :edit) - post api_rate_url(nil, chargeback_rate_detail), gen_request(:edit, :description => "rate_1") + post api_rate_url(nil, chargeback_rate_detail), :params => gen_request(:edit, :description => "rate_1") expect(response.parsed_body["description"]).to eq("rate_1") expect(response).to have_http_status(:ok) @@ -252,7 +257,7 @@ chargeback_rate_detail.save api_basic_authorize action_identifier(:rates, :edit) - patch api_rate_url(nil, chargeback_rate_detail), [{:action => "edit", :path => "description", :value => "rate_1"}] + patch api_rate_url(nil, chargeback_rate_detail), :params => [{:action => "edit", :path => "description", :value => "rate_1"}] expect(response.parsed_body["description"]).to eq("rate_1") expect(response).to have_http_status(:ok) @@ -286,7 +291,7 @@ api_basic_authorize action_identifier(:rates, :delete) expect do - post api_rate_url(nil, chargeback_rate_detail), :action => "delete" + post api_rate_url(nil, chargeback_rate_detail), :params => { :action => "delete" } end.to change(ChargebackRateDetail, :count).by(-1) expect(response).to have_http_status(:ok) end @@ -296,8 +301,7 @@ it "cannot create a chargeback rate" do api_basic_authorize - expect { post api_chargebacks_url, :description => "chargeback_0" }.not_to change(ChargebackRate, - :count) + expect { post api_chargebacks_url, :params => { :description => "chargeback_0" } }.not_to change(ChargebackRate, :count) expect(response).to have_http_status(:forbidden) end @@ -307,7 +311,7 @@ api_basic_authorize expect do - post api_chargeback_url(nil, chargeback_rate), gen_request(:edit, :description => "chargeback_1") + post api_chargeback_url(nil, chargeback_rate), :params => gen_request(:edit, :description => "chargeback_1") end.not_to change { chargeback_rate.reload.description } expect(response).to have_http_status(:forbidden) end @@ -326,8 +330,7 @@ it "cannot create a chargeback rate detail" do api_basic_authorize - expect { post api_rates_url, :description => "rate_0", :enabled => true }.not_to change(ChargebackRateDetail, - :count) + expect { post api_rates_url, :params => { :description => "rate_0", :enabled => true } }.not_to change(ChargebackRateDetail, :count) expect(response).to have_http_status(:forbidden) end @@ -342,7 +345,7 @@ api_basic_authorize expect do - post api_rate_url(nil, chargeback_rate_detail), gen_request(:edit, :description => "rate_2") + post api_rate_url(nil, chargeback_rate_detail), :params => gen_request(:edit, :description => "rate_2") end.not_to change { chargeback_rate_detail.reload.description } expect(response).to have_http_status(:forbidden) end diff --git a/spec/requests/cloud_networks_spec.rb b/spec/requests/cloud_networks_spec.rb index 8bb00b8931..a7d7abf3bd 100644 --- a/spec/requests/cloud_networks_spec.rb +++ b/spec/requests/cloud_networks_spec.rb @@ -26,7 +26,7 @@ cloud_network_ids = provider.cloud_networks.select(:id).collect(&:compressed_id) api_basic_authorize subcollection_action_identifier(:providers, :cloud_networks, :read, :get) - get api_provider_cloud_networks_url(nil, provider), :expand => 'resources' + get api_provider_cloud_networks_url(nil, provider), :params => { :expand => 'resources' } expect_query_result(:cloud_networks, 2) expect_result_resources_to_include_data('resources', 'id' => cloud_network_ids) @@ -63,7 +63,7 @@ FactoryGirl.create(:ems_amazon_with_cloud_networks) # Provider with cloud networks api_basic_authorize collection_action_identifier(:providers, :read, :get) - get api_providers_url, :expand => 'resources,cloud_networks' + get api_providers_url, :params => { :expand => 'resources,cloud_networks' } expected = { 'resources' => a_collection_including( @@ -84,7 +84,7 @@ openshift = FactoryGirl.create(:ems_openshift) api_basic_authorize subcollection_action_identifier(:providers, :cloud_networks, :read, :get) - get(api_provider_cloud_networks_url(nil, openshift), :expand => 'resources') + get(api_provider_cloud_networks_url(nil, openshift), :params => { :expand => 'resources' }) expected = { 'name' => 'cloud_networks', diff --git a/spec/requests/cloud_volumes_spec.rb b/spec/requests/cloud_volumes_spec.rb index 04f3f8e6aa..90ff57344b 100644 --- a/spec/requests/cloud_volumes_spec.rb +++ b/spec/requests/cloud_volumes_spec.rb @@ -44,7 +44,7 @@ it "rejects delete request without appropriate role" do api_basic_authorize - post(api_cloud_volumes_url, :action => 'delete') + post(api_cloud_volumes_url, :params => { :action => 'delete' }) expect(response).to have_http_status(:forbidden) end @@ -57,7 +57,7 @@ api_basic_authorize action_identifier(:cloud_volumes, :delete, :resource_actions, :post) - post(api_cloud_volume_url(nil, cloud_volume1), :action => "delete") + post(api_cloud_volume_url(nil, cloud_volume1), :params => { :action => "delete" }) expected = { 'message' => 'Deleting Cloud Volume CloudVolume1', @@ -115,7 +115,7 @@ ) ) } - post(api_cloud_volumes_url, :action => 'delete', :resources => [{ 'id' => cloud_volume1.id }, { 'id' => cloud_volume2.id }]) + post(api_cloud_volumes_url, :params => { :action => 'delete', :resources => [{ 'id' => cloud_volume1.id }, { 'id' => cloud_volume2.id }] }) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) diff --git a/spec/requests/collections_spec.rb b/spec/requests/collections_spec.rb index 31f54ac187..55fd8d4c62 100644 --- a/spec/requests/collections_spec.rb +++ b/spec/requests/collections_spec.rb @@ -15,7 +15,7 @@ def test_collection_query(collection, collection_url, klass, attr = :id) api_basic_authorize end - get collection_url, :expand => "resources" + get collection_url, :params => { :expand => "resources" } expect_query_result(collection, klass.count, klass.count) expected = attr == :id ? klass.select(:id).collect(&:compressed_id) : klass.pluck(attr) @@ -32,7 +32,7 @@ def test_collection_bulk_query(collection, collection_url, klass, id = nil) resources = [{"id" => obj.compressed_id}, {"href" => url}] attr_list.each { |attr| resources << {attr => obj.public_send(attr)} } - post(collection_url, gen_request(:query, resources)) + post(collection_url, :params => gen_request(:query, resources)) expect(response).to have_http_status(:ok) expect(response.parsed_body["results"].size).to eq(resources.size) @@ -123,7 +123,7 @@ def test_collection_bulk_query(collection, collection_url, klass, id = nil) expect(Tenant.exists?).to be_truthy FactoryGirl.create(:miq_group) api_basic_authorize collection_action_identifier(:groups, :read, :get) - get api_groups_url, :expand => 'resources' + get api_groups_url, :params => { :expand => 'resources' } expect_query_result(:groups, MiqGroup.non_tenant_groups.count, MiqGroup.count) expect_result_resources_to_include_data('resources', 'id' => MiqGroup.non_tenant_groups.select(:id).collect(&:compressed_id)) @@ -543,7 +543,7 @@ def test_collection_bulk_query(collection, collection_url, klass, id = nil) api_basic_authorize(collection_action_identifier(:vms, :query), action_identifier(:vms, :start)) # HMMM - post(api_vms_url, gen_request(:query, [{"id" => vm.id}])) + post(api_vms_url, :params => gen_request(:query, [{"id" => vm.id}])) expected = { "results" => [ @@ -565,7 +565,7 @@ def test_collection_bulk_query(collection, collection_url, klass, id = nil) FactoryGirl.create(:vm_vmware) api_basic_authorize collection_action_identifier(:vms, :query) - post(api_vms_url, gen_request(:query, [{"guid" => "B999999D"}])) + post(api_vms_url, :params => gen_request(:query, [{"guid" => "B999999D"}])) expect(response.parsed_body).to include_error_with_message("Invalid vms resource specified - guid=B999999D") expect(response).to have_http_status(:not_found) diff --git a/spec/requests/conditions_spec.rb b/spec/requests/conditions_spec.rb index 697da69005..5c59681399 100644 --- a/spec/requests/conditions_spec.rb +++ b/spec/requests/conditions_spec.rb @@ -35,7 +35,7 @@ def assign_conditions_to(resource) it "forbids access to create condition without an appropriate role" do api_basic_authorize - post(api_conditions_url, sample_condition) + post(api_conditions_url, :params => sample_condition) expect(response).to have_http_status(:forbidden) end @@ -43,7 +43,7 @@ def assign_conditions_to(resource) it "forbids access to edit condition without an appropriate role" do api_basic_authorize - post(api_condition_url(nil, condition), gen_request(:edit, "description" => "change")) + post(api_condition_url(nil, condition), :params => gen_request(:edit, "description" => "change")) expect(response).to have_http_status(:forbidden) end @@ -52,7 +52,7 @@ def assign_conditions_to(resource) condition api_basic_authorize - post(api_conditions_url, gen_request(:delete, "name" => condition.name, "href" => condition_url)) + post(api_conditions_url, :params => gen_request(:delete, "name" => condition.name, "href" => condition_url)) expect(response).to have_http_status(:forbidden) end @@ -68,7 +68,7 @@ def assign_conditions_to(resource) it "creates new condition" do api_basic_authorize collection_action_identifier(:conditions, :create) - post(api_conditions_url, sample_condition) + post(api_conditions_url, :params => sample_condition) expect(response).to have_http_status(:ok) @@ -79,8 +79,8 @@ def assign_conditions_to(resource) it "creates new conditions" do api_basic_authorize collection_action_identifier(:conditions, :create) - post(api_conditions_url, gen_request(:create, [sample_condition, - sample_condition.merge(:name => "foo", :description => "bar")])) + post(api_conditions_url, :params => gen_request(:create, [sample_condition, + sample_condition.merge(:name => "foo", :description => "bar")])) expect(response).to have_http_status(:ok) expect(response.parsed_body["results"].count).to eq(2) @@ -88,7 +88,7 @@ def assign_conditions_to(resource) it "deletes condition" do api_basic_authorize collection_action_identifier(:conditions, :delete) - post(api_conditions_url, gen_request(:delete, "name" => condition.name, "href" => condition_url)) + post(api_conditions_url, :params => gen_request(:delete, "name" => condition.name, "href" => condition_url)) expect(response).to have_http_status(:ok) @@ -97,10 +97,10 @@ def assign_conditions_to(resource) it "deletes conditions" do api_basic_authorize collection_action_identifier(:conditions, :delete) - post(api_conditions_url, gen_request(:delete, [{"name" => conditions.first.name, - "href" => api_condition_url(nil, conditions.first)}, - {"name" => conditions.second.name, - "href" => api_condition_url(nil, conditions.second)}])) + post(api_conditions_url, :params => gen_request(:delete, [{"name" => conditions.first.name, + "href" => api_condition_url(nil, conditions.first)}, + {"name" => conditions.second.name, + "href" => api_condition_url(nil, conditions.second)}])) expect(response).to have_http_status(:ok) @@ -118,7 +118,7 @@ def assign_conditions_to(resource) it "edits condition" do api_basic_authorize collection_action_identifier(:conditions, :edit) - post(api_condition_url(nil, condition), gen_request(:edit, "description" => "change")) + post(api_condition_url(nil, condition), :params => gen_request(:edit, "description" => "change")) expect(response).to have_http_status(:ok) @@ -128,8 +128,8 @@ def assign_conditions_to(resource) it "edits conditions" do api_basic_authorize collection_action_identifier(:conditions, :edit) - post(api_conditions_url, gen_request(:edit, [{"id" => conditions.first.id, "description" => "change"}, - {"id" => conditions.second.id, "description" => "change2"}])) + post(api_conditions_url, :params => gen_request(:edit, [{"id" => conditions.first.id, "description" => "change"}, + {"id" => conditions.second.id, "description" => "change2"}])) expect(response).to have_http_status(:ok) expect(response.parsed_body["results"].count).to eq(2) @@ -172,7 +172,7 @@ def assign_conditions_to(resource) api_basic_authorize collection_action_identifier(:conditions, :read, :get) create_conditions(3) - get api_conditions_url, :expand => "resources" + get api_conditions_url, :params => { :expand => "resources" } expect_query_result(:conditions, 3, 3) expect_result_resources_to_include_data("resources", "guid" => condition_guid_list) @@ -195,7 +195,7 @@ def assign_conditions_to(resource) create_conditions(3) assign_conditions_to(policy) - get(api_policy_conditions_url(nil, policy), :expand => "resources") + get(api_policy_conditions_url(nil, policy), :params => { :expand => "resources" }) expect_query_result(:conditions, 3, 3) expect_result_resources_to_include_data("resources", "guid" => condition_guid_list) @@ -206,7 +206,7 @@ def assign_conditions_to(resource) create_conditions(3) assign_conditions_to(policy) - get(api_policy_url(nil, policy), :expand => "conditions") + get(api_policy_url(nil, policy), :params => { :expand => "conditions" }) expect_single_resource_query("name" => policy.name, "description" => policy.description, "guid" => policy.guid) expect_result_resources_to_include_data("conditions", "guid" => condition_guid_list) diff --git a/spec/requests/configuration_script_payloads_spec.rb b/spec/requests/configuration_script_payloads_spec.rb index b6c0bd44a3..72fc139e83 100644 --- a/spec/requests/configuration_script_payloads_spec.rb +++ b/spec/requests/configuration_script_payloads_spec.rb @@ -55,7 +55,7 @@ playbook = FactoryGirl.create(:configuration_script_payload, :authentications => [authentication]) api_basic_authorize subcollection_action_identifier(:configuration_script_payloads, :authentications, :read, :get) - get(api_configuration_script_payload_authentications_url(nil, playbook), :expand => 'resources') + get(api_configuration_script_payload_authentications_url(nil, playbook), :params => { :expand => 'resources' }) expected = { 'resources' => [ @@ -84,7 +84,7 @@ it 'requires that the type support create_in_provider_queue' do api_basic_authorize subcollection_action_identifier(:configuration_script_payloads, :authentications, :create) - post(api_configuration_script_payload_authentications_url(nil, playbook), :type => 'Authentication') + post(api_configuration_script_payload_authentications_url(nil, playbook), :params => { :type => 'Authentication' }) expected = { 'results' => [ @@ -98,7 +98,7 @@ it 'creates a new authentication with an appropriate role' do api_basic_authorize subcollection_action_identifier(:configuration_script_payloads, :authentications, :create) - post(api_configuration_script_payload_authentications_url(nil, playbook), params) + post(api_configuration_script_payload_authentications_url(nil, playbook), :params => params) expected = { 'results' => [a_hash_including( @@ -114,7 +114,7 @@ it 'can create multiple authentications with an appropriate role' do api_basic_authorize subcollection_action_identifier(:configuration_script_payloads, :authentications, :create) - post(api_configuration_script_payload_authentications_url(nil, playbook), :resources => [params, params]) + post(api_configuration_script_payload_authentications_url(nil, playbook), :params => { :resources => [params, params] }) expected = { 'results' => [ @@ -137,7 +137,7 @@ it 'cannot create an authentication without appropriate role' do api_basic_authorize - post(api_configuration_script_payload_authentications_url(nil, playbook), :resources => [params]) + post(api_configuration_script_payload_authentications_url(nil, playbook), :params => { :resources => [params] }) expect(response).to have_http_status(:forbidden) end diff --git a/spec/requests/configuration_script_sources_spec.rb b/spec/requests/configuration_script_sources_spec.rb index 910beb5ebb..7001676ff7 100644 --- a/spec/requests/configuration_script_sources_spec.rb +++ b/spec/requests/configuration_script_sources_spec.rb @@ -68,7 +68,7 @@ api_basic_authorize collection_action_identifier(:configuration_script_sources, :edit, :post) params2 = params.dup.merge(:id => config_script_src_2.id) - post(api_configuration_script_sources_url, :action => 'edit', :resources => [params, params2]) + post(api_configuration_script_sources_url, :params => { :action => 'edit', :resources => [params, params2] }) expected = { 'results' => [ @@ -91,7 +91,7 @@ it 'forbids updating configuration_script_sources without an appropriate role' do api_basic_authorize - post(api_configuration_script_sources_url, :action => 'edit', :resources => [params]) + post(api_configuration_script_sources_url, :params => { :action => 'edit', :resources => [params] }) expect(response).to have_http_status(:forbidden) end @@ -99,7 +99,7 @@ it 'will delete multiple configuration script source with an appropriate role' do api_basic_authorize collection_action_identifier(:configuration_script_sources, :delete, :post) - post(api_configuration_script_sources_url, :action => 'delete', :resources => [{:id => config_script_src.id}, {:id => config_script_src_2.id}]) + post(api_configuration_script_sources_url, :params => { :action => 'delete', :resources => [{:id => config_script_src.id}, {:id => config_script_src_2.id}] }) expected = { 'results' => [ @@ -122,7 +122,7 @@ it 'forbids delete without an appropriate role' do api_basic_authorize - post(api_configuration_script_sources_url, :action => 'delete', :resources => [{:id => config_script_src.id}]) + post(api_configuration_script_sources_url, :params => { :action => 'delete', :resources => [{:id => config_script_src.id}] }) expect(response).to have_http_status(:forbidden) end @@ -130,7 +130,7 @@ it 'can refresh multiple configuration_script_source with an appropriate role' do api_basic_authorize collection_action_identifier(:configuration_script_sources, :refresh, :post) - post(api_configuration_script_sources_url, :action => :refresh, :resources => [{ :id => config_script_src.id}, {:id => config_script_src_2.id}]) + post(api_configuration_script_sources_url, :params => { :action => :refresh, :resources => [{ :id => config_script_src.id}, {:id => config_script_src_2.id}] }) expected = { 'results' => [ @@ -166,7 +166,7 @@ it 'updates a configuration_script_source with an appropriate role' do api_basic_authorize action_identifier(:configuration_script_sources, :edit) - put(api_configuration_script_source_url(nil, config_script_src), :resource => params) + put(api_configuration_script_source_url(nil, config_script_src), :params => { :resource => params }) expected = { 'success' => true, @@ -190,7 +190,7 @@ it 'updates a configuration_script_source with an appropriate role' do api_basic_authorize action_identifier(:configuration_script_sources, :edit) - patch(api_configuration_script_source_url(nil, config_script_src), [params]) + patch(api_configuration_script_source_url(nil, config_script_src), :params => [params]) expected = { 'success' => true, @@ -213,7 +213,7 @@ it 'updates a configuration_script_source with an appropriate role' do api_basic_authorize action_identifier(:configuration_script_sources, :edit) - post(api_configuration_script_source_url(nil, config_script_src), :action => 'edit', :resource => params) + post(api_configuration_script_source_url(nil, config_script_src), :params => { :action => 'edit', :resource => params }) expected = { 'success' => true, @@ -228,7 +228,7 @@ config_script_src = FactoryGirl.create(:configuration_script_source) api_basic_authorize action_identifier(:configuration_script_sources, :edit) - post(api_configuration_script_source_url(nil, config_script_src), :action => 'edit', :resource => params) + post(api_configuration_script_source_url(nil, config_script_src), :params => { :action => 'edit', :resource => params }) expected = { 'success' => false, @@ -241,7 +241,7 @@ it 'forbids updating a configuration_script_source without an appropriate role' do api_basic_authorize - post(api_configuration_script_source_url(nil, config_script_src), :action => 'edit', :resource => params) + post(api_configuration_script_source_url(nil, config_script_src), :params => { :action => 'edit', :resource => params }) expect(response).to have_http_status(:forbidden) end @@ -249,7 +249,7 @@ it 'forbids refresh without an appropriate role' do api_basic_authorize - post(api_configuration_script_source_url(nil, config_script_src), :action => 'refresh') + post(api_configuration_script_source_url(nil, config_script_src), :params => { :action => 'refresh' }) expect(response).to have_http_status(:forbidden) end @@ -257,7 +257,7 @@ it 'can refresh a configuration_script_source with an appropriate role' do api_basic_authorize action_identifier(:configuration_script_sources, :refresh) - post(api_configuration_script_source_url(nil, config_script_src), :action => :refresh) + post(api_configuration_script_source_url(nil, config_script_src), :params => { :action => :refresh }) expected = { 'success' => true, @@ -273,7 +273,7 @@ it 'can delete a configuration_script_source with an appropriate role' do api_basic_authorize action_identifier(:configuration_script_sources, :delete) - post(api_configuration_script_source_url(nil, config_script_src), :action => 'delete') + post(api_configuration_script_source_url(nil, config_script_src), :params => { :action => 'delete' }) expected = { 'success' => true, @@ -288,7 +288,7 @@ config_script_src = FactoryGirl.create(:configuration_script_source) api_basic_authorize collection_action_identifier(:configuration_script_sources, :delete, :post) - post(api_configuration_script_source_url(nil, config_script_src), :action => 'delete', :resource => params) + post(api_configuration_script_source_url(nil, config_script_src), :params => { :action => 'delete', :resource => params }) expected = { 'success' => false, @@ -301,7 +301,7 @@ it 'forbids configuration script source delete without an appropriate role' do api_basic_authorize - post(api_configuration_script_source_url(nil, config_script_src), :action => 'delete') + post(api_configuration_script_source_url(nil, config_script_src), :params => { :action => 'delete' }) expect(response).to have_http_status(:forbidden) end @@ -327,7 +327,7 @@ ) ] } - post(api_configuration_script_sources_url, create_params) + post(api_configuration_script_sources_url, :params => create_params) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) @@ -346,7 +346,7 @@ ) ] } - post(api_configuration_script_sources_url, create_params) + post(api_configuration_script_sources_url, :params => create_params) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) @@ -369,7 +369,7 @@ ) ] } - post(api_configuration_script_sources_url, :resources => [create_params, create_params]) + post(api_configuration_script_sources_url, :params => { :resources => [create_params, create_params] }) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) @@ -378,7 +378,7 @@ it 'requires a manager_resource to be specified' do api_basic_authorize collection_action_identifier(:configuration_script_sources, :create, :post) - post(api_configuration_script_sources_url, :resources => [create_params.except(:manager_resource)]) + post(api_configuration_script_sources_url, :params => { :resources => [create_params.except(:manager_resource)] }) expected = { 'results' => [{ @@ -394,7 +394,7 @@ api_basic_authorize collection_action_identifier(:configuration_script_sources, :create, :post) create_params[:manager_resource] = { :href => api_user_url(nil, 10) } - post(api_configuration_script_sources_url, :resources => [create_params]) + post(api_configuration_script_sources_url, :params => { :resources => [create_params] }) expected = { 'results' => [{ @@ -409,7 +409,7 @@ it 'forbids creation of new configuration script source without an appropriate role' do api_basic_authorize - post(api_configuration_script_sources_url, create_params) + post(api_configuration_script_sources_url, :params => create_params) expect(response).to have_http_status(:forbidden) end @@ -467,7 +467,7 @@ get( api_configuration_script_source_configuration_script_payloads_url(nil, config_script_src), - :filter => ["region_number=#{payload.region_number}"] + :params => { :filter => ["region_number=#{payload.region_number}"] } ) expected = { @@ -481,7 +481,7 @@ get( api_configuration_script_source_configuration_script_payloads_url(nil, config_script_src), - :filter => ["region_number=#{payload.region_number + 1}"] + :params => { :filter => ["region_number=#{payload.region_number + 1}"] } ) expected = { diff --git a/spec/requests/container_deployments_spec.rb b/spec/requests/container_deployments_spec.rb index 46771cbb57..b20c6a171d 100644 --- a/spec/requests/container_deployments_spec.rb +++ b/spec/requests/container_deployments_spec.rb @@ -16,7 +16,7 @@ it "creates container deployment with POST" do allow_any_instance_of(ContainerDeployment).to receive(:create_deployment).and_return(true) api_basic_authorize collection_action_identifier(:container_deployments, :create) - post(api_container_deployments_url, gen_request(:create, :example_data => true)) + post(api_container_deployments_url, :params => gen_request(:create, :example_data => true)) expect(response).to have_http_status(:ok) end end diff --git a/spec/requests/custom_actions_spec.rb b/spec/requests/custom_actions_spec.rb index 66ff758826..f31aad7616 100644 --- a/spec/requests/custom_actions_spec.rb +++ b/spec/requests/custom_actions_spec.rb @@ -98,7 +98,7 @@ def expect_result_to_have_custom_actions_hash api_basic_authorize(action_identifier(:services, :edit), action_identifier(:services, :read, :resource_actions, :get)) - get api_service_url(nil, svc1), :attributes => "custom_actions" + get api_service_url(nil, svc1), :params => { :attributes => "custom_actions" } expect_result_to_have_keys(%w(id href)) expect_result_to_have_custom_actions_hash @@ -108,7 +108,7 @@ def expect_result_to_have_custom_actions_hash api_basic_authorize(action_identifier(:services, :edit), action_identifier(:services, :read, :resource_actions, :get)) - get api_service_url(nil, svc1), :attributes => "custom_action_buttons" + get api_service_url(nil, svc1), :params => { :attributes => "custom_action_buttons" } expect_result_to_have_keys(%w(id href custom_action_buttons)) expect(response.parsed_body["custom_action_buttons"].size).to eq(3) @@ -135,7 +135,7 @@ def expect_result_to_have_custom_actions_hash it "supports the custom_actions attribute" do api_basic_authorize action_identifier(:service_templates, :read, :resource_actions, :get) - get api_service_template_url(nil, template1), :attributes => "custom_actions" + get api_service_template_url(nil, template1), :params => { :attributes => "custom_actions" } expect_result_to_have_keys(%w(id href)) expect_result_to_have_custom_actions_hash @@ -144,7 +144,7 @@ def expect_result_to_have_custom_actions_hash it "supports the custom_action_buttons attribute" do api_basic_authorize action_identifier(:service_templates, :read, :resource_actions, :get) - get api_service_template_url(nil, template1), :attributes => "custom_action_buttons" + get api_service_template_url(nil, template1), :params => { :attributes => "custom_action_buttons" } expect_result_to_have_keys(%w(id href custom_action_buttons)) expect(response.parsed_body["custom_action_buttons"].size).to eq(3) @@ -160,7 +160,7 @@ def expect_result_to_have_custom_actions_hash it "accepts a custom action" do api_basic_authorize - post(api_service_url(nil, svc1), gen_request(:button1, "button_key1" => "value", "button_key2" => "value")) + post(api_service_url(nil, svc1), :params => gen_request(:button1, "button_key1" => "value", "button_key2" => "value")) expect_single_action_result(:success => true, :message => /.*/, :href => api_service_url(nil, svc1.compressed_id)) end @@ -168,7 +168,7 @@ def expect_result_to_have_custom_actions_hash it "accepts a custom action as case insensitive" do api_basic_authorize - post(api_service_url(nil, svc1), gen_request(:BuTtOn1, "button_key1" => "value", "button_key2" => "value")) + post(api_service_url(nil, svc1), :params => gen_request(:BuTtOn1, "button_key1" => "value", "button_key2" => "value")) expect_single_action_result(:success => true, :message => /.*/, :href => api_service_url(nil, svc1.compressed_id)) end @@ -187,7 +187,7 @@ def expect_result_to_have_custom_actions_hash service = FactoryGirl.create(:service, :service_template => FactoryGirl.create(:service_template)) api_basic_authorize - post(api_service_url(nil, service), "action" => "test button") + post(api_service_url(nil, service), :params => { "action" => "test button" }) expect(response.parsed_body).to include("success" => true, "message" => /Invoked custom action test button/) end @@ -204,7 +204,7 @@ def expect_result_to_have_custom_actions_hash svc2 = FactoryGirl.create(:service, :name => "svc2", :service_template_id => template2.id) button2.resource_action = ra2 - get api_service_url(nil, svc2), :attributes => "custom_actions" + get api_service_url(nil, svc2), :params => { :attributes => "custom_actions" } expected = { "custom_actions" => { diff --git a/spec/requests/custom_attributes_spec.rb b/spec/requests/custom_attributes_spec.rb index 20fc700c7e..577b0de2ef 100644 --- a/spec/requests/custom_attributes_spec.rb +++ b/spec/requests/custom_attributes_spec.rb @@ -35,7 +35,7 @@ custom_attribute = FactoryGirl.create(:custom_attribute, :resource => provider, :name => 'foo', :value => 'bar') api_basic_authorize subcollection_action_identifier(:providers, :custom_attributes, :edit, :post) - post(api_provider_custom_attribute_url(nil, provider, custom_attribute), :action => :edit, :name => 'name1') + post(api_provider_custom_attribute_url(nil, provider, custom_attribute), :params => { :action => :edit, :name => 'name1' }) expect(response).to have_http_status(:ok) expect(response.parsed_body['href']).to include(api_provider_custom_attribute_url(nil, provider.compressed_id, custom_attribute.compressed_id)) diff --git a/spec/requests/events_spec.rb b/spec/requests/events_spec.rb index bc0898bc75..2337d87f1d 100644 --- a/spec/requests/events_spec.rb +++ b/spec/requests/events_spec.rb @@ -48,7 +48,7 @@ def create_events(count) api_basic_authorize collection_action_identifier(:events, :read, :get) create_events(3) - get api_events_url, :expand => "resources" + get api_events_url, :params => { :expand => "resources" } expect_query_result(:events, 3, 3) expect_result_resources_to_include_data("resources", "guid" => miq_event_guid_list) @@ -77,7 +77,7 @@ def relate_events_to(policy) create_events(3) relate_events_to(policy) - get api_policy_events_url(nil, policy), :expand => "resources" + get api_policy_events_url(nil, policy), :params => { :expand => "resources" } expect_query_result(:events, 3, 3) expect_result_resources_to_include_data("resources", "guid" => miq_event_guid_list) @@ -88,7 +88,7 @@ def relate_events_to(policy) create_events(3) relate_events_to(policy) - get api_policy_url(nil, policy), :expand => "events" + get api_policy_url(nil, policy), :params => { :expand => "events" } expect_single_resource_query("name" => policy.name, "description" => policy.description, "guid" => policy.guid) expect_result_resources_to_include_data("events", "guid" => miq_event_guid_list) diff --git a/spec/requests/floating_ips_spec.rb b/spec/requests/floating_ips_spec.rb index 7c71b0df63..bbbfc1ead0 100644 --- a/spec/requests/floating_ips_spec.rb +++ b/spec/requests/floating_ips_spec.rb @@ -50,7 +50,7 @@ describe 'POST /api/floating_ips' do it 'forbids access to floating ips without an appropriate role' do api_basic_authorize - post(api_floating_ips_url, gen_request(:query, "")) + post(api_floating_ips_url, :params => gen_request(:query, "")) expect(response).to have_http_status(:forbidden) end end diff --git a/spec/requests/generic_object_definitions_spec.rb b/spec/requests/generic_object_definitions_spec.rb index 80258be72b..5567f87395 100644 --- a/spec/requests/generic_object_definitions_spec.rb +++ b/spec/requests/generic_object_definitions_spec.rb @@ -96,7 +96,7 @@ ] } } - post(api_generic_object_definitions_url, object_definition) + post(api_generic_object_definitions_url, :params => object_definition) expect(response).to have_http_status(:ok) expect(response.parsed_body['results'].first).to include(object_definition) @@ -114,7 +114,7 @@ } } } - post(api_generic_object_definitions_url, request) + post(api_generic_object_definitions_url, :params => request) expected = { 'error' => a_hash_including( @@ -139,7 +139,7 @@ { 'href' => api_generic_object_definition_url(nil, object_def3.compressed_id), 'resource' => { 'name' => 'updated 3' }} ] } - post(api_generic_object_definitions_url, request) + post(api_generic_object_definitions_url, :params => request) expected = { 'results' => a_collection_including( @@ -176,7 +176,7 @@ ] } } - post(api_generic_object_definition_url(nil, object_def.name), request) + post(api_generic_object_definition_url(nil, object_def.name), :params => request) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include(request.except('action')) @@ -204,7 +204,7 @@ ] } } - post(api_generic_object_definition_url(nil, object_def.compressed_id), request) + post(api_generic_object_definition_url(nil, object_def.compressed_id), :params => request) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include(request.except('action')) @@ -221,7 +221,7 @@ } } } - post(api_generic_object_definition_url(nil, object_def.compressed_id), request) + post(api_generic_object_definition_url(nil, object_def.compressed_id), :params => request) expected = { 'error' => a_hash_including( @@ -236,7 +236,7 @@ it 'can delete an object definition by name' do api_basic_authorize action_identifier(:generic_object_definitions, :delete) - post(api_generic_object_definition_url(nil, object_def.name), :action => 'delete') + post(api_generic_object_definition_url(nil, object_def.name), :params => { :action => 'delete' }) expect(response).to have_http_status(:ok) end @@ -244,7 +244,7 @@ it 'can delete an object definition by id' do api_basic_authorize action_identifier(:generic_object_definitions, :delete) - post(api_generic_object_definition_url(nil, object_def.compressed_id), :action => 'delete') + post(api_generic_object_definition_url(nil, object_def.compressed_id), :params => { :action => 'delete' }) expect(response).to have_http_status(:ok) end @@ -253,7 +253,7 @@ api_basic_authorize action_identifier(:generic_object_definitions, :delete, :resource_actions, :delete) object_def.create_object(:name => 'foo object') - post(api_generic_object_definition_url(nil, object_def.name), :action => 'delete') + post(api_generic_object_definition_url(nil, object_def.name), :params => { :action => 'delete' }) expected = { 'error' => a_hash_including( @@ -278,7 +278,7 @@ { 'href' => api_generic_object_definition_url(nil, object_def3.compressed_id)} ] } - post(api_generic_object_definitions_url, request) + post(api_generic_object_definitions_url, :params => request) expected = { 'results' => a_collection_including( @@ -318,7 +318,7 @@ 'name' => 'LoadBalancer Updated', 'description' => 'LoadBalancer description Updated' } - put(api_generic_object_definition_url(nil, object_def.name), request) + put(api_generic_object_definition_url(nil, object_def.name), :params => request) expected = { 'name' => 'LoadBalancer Updated', diff --git a/spec/requests/groups_spec.rb b/spec/requests/groups_spec.rb index d97e4de771..26e55ef980 100644 --- a/spec/requests/groups_spec.rb +++ b/spec/requests/groups_spec.rb @@ -25,7 +25,7 @@ it "rejects creation without appropriate role" do api_basic_authorize - post(api_groups_url, sample_group1) + post(api_groups_url, :params => sample_group1) expect(response).to have_http_status(:forbidden) end @@ -33,7 +33,7 @@ it "rejects group creation with id specified" do api_basic_authorize collection_action_identifier(:groups, :create) - post(api_groups_url, "description" => "sample group", "id" => 100) + post(api_groups_url, :params => { "description" => "sample group", "id" => 100 }) expect_bad_request(/id or href should not be specified/i) end @@ -41,7 +41,7 @@ it "rejects group creation with invalid role specified" do api_basic_authorize collection_action_identifier(:groups, :create) - post(api_groups_url, "description" => "sample group", "role" => {"id" => 999_999}) + post(api_groups_url, :params => { "description" => "sample group", "role" => {"id" => 999_999} }) expect(response).to have_http_status(:not_found) end @@ -49,7 +49,7 @@ it "rejects group creation with invalid tenant specified" do api_basic_authorize collection_action_identifier(:groups, :create) - post(api_groups_url, "description" => "sample group", "tenant" => {"id" => 999_999}) + post(api_groups_url, :params => { "description" => "sample group", "tenant" => {"id" => 999_999} }) expect(response).to have_http_status(:not_found) end @@ -57,7 +57,7 @@ it "rejects group creation with invalid filters specified" do api_basic_authorize collection_action_identifier(:groups, :create) - post(api_groups_url, "description" => "sample group", "filters" => {"bogus" => %w(f1 f2)}) + post(api_groups_url, :params => { "description" => "sample group", "filters" => {"bogus" => %w(f1 f2)} }) expect_bad_request(/Invalid filter/i) end @@ -65,7 +65,7 @@ it "supports single group creation" do api_basic_authorize collection_action_identifier(:groups, :create) - post(api_groups_url, sample_group1) + post(api_groups_url, :params => sample_group1) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_attributes) @@ -77,7 +77,7 @@ it "supports single group creation via action" do api_basic_authorize collection_action_identifier(:groups, :create) - post(api_groups_url, gen_request(:create, sample_group1)) + post(api_groups_url, :params => gen_request(:create, sample_group1)) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_attributes) @@ -89,10 +89,10 @@ it "supports single group creation via action with role and tenant specified" do api_basic_authorize collection_action_identifier(:groups, :create) - post(api_groups_url, gen_request(:create, - "description" => "sample_group3", - "role" => {"name" => role3.name}, - "tenant" => {"href" => api_tenant_url(nil, tenant3)})) + post(api_groups_url, :params => gen_request(:create, + "description" => "sample_group3", + "role" => {"name" => role3.name}, + "tenant" => {"href" => api_tenant_url(nil, tenant3)})) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_attributes) @@ -117,7 +117,7 @@ "belongsto" => ["/managed/infra/1", "/managed/infra/2"], } } - post(api_groups_url, gen_request(:create, sample_group)) + post(api_groups_url, :params => gen_request(:create, sample_group)) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_attributes) @@ -133,7 +133,7 @@ it "supports multiple group creation" do api_basic_authorize collection_action_identifier(:groups, :create) - post(api_groups_url, gen_request(:create, [sample_group1, sample_group2])) + post(api_groups_url, :params => gen_request(:create, [sample_group1, sample_group2])) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_attributes) @@ -149,9 +149,9 @@ describe "groups edit" do it "rejects group edits without appropriate role" do api_basic_authorize - post(api_groups_url, gen_request(:edit, - "description" => "updated_group", - "href" => api_group_url(nil, group1))) + post(api_groups_url, :params => gen_request(:edit, + "description" => "updated_group", + "href" => api_group_url(nil, group1))) expect(response).to have_http_status(:forbidden) end @@ -159,7 +159,7 @@ it "rejects group edits for invalid resources" do api_basic_authorize collection_action_identifier(:groups, :edit) - post(api_group_url(nil, 999_999), gen_request(:edit, "description" => "updated_group")) + post(api_group_url(nil, 999_999), :params => gen_request(:edit, "description" => "updated_group")) expect(response).to have_http_status(:not_found) end @@ -167,7 +167,7 @@ it "supports single group edit" do api_basic_authorize collection_action_identifier(:groups, :edit) - post(api_group_url(nil, group1), gen_request(:edit, "description" => "updated_group")) + post(api_group_url(nil, group1), :params => gen_request(:edit, "description" => "updated_group")) expect_single_resource_query("id" => group1.compressed_id, "description" => "updated_group") @@ -177,9 +177,9 @@ it "supports multiple group edits" do api_basic_authorize collection_action_identifier(:groups, :edit) - post(api_groups_url, gen_request(:edit, - [{"href" => api_group_url(nil, group1), "description" => "updated_group1"}, - {"href" => api_group_url(nil, group2), "description" => "updated_group2"}])) + post(api_groups_url, :params => gen_request(:edit, + [{"href" => api_group_url(nil, group1), "description" => "updated_group1"}, + {"href" => api_group_url(nil, group2), "description" => "updated_group2"}])) expect_results_to_match_hash("results", [{"id" => group1.compressed_id, "description" => "updated_group1"}, @@ -194,7 +194,7 @@ it "rejects group deletion, by post action, without appropriate role" do api_basic_authorize - post(api_groups_url, gen_request(:delete, "description" => "group_description", "href" => api_group_url(nil, 100))) + post(api_groups_url, :params => gen_request(:delete, "description" => "group_description", "href" => api_group_url(nil, 100))) expect(response).to have_http_status(:forbidden) end @@ -239,7 +239,7 @@ g1_id = group1.id g1_url = api_group_url(nil, g1_id) - post(g1_url, gen_request(:delete)) + post(g1_url, :params => gen_request(:delete)) expect_single_action_result(:success => true, :message => "deleting", :href => api_group_url(nil, group1.compressed_id)) expect(MiqGroup.exists?(g1_id)).to be_falsey @@ -251,7 +251,7 @@ g1_id, g2_id = group1.id, group2.id g1_url, g2_url = api_group_url(nil, g1_id), api_group_url(nil, g2_id) - post(api_groups_url, gen_request(:delete, [{"href" => g1_url}, {"href" => g2_url}])) + post(api_groups_url, :params => gen_request(:delete, [{"href" => g1_url}, {"href" => g2_url}])) expect_multiple_action_result(2) expect_result_resources_to_include_hrefs("results", [api_group_url(nil, group1.compressed_id), api_group_url(nil, group2.compressed_id)]) @@ -278,7 +278,7 @@ FactoryGirl.create(:classification_department_with_tags) api_basic_authorize(subcollection_action_identifier(:groups, :tags, :assign)) - post(api_group_tags_url(nil, group), :action => "assign", :category => "department", :name => "finance") + post(api_group_tags_url(nil, group), :params => { :action => "assign", :category => "department", :name => "finance" }) expected = { "results" => [ @@ -300,7 +300,7 @@ Classification.classify(group, "department", "finance") api_basic_authorize(subcollection_action_identifier(:groups, :tags, :unassign)) - post(api_group_tags_url(nil, group), :action => "unassign", :category => "department", :name => "finance") + post(api_group_tags_url(nil, group), :params => { :action => "unassign", :category => "department", :name => "finance" }) expected = { "results" => [ diff --git a/spec/requests/hosts_spec.rb b/spec/requests/hosts_spec.rb index c67e90643b..595a970a0c 100644 --- a/spec/requests/hosts_spec.rb +++ b/spec/requests/hosts_spec.rb @@ -7,7 +7,7 @@ options = {:credentials => {:authtype => "default", :password => "abc123"}} expect do - post api_host_url(nil, host), gen_request(:edit, options) + post api_host_url(nil, host), :params => gen_request(:edit, options) end.to change { host.reload.authentication_password(:default) }.to("abc123") expect(response).to have_http_status(:ok) end @@ -18,7 +18,7 @@ options = {:credentials => {:password => "abc123"}} expect do - post api_host_url(nil, host), gen_request(:edit, options) + post api_host_url(nil, host), :params => gen_request(:edit, options) end.to change { host.reload.authentication_password(:default) }.to("abc123") expect(response).to have_http_status(:ok) end @@ -29,7 +29,7 @@ options = {:name => "new name"} expect do - post api_host_url(nil, host), gen_request(:edit, options) + post api_host_url(nil, host), :params => gen_request(:edit, options) end.not_to change { host.reload.name } expect(response).to have_http_status(:bad_request) end @@ -43,7 +43,7 @@ {:href => api_host_url(nil, host2), :credentials => {:password => "def456"}} ] - post api_hosts_url, gen_request(:edit, options) + post api_hosts_url, :params => gen_request(:edit, options) expect(response).to have_http_status(:ok) expect(host1.reload.authentication_password(:default)).to eq("abc123") expect(host2.reload.authentication_password(:default)).to eq("def456") @@ -58,7 +58,7 @@ {:id => host2.id, :credentials => {:password => "def456"}} ] - post api_hosts_url, gen_request(:edit, options) + post api_hosts_url, :params => gen_request(:edit, options) expect(response).to have_http_status(:ok) expect(host1.reload.authentication_password(:default)).to eq("abc123") expect(host2.reload.authentication_password(:default)).to eq("def456") @@ -72,7 +72,7 @@ options = {:credentials => {:authtype => "default", :password => "abc123"}} expect do - post api_host_url(nil, host), gen_request(:edit, options) + post api_host_url(nil, host), :params => gen_request(:edit, options) end.not_to change { host.reload.authentication_password(:default) } expect(response).to have_http_status(:forbidden) end diff --git a/spec/requests/instances_spec.rb b/spec/requests/instances_spec.rb index 292a57e67b..2e91797b0e 100644 --- a/spec/requests/instances_spec.rb +++ b/spec/requests/instances_spec.rb @@ -32,7 +32,7 @@ def update_raw_power_state(state, *instances) it "responds not found for an invalid instance" do api_basic_authorize action_identifier(:instances, :terminate) - post(invalid_instance_url, gen_request(:terminate)) + post(invalid_instance_url, :params => gen_request(:terminate)) expect(response).to have_http_status(:not_found) end @@ -40,7 +40,7 @@ def update_raw_power_state(state, *instances) it "responds forbidden for an invalid instance without appropriate role" do api_basic_authorize - post(invalid_instance_url, gen_request(:terminate)) + post(invalid_instance_url, :params => gen_request(:terminate)) expect(response).to have_http_status(:forbidden) end @@ -48,7 +48,7 @@ def update_raw_power_state(state, *instances) it "terminates a single valid Instance" do api_basic_authorize action_identifier(:instances, :terminate) - post(instance_url, gen_request(:terminate)) + post(instance_url, :params => gen_request(:terminate)) expect_single_action_result( :success => true, @@ -60,7 +60,7 @@ def update_raw_power_state(state, *instances) it "terminates multiple valid Instances" do api_basic_authorize collection_action_identifier(:instances, :terminate) - post(api_instances_url, gen_request(:terminate, [{"href" => instance1_url}, {"href" => instance2_url}])) + post(api_instances_url, :params => gen_request(:terminate, [{"href" => instance1_url}, {"href" => instance2_url}])) expected = { "results" => a_collection_containing_exactly( @@ -85,7 +85,7 @@ def update_raw_power_state(state, *instances) it "responds not found for an invalid instance" do api_basic_authorize action_identifier(:instances, :stop) - post(invalid_instance_url, gen_request(:stop)) + post(invalid_instance_url, :params => gen_request(:stop)) expect(response).to have_http_status(:not_found) end @@ -93,7 +93,7 @@ def update_raw_power_state(state, *instances) it "stopping an invalid instance without appropriate role is forbidden" do api_basic_authorize - post(invalid_instance_url, gen_request(:stop)) + post(invalid_instance_url, :params => gen_request(:stop)) expect(response).to have_http_status(:forbidden) end @@ -102,7 +102,7 @@ def update_raw_power_state(state, *instances) api_basic_authorize action_identifier(:instances, :stop) update_raw_power_state("poweredOff", instance) - post(instance_url, gen_request(:stop)) + post(instance_url, :params => gen_request(:stop)) expect_single_action_result(:success => false, :message => "is not powered on", :href => api_instance_url(nil, instance.compressed_id)) end @@ -110,7 +110,7 @@ def update_raw_power_state(state, *instances) it "stops a valid instance" do api_basic_authorize action_identifier(:instances, :stop) - post(instance_url, gen_request(:stop)) + post(instance_url, :params => gen_request(:stop)) expect_single_action_result(:success => true, :message => "stopping", :href => api_instance_url(nil, instance.compressed_id), :task => true) end @@ -118,7 +118,7 @@ def update_raw_power_state(state, *instances) it "stops multiple valid instances" do api_basic_authorize action_identifier(:instances, :stop) - post(api_instances_url, gen_request(:stop, nil, instance1_url, instance2_url)) + post(api_instances_url, :params => gen_request(:stop, nil, instance1_url, instance2_url)) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_instance_url(nil, instance1.compressed_id), api_instance_url(nil, instance2.compressed_id)]) @@ -129,7 +129,7 @@ def update_raw_power_state(state, *instances) it "responds not found for an invalid instance" do api_basic_authorize action_identifier(:instances, :start) - post(invalid_instance_url, gen_request(:start)) + post(invalid_instance_url, :params => gen_request(:start)) expect(response).to have_http_status(:not_found) end @@ -137,7 +137,7 @@ def update_raw_power_state(state, *instances) it "starting an invalid instance without appropriate role is forbidden" do api_basic_authorize - post(invalid_instance_url, gen_request(:start)) + post(invalid_instance_url, :params => gen_request(:start)) expect(response).to have_http_status(:forbidden) end @@ -145,7 +145,7 @@ def update_raw_power_state(state, *instances) it "fails to start a powered on instance" do api_basic_authorize action_identifier(:instances, :start) - post(instance_url, gen_request(:start)) + post(instance_url, :params => gen_request(:start)) expect_single_action_result(:success => false, :message => "is powered on", :href => api_instance_url(nil, instance.compressed_id)) end @@ -154,7 +154,7 @@ def update_raw_power_state(state, *instances) api_basic_authorize action_identifier(:instances, :start) update_raw_power_state("poweredOff", instance) - post(instance_url, gen_request(:start)) + post(instance_url, :params => gen_request(:start)) expect_single_action_result(:success => true, :message => "starting", :href => api_instance_url(nil, instance.compressed_id), :task => true) end @@ -163,7 +163,7 @@ def update_raw_power_state(state, *instances) api_basic_authorize action_identifier(:instances, :start) update_raw_power_state("poweredOff", instance1, instance2) - post(api_instances_url, gen_request(:start, nil, instance1_url, instance2_url)) + post(api_instances_url, :params => gen_request(:start, nil, instance1_url, instance2_url)) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_instance_url(nil, instance1.compressed_id), api_instance_url(nil, instance2.compressed_id)]) @@ -174,7 +174,7 @@ def update_raw_power_state(state, *instances) it "responds not found for an invalid instance" do api_basic_authorize action_identifier(:instances, :pause) - post(invalid_instance_url, gen_request(:pause)) + post(invalid_instance_url, :params => gen_request(:pause)) expect(response).to have_http_status(:not_found) end @@ -182,7 +182,7 @@ def update_raw_power_state(state, *instances) it "pausing an invalid instance without appropriate role is forbidden" do api_basic_authorize - post(invalid_instance_url, gen_request(:pause)) + post(invalid_instance_url, :params => gen_request(:pause)) expect(response).to have_http_status(:forbidden) end @@ -191,7 +191,7 @@ def update_raw_power_state(state, *instances) api_basic_authorize action_identifier(:instances, :pause) update_raw_power_state("poweredOff", instance) - post(instance_url, gen_request(:pause)) + post(instance_url, :params => gen_request(:pause)) expect_single_action_result(:success => false, :message => "is not powered on", :href => api_instance_url(nil, instance.compressed_id)) end @@ -200,7 +200,7 @@ def update_raw_power_state(state, *instances) api_basic_authorize action_identifier(:instances, :pause) update_raw_power_state("paused", instance) - post(instance_url, gen_request(:pause)) + post(instance_url, :params => gen_request(:pause)) expect_single_action_result(:success => false, :message => "is not powered on", :href => api_instance_url(nil, instance.compressed_id)) end @@ -208,7 +208,7 @@ def update_raw_power_state(state, *instances) it "pauses an instance" do api_basic_authorize action_identifier(:instances, :pause) - post(instance_url, gen_request(:pause)) + post(instance_url, :params => gen_request(:pause)) expect_single_action_result(:success => true, :message => "pausing", :href => api_instance_url(nil, instance.compressed_id), :task => true) end @@ -216,7 +216,7 @@ def update_raw_power_state(state, *instances) it "pauses multiple instances" do api_basic_authorize action_identifier(:instances, :pause) - post(api_instances_url, gen_request(:pause, nil, instance1_url, instance2_url)) + post(api_instances_url, :params => gen_request(:pause, nil, instance1_url, instance2_url)) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_instance_url(nil, instance1.compressed_id), api_instance_url(nil, instance2.compressed_id)]) @@ -227,7 +227,7 @@ def update_raw_power_state(state, *instances) it "responds not found for an invalid instance" do api_basic_authorize action_identifier(:instances, :suspend) - post(invalid_instance_url, gen_request(:suspend)) + post(invalid_instance_url, :params => gen_request(:suspend)) expect(response).to have_http_status(:not_found) end @@ -235,7 +235,7 @@ def update_raw_power_state(state, *instances) it "responds forbidden for an invalid instance without appropriate role" do api_basic_authorize - post(invalid_instance_url, gen_request(:suspend)) + post(invalid_instance_url, :params => gen_request(:suspend)) expect(response).to have_http_status(:forbidden) end @@ -244,7 +244,7 @@ def update_raw_power_state(state, *instances) api_basic_authorize action_identifier(:instances, :suspend) update_raw_power_state("poweredOff", instance) - post(instance_url, gen_request(:suspend)) + post(instance_url, :params => gen_request(:suspend)) expect_single_action_result(:success => false, :message => "is not powered on", :href => api_instance_url(nil, instance.compressed_id)) end @@ -253,7 +253,7 @@ def update_raw_power_state(state, *instances) api_basic_authorize action_identifier(:instances, :suspend) update_raw_power_state("suspended", instance) - post(instance_url, gen_request(:suspend)) + post(instance_url, :params => gen_request(:suspend)) expect_single_action_result(:success => false, :message => "is not powered on", :href => api_instance_url(nil, instance.compressed_id)) end @@ -261,7 +261,7 @@ def update_raw_power_state(state, *instances) it "suspends an instance" do api_basic_authorize action_identifier(:instances, :suspend) - post(instance_url, gen_request(:suspend)) + post(instance_url, :params => gen_request(:suspend)) expect_single_action_result(:success => true, :message => "suspending", :href => api_instance_url(nil, instance.compressed_id), :task => true) end @@ -269,7 +269,7 @@ def update_raw_power_state(state, *instances) it "suspends multiple instances" do api_basic_authorize action_identifier(:instances, :suspend) - post(api_instances_url, gen_request(:suspend, nil, instance1_url, instance2_url)) + post(api_instances_url, :params => gen_request(:suspend, nil, instance1_url, instance2_url)) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_instance_url(nil, instance1.compressed_id), api_instance_url(nil, instance2.compressed_id)]) @@ -280,7 +280,7 @@ def update_raw_power_state(state, *instances) it "responds not found for an invalid instance" do api_basic_authorize action_identifier(:instances, :shelve) - post(invalid_instance_url, gen_request(:shelve)) + post(invalid_instance_url, :params => gen_request(:shelve)) expect(response).to have_http_status(:not_found) end @@ -288,7 +288,7 @@ def update_raw_power_state(state, *instances) it "responds forbidden for an invalid instance without appropriate role" do api_basic_authorize - post(invalid_instance_url, gen_request(:shelve)) + post(invalid_instance_url, :params => gen_request(:shelve)) expect(response).to have_http_status(:forbidden) end @@ -297,7 +297,7 @@ def update_raw_power_state(state, *instances) api_basic_authorize action_identifier(:instances, :shelve) update_raw_power_state("SHUTOFF", instance) - post(instance_url, gen_request(:shelve)) + post(instance_url, :params => gen_request(:shelve)) expect_single_action_result(:success => true, :message => 'shelving', :href => api_instance_url(nil, instance.compressed_id)) end @@ -306,7 +306,7 @@ def update_raw_power_state(state, *instances) api_basic_authorize action_identifier(:instances, :shelve) update_raw_power_state("SUSPENDED", instance) - post(instance_url, gen_request(:shelve)) + post(instance_url, :params => gen_request(:shelve)) expect_single_action_result(:success => true, :message => 'shelving', :href => api_instance_url(nil, instance.compressed_id)) end @@ -315,7 +315,7 @@ def update_raw_power_state(state, *instances) api_basic_authorize action_identifier(:instances, :shelve) update_raw_power_state("PAUSED", instance) - post(instance_url, gen_request(:shelve)) + post(instance_url, :params => gen_request(:shelve)) expect_single_action_result(:success => true, :message => 'shelving', :href => api_instance_url(nil, instance.compressed_id)) end @@ -324,7 +324,7 @@ def update_raw_power_state(state, *instances) api_basic_authorize action_identifier(:instances, :shelve) update_raw_power_state("SHELVED", instance) - post(instance_url, gen_request(:shelve)) + post(instance_url, :params => gen_request(:shelve)) expect_single_action_result( :success => false, @@ -336,7 +336,7 @@ def update_raw_power_state(state, *instances) it "shelves an instance" do api_basic_authorize action_identifier(:instances, :shelve) - post(instance_url, gen_request(:shelve)) + post(instance_url, :params => gen_request(:shelve)) expect_single_action_result(:success => true, :message => "shelving", @@ -347,7 +347,7 @@ def update_raw_power_state(state, *instances) it "shelves multiple instances" do api_basic_authorize action_identifier(:instances, :shelve) - post(api_instances_url, gen_request(:shelve, nil, instance1_url, instance2_url)) + post(api_instances_url, :params => gen_request(:shelve, nil, instance1_url, instance2_url)) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_instance_url(nil, instance1.compressed_id), api_instance_url(nil, instance2.compressed_id)]) @@ -358,7 +358,7 @@ def update_raw_power_state(state, *instances) it "responds not found for an invalid instance" do api_basic_authorize action_identifier(:instances, :reboot_guest) - post(invalid_instance_url, gen_request(:reboot_guest)) + post(invalid_instance_url, :params => gen_request(:reboot_guest)) expect(response).to have_http_status(:not_found) end @@ -366,7 +366,7 @@ def update_raw_power_state(state, *instances) it "responds forbidden for an invalid instance without appropriate role" do api_basic_authorize - post(invalid_instance_url, gen_request(:reboot_guest)) + post(invalid_instance_url, :params => gen_request(:reboot_guest)) expect(response).to have_http_status(:forbidden) end @@ -375,7 +375,7 @@ def update_raw_power_state(state, *instances) api_basic_authorize action_identifier(:instances, :reboot_guest) update_raw_power_state("poweredOff", instance) - post(instance_url, gen_request(:reboot_guest)) + post(instance_url, :params => gen_request(:reboot_guest)) expect_single_action_result(:success => false, :message => "is not powered on", :href => api_instance_url(nil, instance.compressed_id)) end @@ -383,7 +383,7 @@ def update_raw_power_state(state, *instances) it "reboots a valid instance" do api_basic_authorize action_identifier(:instances, :reboot_guest) - post(instance_url, gen_request(:reboot_guest)) + post(instance_url, :params => gen_request(:reboot_guest)) expect_single_action_result(:success => true, :message => "rebooting", :href => api_instance_url(nil, instance.compressed_id), :task => true) end @@ -391,7 +391,7 @@ def update_raw_power_state(state, *instances) it "reboots multiple valid instances" do api_basic_authorize action_identifier(:instances, :reboot_guest) - post(api_instances_url, gen_request(:reboot_guest, nil, instance1_url, instance2_url)) + post(api_instances_url, :params => gen_request(:reboot_guest, nil, instance1_url, instance2_url)) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_instance_url(nil, instance1.compressed_id), api_instance_url(nil, instance2.compressed_id)]) @@ -402,7 +402,7 @@ def update_raw_power_state(state, *instances) it "responds not found for an invalid instance" do api_basic_authorize action_identifier(:instances, :reset) - post(invalid_instance_url, gen_request(:reset)) + post(invalid_instance_url, :params => gen_request(:reset)) expect(response).to have_http_status(:not_found) end @@ -410,7 +410,7 @@ def update_raw_power_state(state, *instances) it "responds forbidden for an invalid instance without appropriate role" do api_basic_authorize - post(invalid_instance_url, gen_request(:reset)) + post(invalid_instance_url, :params => gen_request(:reset)) expect(response).to have_http_status(:forbidden) end @@ -419,7 +419,7 @@ def update_raw_power_state(state, *instances) api_basic_authorize action_identifier(:instances, :reset) update_raw_power_state("poweredOff", instance) - post(instance_url, gen_request(:reset)) + post(instance_url, :params => gen_request(:reset)) expect_single_action_result(:success => false, :message => "is not powered on", :href => api_instance_url(nil, instance.compressed_id)) end @@ -427,7 +427,7 @@ def update_raw_power_state(state, *instances) it "resets a valid instance" do api_basic_authorize action_identifier(:instances, :reset) - post(instance_url, gen_request(:reset)) + post(instance_url, :params => gen_request(:reset)) expect_single_action_result(:success => true, :message => "resetting", :href => api_instance_url(nil, instance.compressed_id), :task => true) end @@ -435,7 +435,7 @@ def update_raw_power_state(state, *instances) it "resets multiple valid instances" do api_basic_authorize action_identifier(:instances, :reset) - post(api_instances_url, gen_request(:reset, nil, instance1_url, instance2_url)) + post(api_instances_url, :params => gen_request(:reset, nil, instance1_url, instance2_url)) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_instance_url(nil, instance1.compressed_id), api_instance_url(nil, instance2.compressed_id)]) diff --git a/spec/requests/logging_spec.rb b/spec/requests/logging_spec.rb index 08785b210a..8e61e72a2e 100644 --- a/spec/requests/logging_spec.rb +++ b/spec/requests/logging_spec.rb @@ -37,7 +37,7 @@ it "filters password attributes in nested parameters" do api_basic_authorize collection_action_identifier(:services, :create) - post(api_services_url, gen_request(:create, "name" => "new_service_1", "options" => { "password" => "SECRET" })) + post(api_services_url, :params => gen_request(:create, "name" => "new_service_1", "options" => { "password" => "SECRET" })) expect(@log.string).to include( 'Parameters: {"action"=>"update", "controller"=>"api/services", "format"=>"json", ' \ diff --git a/spec/requests/metric_rollups_spec.rb b/spec/requests/metric_rollups_spec.rb index 2383019fec..738b789ae4 100644 --- a/spec/requests/metric_rollups_spec.rb +++ b/spec/requests/metric_rollups_spec.rb @@ -9,7 +9,7 @@ it 'returns metric_rollups for a specific resource_type' do api_basic_authorize collection_action_identifier(:metric_rollups, :read, :get) - get api_metric_rollups_url, :resource_type => 'VmOrTemplate', :capture_interval => 'hourly', :start_date => Time.zone.today.to_s + get api_metric_rollups_url, :params => { :resource_type => 'VmOrTemplate', :capture_interval => 'hourly', :start_date => Time.zone.today.to_s } expected = { 'count' => 3, @@ -24,10 +24,15 @@ vm_metric = FactoryGirl.create(:metric_rollup_vm_hr, :resource => vm) api_basic_authorize collection_action_identifier(:metric_rollups, :read, :get) - get api_metric_rollups_url, :resource_type => 'VmOrTemplate', - :resource_ids => [vm.id], - :capture_interval => 'hourly', - :start_date => Time.zone.today.to_s + get( + api_metric_rollups_url, + :params => { + :resource_type => 'VmOrTemplate', + :resource_ids => [vm.id], + :capture_interval => 'hourly', + :start_date => Time.zone.today.to_s + } + ) expected = { 'count' => 4, @@ -46,10 +51,15 @@ vm_daily = FactoryGirl.create(:metric_rollup_vm_daily, :resource => vm) api_basic_authorize collection_action_identifier(:metric_rollups, :read, :get) - get api_metric_rollups_url, :resource_type => 'VmOrTemplate', - :resource_ids => [vm.id], - :capture_interval => 'daily', - :start_date => Time.zone.today.to_s + get( + api_metric_rollups_url, + :params => { + :resource_type => 'VmOrTemplate', + :resource_ids => [vm.id], + :capture_interval => 'daily', + :start_date => Time.zone.today.to_s + } + ) expected = { 'count' => 5, @@ -79,9 +89,14 @@ it 'pages the request by default' do api_basic_authorize collection_action_identifier(:metric_rollups, :read, :get) - get api_metric_rollups_url, :resource_type => 'VmOrTemplate', - :capture_interval => 'daily', - :start_date => Time.zone.today.to_s + get( + api_metric_rollups_url, + :params => { + :resource_type => 'VmOrTemplate', + :capture_interval => 'daily', + :start_date => Time.zone.today.to_s + } + ) expected = { 'count' => 3, 'subcount' => 1, @@ -95,9 +110,14 @@ it 'validates that the capture interval is valid' do api_basic_authorize collection_action_identifier(:metric_rollups, :read, :get) - get api_metric_rollups_url, :resource_type => 'VmOrTemplate', - :start_date => Time.zone.today.to_s, - :capture_interval => 'bad_interval' + get( + api_metric_rollups_url, + :params => { + :resource_type => 'VmOrTemplate', + :start_date => Time.zone.today.to_s, + :capture_interval => 'bad_interval' + } + ) expected = { 'error' => a_hash_including( @@ -114,11 +134,16 @@ FactoryGirl.create_list(:metric_rollup_vm_hr, 3, :resource => vm) api_basic_authorize collection_action_identifier(:metric_rollups, :read, :get) - get api_metric_rollups_url, :resource_type => 'VmOrTemplate', - :resource_ids => [vm.id], - :capture_interval => 'hourly', - :start_date => Time.zone.today.to_s, - :limit => 1 + get( + api_metric_rollups_url, + :params => { + :resource_type => 'VmOrTemplate', + :resource_ids => [vm.id], + :capture_interval => 'hourly', + :start_date => Time.zone.today.to_s, + :limit => 1 + } + ) expected = { 'count' => 6, diff --git a/spec/requests/network_routers_spec.rb b/spec/requests/network_routers_spec.rb index 2c32172ce9..95002d4965 100644 --- a/spec/requests/network_routers_spec.rb +++ b/spec/requests/network_routers_spec.rb @@ -44,7 +44,7 @@ describe 'POST /api/network_routers' do it 'forbids access to network routers without an appropriate role' do api_basic_authorize - post(api_network_routers_url, gen_request(:query, "")) + post(api_network_routers_url, :params => gen_request(:query, "")) expect(response).to have_http_status(:forbidden) end end diff --git a/spec/requests/notifications_spec.rb b/spec/requests/notifications_spec.rb index 565929ae7f..4b0a55901f 100644 --- a/spec/requests/notifications_spec.rb +++ b/spec/requests/notifications_spec.rb @@ -10,7 +10,7 @@ it 'is not supported' do api_basic_authorize - post(api_notifications_url, gen_request(:create, :notification_id => 1, :user_id => 1)) + post(api_notifications_url, :params => gen_request(:create, :notification_id => 1, :user_id => 1)) expect_bad_request(/Unsupported Action create/i) end end @@ -36,7 +36,7 @@ it 'is not supported' do api_basic_authorize - post(api_notifications_url, gen_request(:edit, :user_id => 1, :href => notification_url)) + post(api_notifications_url, :params => gen_request(:edit, :user_id => 1, :href => notification_url)) expect_bad_request(/Unsupported Action edit/i) end end @@ -46,7 +46,7 @@ it 'deletes notification using POST' do api_basic_authorize - post(notification_url, gen_request(:delete)) + post(notification_url, :params => gen_request(:delete)) expect(response).to have_http_status(:ok) expect_single_action_result(:success => true, :href => api_notification_url(nil, notification_recipient.compressed_id)) expect { notification_recipient.reload }.to raise_error(ActiveRecord::RecordNotFound) @@ -65,14 +65,14 @@ it 'rejects on notification that is not owned by current user' do api_basic_authorize - post(api_notifications_url, gen_request(:delete, :href => foreign_notification_url)) + post(api_notifications_url, :params => gen_request(:delete, :href => foreign_notification_url)) expect(response).to have_http_status(:not_found) end it 'deletes single' do api_basic_authorize - post(api_notifications_url, gen_request(:delete, :href => notification_url)) + post(api_notifications_url, :params => gen_request(:delete, :href => notification_url)) expect(response).to have_http_status(:ok) expect_results_to_match_hash('results', [{'success' => true, 'href' => api_notification_url(nil, notification_recipient.compressed_id)}]) @@ -85,7 +85,7 @@ it 'deletes multiple' do api_basic_authorize - post(api_notifications_url, gen_request(:delete, [{:href => notification_url}, {:href => notification2_url}])) + post(api_notifications_url, :params => gen_request(:delete, [{:href => notification_url}, {:href => notification2_url}])) expect(response).to have_http_status(:ok) expect { notification_recipient.reload }.to raise_error(ActiveRecord::RecordNotFound) expect { notification2_recipient.reload }.to raise_error(ActiveRecord::RecordNotFound) @@ -95,13 +95,13 @@ let(:notification_id) { ApplicationRecord.compress_id(notification_recipient.id) } it 'deletes notifications specified by compressed id in href' do api_basic_authorize - post(api_notifications_url, gen_request(:delete, :href => api_notification_url(nil, notification_id))) + post(api_notifications_url, :params => gen_request(:delete, :href => api_notification_url(nil, notification_id))) expect(response).to have_http_status(:ok) end it 'deletes notifications specified by compressed id' do api_basic_authorize - post(api_notifications_url, gen_request(:delete, :id => notification_id)) + post(api_notifications_url, :params => gen_request(:delete, :id => notification_id)) expect(response).to have_http_status(:ok) end end @@ -113,7 +113,7 @@ it 'rejects on notification that is not owned by current user' do api_basic_authorize - post(foreign_notification_url, gen_request(:mark_as_seen)) + post(foreign_notification_url, :params => gen_request(:mark_as_seen)) expect(response).to have_http_status(:not_found) end @@ -121,7 +121,7 @@ api_basic_authorize expect(notification_recipient.seen).to be_falsey - post(notification_url, gen_request(:mark_as_seen)) + post(notification_url, :params => gen_request(:mark_as_seen)) expect_single_action_result(:success => true, :href => api_notification_url(nil, notification_recipient.compressed_id)) expect(notification_recipient.reload.seen).to be_truthy end diff --git a/spec/requests/orchestration_template_spec.rb b/spec/requests/orchestration_template_spec.rb index 7a8755d1c1..777b9d264d 100644 --- a/spec/requests/orchestration_template_spec.rb +++ b/spec/requests/orchestration_template_spec.rb @@ -39,7 +39,7 @@ it 'rejects creation without appropriate role' do api_basic_authorize - post(api_orchestration_templates_url, request_body_hot) + post(api_orchestration_templates_url, :params => request_body_hot) expect(response).to have_http_status(:forbidden) end @@ -48,7 +48,7 @@ api_basic_authorize collection_action_identifier(:orchestration_templates, :create) expect do - post(api_orchestration_templates_url, request_body_hot) + post(api_orchestration_templates_url, :params => request_body_hot) end.to change(OrchestrationTemplateHot, :count).by(1) end @@ -56,7 +56,7 @@ api_basic_authorize collection_action_identifier(:orchestration_templates, :create) expect do - post(api_orchestration_templates_url, request_body_cfn) + post(api_orchestration_templates_url, :params => request_body_cfn) end.to change(OrchestrationTemplateCfn, :count).by(1) end @@ -64,7 +64,7 @@ api_basic_authorize collection_action_identifier(:orchestration_templates, :create) expect do - post(api_orchestration_templates_url, request_body_vnfd) + post(api_orchestration_templates_url, :params => request_body_vnfd) end.to change(OrchestrationTemplateVnfd, :count).by(1) end @@ -72,14 +72,14 @@ api_basic_authorize collection_action_identifier(:orchestration_templates, :create) expect do - post(api_orchestration_templates_url, gen_request(:create, request_body_hot)) + post(api_orchestration_templates_url, :params => gen_request(:create, request_body_hot)) end.to change(OrchestrationTemplateHot, :count).by(1) end it 'rejects a request with an id' do api_basic_authorize collection_action_identifier(:orchestration_templates, :create) - post(api_orchestration_templates_url, request_body_hot.merge(:id => 1)) + post(api_orchestration_templates_url, :params => request_body_hot.merge(:id => 1)) expect_bad_request(/Resource id or href should not be specified/) end @@ -92,7 +92,7 @@ api_basic_authorize collection_action_identifier(:orchestration_templates, :edit) edited_name = "Edited Hot Template" - post(api_orchestration_template_url(nil, hot), gen_request(:edit, :name => edited_name)) + post(api_orchestration_template_url(nil, hot), :params => gen_request(:edit, :name => edited_name)) expect(hot.reload.name).to eq(edited_name) end @@ -130,8 +130,10 @@ cfn = FactoryGirl.create(:orchestration_template_cfn_with_content) hot = FactoryGirl.create(:orchestration_template_hot_with_content) - post(api_orchestration_templates_url, - gen_request(:delete, [{'id' => cfn.id}, {'id' => hot.id}])) + post( + api_orchestration_templates_url, + :params => gen_request(:delete, [{'id' => cfn.id}, {'id' => hot.id}]) + ) expected = { 'results' => a_collection_containing_exactly( @@ -155,7 +157,7 @@ post( api_orchestration_template_url(nil, orchestration_template), - gen_request(:copy, :content => new_content) + :params => gen_request(:copy, :content => new_content) ) expect(response).to have_http_status(:forbidden) @@ -166,7 +168,7 @@ orchestration_template = FactoryGirl.create(:orchestration_template_cfn) - post(api_orchestration_template_url(nil, orchestration_template), gen_request(:copy)) + post(api_orchestration_template_url(nil, orchestration_template), :params => gen_request(:copy)) expect(response).to have_http_status(:bad_request) end @@ -188,7 +190,7 @@ expect do post( api_orchestration_template_url(nil, orchestration_template), - gen_request(:copy, :content => new_content) + :params => gen_request(:copy, :content => new_content) ) end.to change(OrchestrationTemplateCfn, :count).by(1) @@ -215,7 +217,7 @@ expect do post( api_orchestration_templates_url, - gen_request( + :params => gen_request( :copy, [ {:id => orchestration_template.id, :content => new_content}, diff --git a/spec/requests/physical_servers_spec.rb b/spec/requests/physical_servers_spec.rb index 94a84852e3..d54a748698 100644 --- a/spec/requests/physical_servers_spec.rb +++ b/spec/requests/physical_servers_spec.rb @@ -18,7 +18,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize action_identifier(:physical_servers, :power_on, :resource_actions, :post) - post(api_physical_server_url(nil, ps), gen_request(:power_on)) + post(api_physical_server_url(nil, ps), :params => gen_request(:power_on)) expect(response).to have_http_status(:success) expect(response.parsed_body).to include("success" => true) @@ -28,7 +28,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize action_identifier(:physical_servers, :power_off, :resource_actions, :post) - post(api_physical_server_url(nil, ps), gen_request(:power_off)) + post(api_physical_server_url(nil, ps), :params => gen_request(:power_off)) expect(response).to have_http_status(:success) expect(response.parsed_body).to include("success" => true) @@ -38,7 +38,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize action_identifier(:physical_servers, :power_off_now, :resource_actions, :post) - post(api_physical_server_url(nil, ps), gen_request(:power_off_now)) + post(api_physical_server_url(nil, ps), :params => gen_request(:power_off_now)) expect(response).to have_http_status(:success) expect(response.parsed_body).to include("success" => true) @@ -48,7 +48,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize action_identifier(:physical_servers, :restart, :resource_actions, :post) - post(api_physical_server_url(nil, ps), gen_request(:restart)) + post(api_physical_server_url(nil, ps), :params => gen_request(:restart)) expect(response).to have_http_status(:success) expect(response.parsed_body).to include("success" => true) @@ -58,7 +58,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize action_identifier(:physical_servers, :restart_now, :resource_actions, :post) - post(api_physical_server_url(nil, ps), gen_request(:restart_now)) + post(api_physical_server_url(nil, ps), :params => gen_request(:restart_now)) expect(response).to have_http_status(:success) expect(response.parsed_body).to include("success" => true) @@ -68,7 +68,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize action_identifier(:physical_servers, :restart_to_sys_setup, :resource_actions, :post) - post(api_physical_server_url(nil, ps), gen_request(:restart_to_sys_setup)) + post(api_physical_server_url(nil, ps), :params => gen_request(:restart_to_sys_setup)) expect(response).to have_http_status(:success) expect(response.parsed_body).to include("success" => true) @@ -78,7 +78,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize action_identifier(:physical_servers, :restart_mgmt_controller, :resource_actions, :post) - post(api_physical_server_url(nil, ps), gen_request(:restart_mgmt_controller)) + post(api_physical_server_url(nil, ps), :params => gen_request(:restart_mgmt_controller)) expect(response).to have_http_status(:success) expect(response.parsed_body).to include("success" => true) @@ -90,7 +90,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize - post(api_physical_server_url(nil, ps), gen_request(:power_on)) + post(api_physical_server_url(nil, ps), :params => gen_request(:power_on)) expect(response).to have_http_status(:forbidden) expect(response.parsed_body["error"]).to include("kind" => "forbidden") @@ -100,7 +100,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize - post(api_physical_server_url(nil, ps), gen_request(:power_off)) + post(api_physical_server_url(nil, ps), :params => gen_request(:power_off)) expect(response).to have_http_status(:forbidden) expect(response.parsed_body["error"]).to include("kind" => "forbidden") @@ -110,7 +110,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize - post(api_physical_server_url(nil, ps), gen_request(:power_off_now)) + post(api_physical_server_url(nil, ps), :params => gen_request(:power_off_now)) expect(response).to have_http_status(:forbidden) expect(response.parsed_body["error"]).to include("kind" => "forbidden") @@ -120,7 +120,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize - post(api_physical_server_url(nil, ps), gen_request(:restart)) + post(api_physical_server_url(nil, ps), :params => gen_request(:restart)) expect(response).to have_http_status(:forbidden) expect(response.parsed_body["error"]).to include("kind" => "forbidden") @@ -130,7 +130,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize - post(api_physical_server_url(nil, ps), gen_request(:restart_now)) + post(api_physical_server_url(nil, ps), :params => gen_request(:restart_now)) expect(response).to have_http_status(:forbidden) expect(response.parsed_body["error"]).to include("kind" => "forbidden") @@ -140,7 +140,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize - post(api_physical_server_url(nil, ps), gen_request(:restart_to_sys_setup)) + post(api_physical_server_url(nil, ps), :params => gen_request(:restart_to_sys_setup)) expect(response).to have_http_status(:forbidden) expect(response.parsed_body["error"]).to include("kind" => "forbidden") @@ -150,7 +150,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize - post(api_physical_server_url(nil, ps), gen_request(:restart_mgmt_controller)) + post(api_physical_server_url(nil, ps), :params => gen_request(:restart_mgmt_controller)) expect(response).to have_http_status(:forbidden) expect(response.parsed_body["error"]).to include("kind" => "forbidden") @@ -164,7 +164,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize action_identifier(:physical_servers, :turn_on_loc_led, :resource_actions, :post) - post(api_physical_server_url(nil, ps), gen_request(:turn_on_loc_led)) + post(api_physical_server_url(nil, ps), :params => gen_request(:turn_on_loc_led)) expect(response).to have_http_status(:success) expect(response.parsed_body).to include("success" => true) @@ -174,7 +174,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize action_identifier(:physical_servers, :turn_off_loc_led, :resource_actions, :post) - post(api_physical_server_url(nil, ps), gen_request(:turn_off_loc_led)) + post(api_physical_server_url(nil, ps), :params => gen_request(:turn_off_loc_led)) expect(response).to have_http_status(:success) expect(response.parsed_body).to include("success" => true) @@ -184,7 +184,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize action_identifier(:physical_servers, :blink_loc_led, :resource_actions, :post) - post(api_physical_server_url(nil, ps), gen_request(:blink_loc_led)) + post(api_physical_server_url(nil, ps), :params => gen_request(:blink_loc_led)) expect(response).to have_http_status(:success) expect(response.parsed_body).to include("success" => true) @@ -196,7 +196,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize - post(api_physical_server_url(nil, ps), gen_request(:turn_on_loc_led)) + post(api_physical_server_url(nil, ps), :params => gen_request(:turn_on_loc_led)) expect(response).to have_http_status(:forbidden) expect(response.parsed_body["error"]).to include("kind" => "forbidden") @@ -206,7 +206,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize - post(api_physical_server_url(nil, ps), gen_request(:turn_off_loc_led)) + post(api_physical_server_url(nil, ps), :params => gen_request(:turn_off_loc_led)) expect(response).to have_http_status(:forbidden) expect(response.parsed_body["error"]).to include("kind" => "forbidden") @@ -216,7 +216,7 @@ ps = FactoryGirl.create(:physical_server) api_basic_authorize - post(api_physical_server_url(nil, ps), gen_request(:blink_loc_led)) + post(api_physical_server_url(nil, ps), :params => gen_request(:blink_loc_led)) expect(response).to have_http_status(:forbidden) expect(response.parsed_body["error"]).to include("kind" => "forbidden") diff --git a/spec/requests/picture_spec.rb b/spec/requests/picture_spec.rb index 53472cba5b..aba1869a57 100644 --- a/spec/requests/picture_spec.rb +++ b/spec/requests/picture_spec.rb @@ -36,7 +36,7 @@ def expect_result_to_include_picture_href(source_id) it "allows queries of the related picture and image_href" do api_basic_authorize action_identifier(:service_templates, :read, :resource_actions, :get) - get api_service_template_url(nil, template), :attributes => "picture,picture.image_href" + get api_service_template_url(nil, template), :params => { :attributes => "picture,picture.image_href" } expect_result_to_include_picture_href(template.compressed_id) end @@ -46,7 +46,7 @@ def expect_result_to_include_picture_href(source_id) it "allows queries of the related picture and image_href" do api_basic_authorize action_identifier(:services, :read, :resource_actions, :get) - get api_service_url(nil, service), :attributes => "picture,picture.image_href" + get api_service_url(nil, service), :params => { :attributes => "picture,picture.image_href" } expect_result_to_include_picture_href(service.compressed_id) end @@ -56,7 +56,7 @@ def expect_result_to_include_picture_href(source_id) it "allows queries of the related picture and image_href" do api_basic_authorize action_identifier(:service_requests, :read, :resource_actions, :get) - get api_service_request_url(nil, service_request), :attributes => "picture,picture.image_href" + get api_service_request_url(nil, service_request), :params => { :attributes => "picture,picture.image_href" } expect_result_to_include_picture_href(service_request.compressed_id) end @@ -82,7 +82,7 @@ def expect_result_to_include_picture_href(source_id) it 'rejects create without an appropriate role' do api_basic_authorize - post api_pictures_url, :extension => 'png', :content => content + post api_pictures_url, :params => { :extension => 'png', :content => content } expect(response).to have_http_status(:forbidden) end @@ -95,7 +95,7 @@ def expect_result_to_include_picture_href(source_id) } expect do - post api_pictures_url, :extension => 'png', :content => content + post api_pictures_url, :params => { :extension => 'png', :content => content } end.to change(Picture, :count).by(1) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) @@ -109,10 +109,8 @@ def expect_result_to_include_picture_href(source_id) } expect do - post(api_pictures_url, gen_request(:create, [ - {:extension => 'png', :content => content}, - {:extension => 'jpg', :content => content} - ])) + post(api_pictures_url, :params => gen_request(:create, [{:extension => 'png', :content => content}, + {:extension => 'jpg', :content => content}])) end.to change(Picture, :count).by(2) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) @@ -121,7 +119,7 @@ def expect_result_to_include_picture_href(source_id) it 'requires an extension' do api_basic_authorize collection_action_identifier(:pictures, :create) - post api_pictures_url, :content => content + post api_pictures_url, :params => { :content => content } expected = { 'error' => a_hash_including( @@ -135,7 +133,7 @@ def expect_result_to_include_picture_href(source_id) it 'requires content' do api_basic_authorize collection_action_identifier(:pictures, :create) - post api_pictures_url, :extension => 'png' + post api_pictures_url, :params => { :extension => 'png' } expected = { 'error' => a_hash_including( @@ -149,7 +147,7 @@ def expect_result_to_include_picture_href(source_id) it 'requires content with valid base64' do api_basic_authorize collection_action_identifier(:pictures, :create) - post api_pictures_url, :content => 'not base64', :extension => 'png' + post api_pictures_url, :params => { :content => 'not base64', :extension => 'png' } expected = { 'error' => a_hash_including( diff --git a/spec/requests/policies_assignment_spec.rb b/spec/requests/policies_assignment_spec.rb index 5539672f56..8f3582749e 100644 --- a/spec/requests/policies_assignment_spec.rb +++ b/spec/requests/policies_assignment_spec.rb @@ -47,7 +47,7 @@ def test_policy_assign_no_role(api_object_policies_url) api_basic_authorize - post(api_object_policies_url, gen_request(:assign)) + post(api_object_policies_url, :params => gen_request(:assign)) expect(response).to have_http_status(:forbidden) end @@ -55,7 +55,7 @@ def test_policy_assign_no_role(api_object_policies_url) def test_policy_assign_invalid_policy(api_object_policies_url, collection, subcollection) api_basic_authorize subcollection_action_identifier(collection, subcollection, :assign) - post(api_object_policies_url, gen_request(:assign, :href => "/api/#{subcollection}/999999")) + post(api_object_policies_url, :params => gen_request(:assign, :href => "/api/#{subcollection}/999999")) expect(response).to have_http_status(:not_found) end @@ -63,7 +63,7 @@ def test_policy_assign_invalid_policy(api_object_policies_url, collection, subco def test_policy_assign_invalid_policy_guid(object_url, api_object_policies_url, collection, subcollection) api_basic_authorize subcollection_action_identifier(collection, subcollection, :assign) - post(api_object_policies_url, gen_request(:assign, :guid => "xyzzy")) + post(api_object_policies_url, :params => gen_request(:assign, :guid => "xyzzy")) expect(response).to have_http_status(:ok) results_hash = [{"success" => false, "href" => object_url, "message" => /must specify a valid/i}] @@ -76,7 +76,7 @@ def test_assign_multiple_policies(object_url, api_object_policies_url, collectio object = options[:object] policies = options[:policies] - post(api_object_policies_url, gen_request(:assign, policies.collect { |p| {:guid => p.guid} })) + post(api_object_policies_url, :params => gen_request(:assign, policies.collect { |p| {:guid => p.guid} })) expect_multiple_action_result(policies.size) sc_prefix = subcollection.to_s.singularize @@ -91,7 +91,7 @@ def test_assign_multiple_policies(object_url, api_object_policies_url, collectio def test_policy_unassign_no_role(api_object_policies_url) api_basic_authorize - post(api_object_policies_url, gen_request(:unassign)) + post(api_object_policies_url, :params => gen_request(:unassign)) expect(response).to have_http_status(:forbidden) end @@ -99,7 +99,7 @@ def test_policy_unassign_no_role(api_object_policies_url) def test_policy_unassign_invalid_policy(api_object_policies_url, collection, subcollection) api_basic_authorize subcollection_action_identifier(collection, subcollection, :unassign) - post(api_object_policies_url, gen_request(:unassign, :href => "/api/#{subcollection}/999999")) + post(api_object_policies_url, :params => gen_request(:unassign, :href => "/api/#{subcollection}/999999")) expect(response).to have_http_status(:not_found) end @@ -107,7 +107,7 @@ def test_policy_unassign_invalid_policy(api_object_policies_url, collection, sub def test_policy_unassign_invalid_policy_guid(object_url, api_object_policies_url, collection, subcollection) api_basic_authorize subcollection_action_identifier(collection, subcollection, :unassign) - post(api_object_policies_url, gen_request(:unassign, :guid => "xyzzy")) + post(api_object_policies_url, :params => gen_request(:unassign, :guid => "xyzzy")) expect(response).to have_http_status(:ok) results_hash = [{"success" => false, "href" => object_url, "message" => /must specify a valid/i}] @@ -119,7 +119,7 @@ def test_unassign_multiple_policies(api_object_policies_url, collection, subcoll object = options[:object] [p1, p2, p3].each { |p| object.add_policy(p) } - post(api_object_policies_url, gen_request(:unassign, [{:guid => p2.guid}, {:guid => p3.guid}])) + post(api_object_policies_url, :params => gen_request(:unassign, [{:guid => p2.guid}, {:guid => p3.guid}])) object.reload expect_multiple_action_result(2) @@ -132,7 +132,7 @@ def test_unassign_multiple_policy_profiles(api_object_policies_url, collection, object = options[:object] [ps1, ps2].each { |ps| object.add_policy(ps) } - post(api_object_policies_url, gen_request(:unassign, [{:guid => ps2.guid}])) + post(api_object_policies_url, :params => gen_request(:unassign, [{:guid => ps2.guid}])) expect_multiple_action_result(1) expect(object.get_policies.size).to eq(1) diff --git a/spec/requests/policies_spec.rb b/spec/requests/policies_spec.rb index 2bf618ba94..81a47b8a30 100644 --- a/spec/requests/policies_spec.rb +++ b/spec/requests/policies_spec.rb @@ -67,7 +67,7 @@ def test_single_policy_query(object, api_object_policies_url) object.add_policy(p1) object.add_policy(ps2) - get api_object_policies_url, :expand => "resources" + get api_object_policies_url, :params => { :expand => "resources" } expect_query_result(:policies, 1) expect_result_resources_to_match_hash([{"name" => p1.name, "description" => p1.description, "guid" => p1.guid}]) @@ -80,7 +80,7 @@ def test_multiple_policy_query(object, api_object_policies_url) object.add_policy(p2) object.add_policy(ps2) - get api_object_policies_url, :expand => "resources" + get api_object_policies_url, :params => { :expand => "resources" } expect_query_result(:policies, 2) expect_result_resources_to_include_data("resources", "guid" => p_guids) @@ -92,7 +92,7 @@ def test_policy_profile_query(object, api_object_policy_profiles_url) object.add_policy(p1) object.add_policy(ps2) - get api_object_policy_profiles_url, :expand => "resources" + get api_object_policy_profiles_url, :params => { :expand => "resources" } expect_query_result(:policy_profiles, 1) expect_result_resources_to_include_data("resources", "guid" => Array.wrap(ps2.guid)) @@ -122,7 +122,7 @@ def test_policy_profile_query(object, api_object_policy_profiles_url) it "query policies in expanded form" do api_basic_authorize collection_action_identifier(:policies, :read, :get) - get api_policies_url, :expand => "resources" + get api_policies_url, :params => { :expand => "resources" } expect_query_result(:policies, 3, 3) expect_result_resources_to_include_data("resources", "guid" => p_all_guids) @@ -165,7 +165,7 @@ def test_policy_profile_query(object, api_object_policy_profiles_url) it "query Policy Profile policies subcollection" do api_basic_authorize - get api_policy_profile_policies_url(nil, policy_profile), :expand => "resources" + get api_policy_profile_policies_url(nil, policy_profile), :params => { :expand => "resources" } expect_query_result(:policies, p_guids.count) expect_result_resources_to_include_data("resources", "guid" => p_guids) @@ -174,7 +174,7 @@ def test_policy_profile_query(object, api_object_policy_profiles_url) it "query Policy Profile with expanded policies subcollection" do api_basic_authorize action_identifier(:policy_profiles, :read, :resource_actions, :get) - get api_policy_profile_url(nil, policy_profile), :expand => "policies" + get api_policy_profile_url(nil, policy_profile), :params => { :expand => "policies" } expect_single_resource_query( "name" => policy_profile.name, "description" => policy_profile.description, "guid" => policy_profile.guid @@ -352,7 +352,7 @@ def test_policy_profile_query(object, api_object_policy_profiles_url) it "creates new policy" do api_basic_authorize collection_action_identifier(:policies, :create) - post(api_policies_url, sample_policy.merge!(miq_policy_contents)) + post(api_policies_url, :params => sample_policy.merge!(miq_policy_contents)) policy = MiqPolicy.find(ApplicationRecord.uncompress_id(response.parsed_body["results"].first["id"])) expect(response.parsed_body["results"].first["name"]).to eq("sample policy") expect(response.parsed_body["results"].first["towhat"]).to eq("ManageIQ::Providers::Redhat::InfraManager") @@ -365,7 +365,7 @@ def test_policy_profile_query(object, api_object_policy_profiles_url) it "shouldn't creates new policy with missing params" do api_basic_authorize collection_action_identifier(:policies, :create) - post(api_policies_url, sample_policy) + post(api_policies_url, :params => sample_policy) expect(response).to have_http_status(:bad_request) expect(response.parsed_body["error"]["message"]).to include(miq_policy_contents.keys.join(", ")) end @@ -375,7 +375,7 @@ def test_policy_profile_query(object, api_object_policy_profiles_url) api_basic_authorize(action_identifier(:policies, :delete)) policy = FactoryGirl.create(:miq_policy) - expect { post(api_policy_url(nil, policy), :action => "delete") }.to change(MiqPolicy, :count).by(-1) + expect { post(api_policy_url(nil, policy), :params => { :action => "delete" }) }.to change(MiqPolicy, :count).by(-1) expect(response).to have_http_status(:ok) end @@ -384,7 +384,7 @@ def test_policy_profile_query(object, api_object_policy_profiles_url) api_basic_authorize policy = FactoryGirl.create(:miq_policy) - expect { post(api_policy_url(nil, policy), :action => "delete") }.not_to change(MiqPolicy, :count) + expect { post(api_policy_url(nil, policy), :params => { :action => "delete" }) }.not_to change(MiqPolicy, :count) expect(response).to have_http_status(:forbidden) end @@ -396,7 +396,7 @@ def test_policy_profile_query(object, api_object_policy_profiles_url) policy = FactoryGirl.create(:miq_policy) expect do - post(api_policies_url, :action => "delete", :resources => [{:id => policy.id}]) + post(api_policies_url, :params => { :action => "delete", :resources => [{:id => policy.id}] }) end.to change(MiqPolicy, :count).by(-1) expect(response.parsed_body).to include("results" => [a_hash_including("success" => true)]) @@ -408,7 +408,7 @@ def test_policy_profile_query(object, api_object_policy_profiles_url) policy = FactoryGirl.create(:miq_policy) expect do - post(api_policies_url, :action => "delete", :resources => [{:id => policy.id}]) + post(api_policies_url, :params => { :action => "delete", :resources => [{:id => policy.id}] }) end.not_to change(MiqPolicy, :count) expect(response).to have_http_status(:forbidden) @@ -441,7 +441,7 @@ def test_policy_profile_query(object, api_object_policy_profiles_url) expect(miq_policy.conditions.count).to eq(2) expect(miq_policy.actions.count).to eq(0) expect(miq_policy.events.count).to eq(0) - post(api_policy_url(nil, miq_policy), gen_request(:edit, miq_policy_contents.merge('conditions_ids' => []))) + post(api_policy_url(nil, miq_policy), :params => gen_request(:edit, miq_policy_contents.merge('conditions_ids' => []))) policy = MiqPolicy.find(ApplicationRecord.uncompress_id(response.parsed_body["id"])) expect(response).to have_http_status(:ok) expect(policy.actions.count).to eq(1) @@ -452,7 +452,7 @@ def test_policy_profile_query(object, api_object_policy_profiles_url) it "edits just the description" do api_basic_authorize collection_action_identifier(:policies, :edit) expect(miq_policy.description).to_not eq("BAR") - post(api_policy_url(nil, miq_policy), gen_request(:edit, :description => "BAR")) + post(api_policy_url(nil, miq_policy), :params => gen_request(:edit, :description => "BAR")) policy = MiqPolicy.find(ApplicationRecord.uncompress_id(response.parsed_body["id"])) expect(response).to have_http_status(:ok) expect(policy.description).to eq("BAR") diff --git a/spec/requests/policy_actions_spec.rb b/spec/requests/policy_actions_spec.rb index 99555d0c7b..8c88a1cdc0 100644 --- a/spec/requests/policy_actions_spec.rb +++ b/spec/requests/policy_actions_spec.rb @@ -50,7 +50,7 @@ def create_actions(count) api_basic_authorize collection_action_identifier(:policy_actions, :read, :get) create_actions(4) - get api_policy_actions_url, :expand => "resources" + get api_policy_actions_url, :params => { :expand => "resources" } expect_query_result(:policy_actions, 4, 4) expect_result_resources_to_include_data("resources", "guid" => miq_action_guid_list) @@ -79,7 +79,7 @@ def relate_actions_to(policy) create_actions(4) relate_actions_to(policy) - get api_policy_policy_actions_url(nil, policy), :expand => "resources" + get api_policy_policy_actions_url(nil, policy), :params => { :expand => "resources" } expect_query_result(:policy_actions, 4, 4) expect_result_resources_to_include_data("resources", "guid" => miq_action_guid_list) @@ -90,7 +90,7 @@ def relate_actions_to(policy) create_actions(4) relate_actions_to(policy) - get api_policy_url(nil, policy), :expand => "policy_actions" + get api_policy_url(nil, policy), :params => { :expand => "policy_actions" } expect_single_resource_query("name" => policy.name, "description" => policy.description, "guid" => policy.guid) expect_result_resources_to_include_data("policy_actions", "guid" => miq_action_guid_list) diff --git a/spec/requests/providers_spec.rb b/spec/requests/providers_spec.rb index 941be81a96..8a482d00e5 100644 --- a/spec/requests/providers_spec.rb +++ b/spec/requests/providers_spec.rb @@ -172,14 +172,14 @@ def define_user it 'lists only CloudTenant for the restricted user(indirect association)' do api_basic_authorize action_identifier(:providers, :read, :resource_actions, :get) - get(ems_cinder_url, :attributes => 'parent_manager.cloud_tenants') + get(ems_cinder_url, :params => { :attributes => 'parent_manager.cloud_tenants' }) cloud_tenant_ids = response.parsed_body['parent_manager']['cloud_tenants'].map { |x| x['id'] } expect([cloud_tenant_1.compressed_id]).to match_array(cloud_tenant_ids) end it 'lists only CloudTenant for the restricted user(direct association)' do api_basic_authorize action_identifier(:providers, :read, :resource_actions, :get) - get(ems_cinder_url, :attributes => 'vms') + get(ems_cinder_url, :params => { :attributes => 'vms' }) vm_ids = response.parsed_body['vms'].map { |x| x['id'] } expect([vm.compressed_id]).to match_array(vm_ids) end @@ -187,7 +187,7 @@ def define_user it 'lists all CloudTenants' do api_basic_authorize action_identifier(:providers, :read, :resource_actions, :get) - get(ems_cinder_url, :attributes => 'parent_manager.cloud_tenants') + get(ems_cinder_url, :params => { :attributes => 'parent_manager.cloud_tenants' }) cloud_tenant_ids = response.parsed_body['parent_manager']['cloud_tenants'].map { |x| x['id'] } expect([cloud_tenant_1.compressed_id, cloud_tenant_2.compressed_id]).to match_array(cloud_tenant_ids) end @@ -228,7 +228,7 @@ def define_user api_basic_authorize provider.custom_attributes = [ca1, ca2] - get provider_ca_url, :expand => "resources" + get provider_ca_url, :params => { :expand => "resources" } expect_query_result(:custom_attributes, 2) @@ -239,7 +239,7 @@ def define_user api_basic_authorize action_identifier(:providers, :read, :resource_actions, :get) provider.custom_attributes = [ca1, ca2] - get provider_url, :expand => "custom_attributes" + get provider_url, :params => { :expand => "custom_attributes" } expect_single_resource_query("guid" => provider.guid) @@ -250,7 +250,7 @@ def define_user api_basic_authorize provider.custom_attributes = [ca1] - post(provider_ca_url, gen_request(:delete, nil, provider_url)) + post(provider_ca_url, :params => gen_request(:delete, nil, provider_url)) expect(response).to have_http_status(:forbidden) end @@ -259,7 +259,7 @@ def define_user api_basic_authorize action_identifier(:providers, :edit) provider.custom_attributes = [ca1] - post(provider_ca_url, gen_request(:delete, nil, ca1_url)) + post(provider_ca_url, :params => gen_request(:delete, nil, ca1_url)) expect(response).to have_http_status(:ok) @@ -269,7 +269,7 @@ def define_user it "add custom attribute to a provider without a name" do api_basic_authorize action_identifier(:providers, :edit) - post(provider_ca_url, gen_request(:add, "value" => "value1")) + post(provider_ca_url, :params => gen_request(:add, "value" => "value1")) expect_bad_request("Must specify a name") end @@ -277,7 +277,7 @@ def define_user it "prevents adding custom attribute to a provider with forbidden section" do api_basic_authorize action_identifier(:providers, :edit) - post(provider_ca_url, gen_request(:add, [{"name" => "name3", "value" => "value3", + post(provider_ca_url, :params => gen_request(:add, [{"name" => "name3", "value" => "value3", "section" => "bad_section"}])) expect_bad_request("Invalid provider custom attributes specified - " \ @@ -287,8 +287,8 @@ def define_user it "add custom attributes to a provider" do api_basic_authorize action_identifier(:providers, :edit) - post(provider_ca_url, gen_request(:add, [{"name" => "name1", "value" => "value1"}, - {"name" => "name2", "value" => "value2", "section" => "metadata"}])) + post(provider_ca_url, :params => gen_request(:add, [{"name" => "name1", "value" => "value1"}, + {"name" => "name2", "value" => "value2", "section" => "metadata"}])) expected = { "results" => a_collection_containing_exactly( a_hash_including("name" => "name1", "value" => "value1", "section" => "metadata"), @@ -306,9 +306,9 @@ def define_user api_basic_authorize action_identifier(:providers, :edit) date_field = DateTime.new.in_time_zone - post(provider_ca_url, gen_request(:add, [{"name" => "name1", - "value" => date_field, - "field_type" => "DateTime"}])) + post(provider_ca_url, :params => gen_request(:add, [{"name" => "name1", + "value" => date_field, + "field_type" => "DateTime"}])) expect(response).to have_http_status(:ok) @@ -321,7 +321,7 @@ def define_user api_basic_authorize action_identifier(:providers, :edit) provider.custom_attributes = [ca1] - post(provider_ca_url, gen_request(:edit, "name" => "name1", "value" => "value one")) + post(provider_ca_url, :params => gen_request(:edit, "name" => "name1", "value" => "value one")) expect(response).to have_http_status(:ok) @@ -345,7 +345,7 @@ def define_user it "rejects requests with invalid provider_class" do api_basic_authorize - get api_providers_url, :provider_class => "bad_class" + get api_providers_url, :params => { :provider_class => "bad_class" } expect_bad_request(/unsupported/i) end @@ -353,7 +353,7 @@ def define_user it "requires credentials if no connection_configurations are specified" do api_basic_authorize collection_action_identifier(:providers, :create) - post(api_providers_url, gen_request(:create, [{"name" => "name3"}])) + post(api_providers_url, :params => gen_request(:create, [{"name" => "name3"}])) expect_bad_request("Must specify credentials") end @@ -362,7 +362,7 @@ def define_user api_basic_authorize collection_action_identifier(:providers, :read, :get) FactoryGirl.build(:provider_foreman) - get api_providers_url, :provider_class => "provider", :expand => "resources" + get api_providers_url, :params => { :provider_class => "provider", :expand => "resources" } klass = Provider expect_query_result(:providers, klass.count, klass.count) @@ -373,7 +373,7 @@ def define_user api_basic_authorize collection_action_identifier(:providers, :create) # TODO: provider_class in params, when supported (https://github.com/brynary/rack-test/issues/150) - post(api_providers_url + '?provider_class=provider', gen_request(:create, sample_foreman)) + post(api_providers_url + '?provider_class=provider', :params => gen_request(:create, sample_foreman)) expect(response).to have_http_status(:ok) @@ -388,7 +388,7 @@ def define_user provider = FactoryGirl.create(:provider_foreman) api_basic_authorize collection_action_identifier(:providers, :read, :get) - get api_providers_url, :provider_class => 'provider' + get api_providers_url, :params => { :provider_class => 'provider' } expected = { 'resources' => [ @@ -405,7 +405,7 @@ def define_user api_basic_authorize action_identifier(:providers, :read, :resource_actions, :get), action_identifier(:providers, :edit) - get api_provider_url(nil, provider), :provider_class => :provider + get api_provider_url(nil, provider), :params => { :provider_class => :provider } expected = { 'href' => a_string_including("/api/providers/#{provider.compressed_id}?provider_class=provider"), @@ -422,7 +422,7 @@ def define_user it "rejects creation without appropriate role" do api_basic_authorize - post(api_providers_url, sample_rhevm) + post(api_providers_url, :params => sample_rhevm) expect(response).to have_http_status(:forbidden) end @@ -430,7 +430,7 @@ def define_user it "rejects provider creation with id specified" do api_basic_authorize collection_action_identifier(:providers, :create) - post(api_providers_url, "name" => "sample provider", "id" => 100) + post(api_providers_url, :params => { "name" => "sample provider", "id" => 100 }) expect_bad_request(/id or href should not be specified/i) end @@ -438,7 +438,7 @@ def define_user it "rejects provider creation with invalid type specified" do api_basic_authorize collection_action_identifier(:providers, :create) - post(api_providers_url, "name" => "sample provider", "type" => "BogusType", "credentials" => {}) + post(api_providers_url, :params => { "name" => "sample provider", "type" => "BogusType", "credentials" => {} }) expect_bad_request(/Invalid provider type BogusType/i) end @@ -446,7 +446,7 @@ def define_user it "supports single provider creation" do api_basic_authorize collection_action_identifier(:providers, :create) - post(api_providers_url, sample_rhevm) + post(api_providers_url, :params => sample_rhevm) expect(response).to have_http_status(:ok) expected = { @@ -468,7 +468,7 @@ def define_user it "supports creation with auth_key specified" do api_basic_authorize collection_action_identifier(:providers, :create) - post(api_providers_url, sample_containers.merge("credentials" => [containers_credentials])) + post(api_providers_url, :params => sample_containers.merge("credentials" => [containers_credentials])) expect(response).to have_http_status(:ok) expected = { @@ -489,7 +489,7 @@ def define_user it "supports single provider creation via action" do api_basic_authorize collection_action_identifier(:providers, :create) - post(api_providers_url, gen_request(:create, sample_rhevm)) + post(api_providers_url, :params => gen_request(:create, sample_rhevm)) expect(response).to have_http_status(:ok) expected = { @@ -506,7 +506,7 @@ def define_user it "supports single provider creation with simple credentials" do api_basic_authorize collection_action_identifier(:providers, :create) - post(api_providers_url, sample_vmware.merge("credentials" => default_credentials)) + post(api_providers_url, :params => sample_vmware.merge("credentials" => default_credentials)) expect(response).to have_http_status(:ok) expected = { @@ -525,7 +525,7 @@ def define_user it "supports single provider creation with compound credentials" do api_basic_authorize collection_action_identifier(:providers, :create) - post(api_providers_url, sample_rhevm.merge("credentials" => compound_credentials)) + post(api_providers_url, :params => sample_rhevm.merge("credentials" => compound_credentials)) expect(response).to have_http_status(:ok) expected = { @@ -546,7 +546,7 @@ def define_user it "supports multiple provider creation" do api_basic_authorize collection_action_identifier(:providers, :create) - post(api_providers_url, gen_request(:create, [sample_vmware, sample_rhevm])) + post(api_providers_url, :params => gen_request(:create, [sample_vmware, sample_rhevm])) expect(response).to have_http_status(:ok) expected = { @@ -575,7 +575,7 @@ def token(connection) it "supports provider with multiple endpoints creation" do api_basic_authorize collection_action_identifier(:providers, :create) - post(api_providers_url, gen_request(:create, sample_containers_multi_end_point)) + post(api_providers_url, :params => gen_request(:create, sample_containers_multi_end_point)) expect(response).to have_http_status(:ok) expected = {"id" => a_kind_of(String), @@ -603,7 +603,7 @@ def token(connection) it "rejects resource edits without appropriate role" do api_basic_authorize - post(api_providers_url, gen_request(:edit, "name" => "provider name", "href" => api_provider_url(nil, 999_999))) + post(api_providers_url, :params => gen_request(:edit, "name" => "provider name", "href" => api_provider_url(nil, 999_999))) expect(response).to have_http_status(:forbidden) end @@ -611,7 +611,7 @@ def token(connection) it "rejects edits for invalid resources" do api_basic_authorize collection_action_identifier(:providers, :edit) - post(api_provider_url(nil, 999_999), gen_request(:edit, "name" => "updated provider name")) + post(api_provider_url(nil, 999_999), :params => gen_request(:edit, "name" => "updated provider name")) expect(response).to have_http_status(:not_found) end @@ -621,7 +621,7 @@ def token(connection) provider = FactoryGirl.create(:ext_management_system, sample_rhevm.except("credentials")) - post(api_provider_url(nil, provider), gen_request(:edit, "name" => "updated provider", "port" => "8080")) + post(api_provider_url(nil, provider), :params => gen_request(:edit, "name" => "updated provider", "port" => "8080")) expect_single_resource_query("id" => provider.compressed_id, "name" => "updated provider") expect(provider.reload.name).to eq("updated provider") @@ -633,7 +633,7 @@ def token(connection) provider = FactoryGirl.create(:ext_management_system, sample_rhevm.except("credentials")) - post(api_provider_url(nil, provider), gen_request(:edit, "name" => "updated provider", "port" => "8080")) + post(api_provider_url(nil, provider), :params => gen_request(:edit, "name" => "updated provider", "port" => "8080")) response_keys = response.parsed_body.keys expect(response_keys).to include("tenant_id") @@ -646,9 +646,9 @@ def token(connection) provider = FactoryGirl.create(:ext_management_system, sample_vmware.except("credentials")) provider.update_authentication(:default => default_credentials.symbolize_keys) - post(api_provider_url(nil, provider), gen_request(:edit, - "name" => "updated vmware", - "credentials" => {"userid" => "superadmin"})) + post(api_provider_url(nil, provider), :params => gen_request(:edit, + "name" => "updated vmware", + "credentials" => {"userid" => "superadmin"})) expect_single_resource_query("id" => provider.compressed_id, "name" => "updated vmware") expect(provider.reload.name).to eq("updated vmware") @@ -667,9 +667,9 @@ def token(connection) :class_name => "ExtManagementSystem", :instance_id => provider.id).delete_all - post(api_provider_url(nil, provider), gen_request(:edit, - "connection_configurations" => [default_connection, - hawkular_connection])) + post(api_provider_url(nil, provider), :params => gen_request(:edit, + "connection_configurations" => [default_connection, + hawkular_connection])) queue_jobs = MiqQueue.where(:method_name => "authentication_check_types", :class_name => "ExtManagementSystem", @@ -686,9 +686,9 @@ def token(connection) :class_name => "ExtManagementSystem", :instance_id => provider.id).delete_all - post(api_provider_url(nil, provider), gen_request(:edit, - "connection_configurations" => [updated_connection, - hawkular_connection])) + post(api_provider_url(nil, provider), :params => gen_request(:edit, + "connection_configurations" => [updated_connection, + hawkular_connection])) provider.reload expect(provider).to have_endpoint_attributes(updated_connection["endpoint"]) @@ -709,9 +709,9 @@ def token(connection) provider = FactoryGirl.create(:ext_management_system, sample_rhevm.except("credentials")) provider.update_authentication(:default => default_credentials.symbolize_keys) - post(api_provider_url(nil, provider), gen_request(:edit, - "name" => "updated rhevm", - "credentials" => [metrics_credentials])) + post(api_provider_url(nil, provider), :params => gen_request(:edit, + "name" => "updated rhevm", + "credentials" => [metrics_credentials])) expect_single_resource_query("id" => provider.compressed_id, "name" => "updated rhevm") expect(provider.reload.name).to eq("updated rhevm") @@ -725,9 +725,9 @@ def token(connection) p1 = FactoryGirl.create(:ems_redhat, :name => "name1") p2 = FactoryGirl.create(:ems_redhat, :name => "name2") - post(api_providers_url, gen_request(:edit, - [{"href" => api_provider_url(nil, p1), "name" => "updated name1"}, - {"href" => api_provider_url(nil, p2), "name" => "updated name2"}])) + post(api_providers_url, :params => gen_request(:edit, + [{"href" => api_provider_url(nil, p1), "name" => "updated name1"}, + {"href" => api_provider_url(nil, p2), "name" => "updated name2"}])) expect_results_to_match_hash("results", [{"id" => p1.compressed_id, "name" => "updated name1"}, @@ -742,7 +742,7 @@ def token(connection) it "rejects deletion without appropriate role" do api_basic_authorize - post(api_providers_url, gen_request(:delete, "name" => "provider name", "href" => api_provider_url(nil, 100))) + post(api_providers_url, :params => gen_request(:delete, "name" => "provider name", "href" => api_provider_url(nil, 100))) expect(response).to have_http_status(:forbidden) end @@ -778,7 +778,7 @@ def token(connection) provider = FactoryGirl.create(:ext_management_system, :name => "provider", :hostname => "provider.com") - post(api_provider_url(nil, provider), gen_request(:delete)) + post(api_provider_url(nil, provider), :params => gen_request(:delete)) expect_single_action_result(:success => true, :message => "deleting", @@ -792,9 +792,9 @@ def token(connection) p1 = FactoryGirl.create(:ext_management_system, :name => "provider name 1") p2 = FactoryGirl.create(:ext_management_system, :name => "provider name 2") - post(api_providers_url, gen_request(:delete, - [{"href" => api_provider_url(nil, p1)}, - {"href" => api_provider_url(nil, p2)}])) + post(api_providers_url, :params => gen_request(:delete, + [{"href" => api_provider_url(nil, p1)}, + {"href" => api_provider_url(nil, p2)}])) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_provider_url(nil, p1.compressed_id), api_provider_url(nil, p2.compressed_id)]) @@ -809,7 +809,7 @@ def failed_auth_action(id) it "rejects refresh requests without appropriate role" do api_basic_authorize - post(api_provider_url(nil, 100), gen_request(:refresh)) + post(api_provider_url(nil, 100), :params => gen_request(:refresh)) expect(response).to have_http_status(:forbidden) end @@ -820,7 +820,7 @@ def failed_auth_action(id) provider = FactoryGirl.create(:ext_management_system, sample_vmware.symbolize_keys.except(:type, :credentials)) provider.update_authentication(:default => default_credentials.symbolize_keys) - post(api_provider_url(nil, provider), gen_request(:refresh)) + post(api_provider_url(nil, provider), :params => gen_request(:refresh)) expect_single_action_result(failed_auth_action(provider.compressed_id).symbolize_keys) end @@ -834,8 +834,8 @@ def failed_auth_action(id) p2 = FactoryGirl.create(:ext_management_system, sample_rhevm.symbolize_keys.except(:type, :credentials)) p2.update_authentication(:default => default_credentials.symbolize_keys) - post(api_providers_url, gen_request(:refresh, [{"href" => api_provider_url(nil, p1)}, - {"href" => api_provider_url(nil, p2)}])) + post(api_providers_url, :params => gen_request(:refresh, [{"href" => api_provider_url(nil, p1)}, + {"href" => api_provider_url(nil, p2)}])) expect(response).to have_http_status(:ok) expect_results_to_match_hash("results", [failed_auth_action(p1.compressed_id), failed_auth_action(p2.compressed_id)]) end @@ -847,7 +847,7 @@ def failed_auth_action(id) provider.update_authentication(:default => default_credentials.symbolize_keys) provider.authentication_type(:default).update(:status => "Valid") - post(api_provider_url(nil, provider), gen_request(:refresh)) + post(api_provider_url(nil, provider), :params => gen_request(:refresh)) expect_single_action_result(:success => true, :message => a_string_matching("Provider .* refreshing"), @@ -862,7 +862,7 @@ def failed_auth_action(id) provider.update_authentication(:default => default_credentials.symbolize_keys) provider.authentication_type(:default).update(:status => "Valid") - post(api_provider_url(nil, provider) + '?provider_class=provider', gen_request(:refresh)) + post(api_provider_url(nil, provider) + '?provider_class=provider', :params => gen_request(:refresh)) expect_single_action_result(:success => true, :message => a_string_matching("Provider .* refreshing"), @@ -877,7 +877,7 @@ def failed_auth_action(id) provider.update_authentication(:default => default_credentials.symbolize_keys) provider.authentication_type(:default).update(:status => "Valid") - post(api_provider_url(nil, provider) + '?provider_class=provider', gen_request(:refresh)) + post(api_provider_url(nil, provider) + '?provider_class=provider', :params => gen_request(:refresh)) expected = { "success" => true, @@ -925,7 +925,7 @@ def gen_import_request it 'rejects import without appropriate role' do api_basic_authorize - post(provider_url, gen_import_request) + post(provider_url, :params => gen_import_request) expect(response).to have_http_status(:forbidden) end @@ -933,7 +933,7 @@ def gen_import_request it 'enqueues a correct import request' do api_basic_authorize action_identifier(:providers, :import_vm) - post(provider_url, gen_import_request) + post(provider_url, :params => gen_import_request) expect_single_action_result(:success => true, :task => true) queue_jobs = MiqQueue.where(:method_name => 'import_vm', @@ -955,7 +955,7 @@ def gen_import_request let!(:generic_provider) { FactoryGirl.create(:provider) } it 'does not blow-up on provider without custom_attributes' do api_basic_authorize collection_action_identifier(:providers, :read, :get) - get(api_providers_url, :expand => 'resources,custom_attributes', :provider_class => 'provider') + get(api_providers_url, :params => { :expand => 'resources,custom_attributes', :provider_class => 'provider' }) expect_query_result(:providers, 1, 1) end end @@ -1123,13 +1123,13 @@ def gen_import_request it 'cannot add a custom_attribute' do api_basic_authorize subcollection_action_identifier(:providers, :custom_attributes, :add, :post) - post(url, gen_request(:add, :name => 'x')) + post(url, :params => gen_request(:add, :name => 'x')) expect_bad_request("#{generic_provider.class.name} does not support management of custom attributes") end it 'cannot edit custom_attribute' do api_basic_authorize subcollection_action_identifier(:providers, :custom_attributes, :edit, :post) - post(url, gen_request(:edit, :href => api_provider_custom_attribute_url(nil, generic_provider, attr))) + post(url, :params => gen_request(:edit, :href => api_provider_custom_attribute_url(nil, generic_provider, attr))) expect_bad_request("#{generic_provider.class.name} does not support management of custom attributes") end end diff --git a/spec/requests/provision_requests_spec.rb b/spec/requests/provision_requests_spec.rb index 480189f2f6..97de91669e 100644 --- a/spec/requests/provision_requests_spec.rb +++ b/spec/requests/provision_requests_spec.rb @@ -87,7 +87,7 @@ } ) - post(api_provision_requests_url, body) + post(api_provision_requests_url, :params => body) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_provreq_attributes) @@ -119,7 +119,7 @@ } ) - post(api_provision_requests_url, body) + post(api_provision_requests_url, :params => body) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_provreq_attributes) @@ -148,7 +148,7 @@ } ) - post(api_provision_requests_url, body) + post(api_provision_requests_url, :params => body) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_provreq_attributes) @@ -271,7 +271,7 @@ it "rejects requests without appropriate role" do api_basic_authorize - post(api_provision_requests_url, single_provision_request) + post(api_provision_requests_url, :params => single_provision_request) expect(response).to have_http_status(:forbidden) end @@ -280,7 +280,7 @@ api_basic_authorize collection_action_identifier(:provision_requests, :create) dialog # Create the Provisioning dialog - post(api_provision_requests_url, single_provision_request) + post(api_provision_requests_url, :params => single_provision_request) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_attributes) @@ -294,7 +294,7 @@ api_basic_authorize collection_action_identifier(:provision_requests, :create) dialog # Create the Provisioning dialog - post(api_provision_requests_url, gen_request(:create, single_provision_request)) + post(api_provision_requests_url, :params => gen_request(:create, single_provision_request)) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_attributes) @@ -308,7 +308,7 @@ api_basic_authorize collection_action_identifier(:provision_requests, :create) dialog # Create the Provisioning dialog - post(api_provision_requests_url, gen_request(:create, [single_provision_request, single_provision_request])) + post(api_provision_requests_url, :params => gen_request(:create, [single_provision_request, single_provision_request])) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_attributes) @@ -324,7 +324,7 @@ provision_request = FactoryGirl.create(:miq_provision_request, :requester => @user, :options => {:foo => "bar"}) api_basic_authorize - post(api_provision_request_url(nil, provision_request), :action => "edit", :options => {:baz => "qux"}) + post(api_provision_request_url(nil, provision_request), :params => { :action => "edit", :options => {:baz => "qux"} }) expect(response).to have_http_status(:forbidden) end @@ -333,7 +333,7 @@ provision_request = FactoryGirl.create(:miq_provision_request, :requester => @user, :options => {:foo => "bar"}) api_basic_authorize(action_identifier(:provision_requests, :edit)) - post(api_provision_request_url(nil, provision_request), :action => "edit", :options => {:baz => "qux"}) + post(api_provision_request_url(nil, provision_request), :params => { :action => "edit", :options => {:baz => "qux"} }) expected = { "id" => provision_request.compressed_id, @@ -352,11 +352,13 @@ post( api_provision_requests_url, - :action => "edit", - :resources => [ - {:id => provision_request.id, :options => {:baz => "qux"}}, - {:id => provision_request2.id, :options => {:quux => "quuz"}} - ] + :params => { + :action => "edit", + :resources => [ + {:id => provision_request.id, :options => {:baz => "qux"}}, + {:id => provision_request2.id, :options => {:quux => "quuz"}} + ] + } ) expected = { @@ -387,7 +389,7 @@ it "supports approving a request" do api_basic_authorize collection_action_identifier(:provision_requests, :approve) - post(provreq1_url, gen_request(:approve)) + post(provreq1_url, :params => gen_request(:approve)) expected_msg = "Provision request #{provreq1.id} approved" expect_single_action_result(:success => true, :message => expected_msg, :href => api_provision_request_url(nil, provreq1.compressed_id)) @@ -396,7 +398,7 @@ it "supports denying a request" do api_basic_authorize collection_action_identifier(:provision_requests, :approve) - post(provreq2_url, gen_request(:deny)) + post(provreq2_url, :params => gen_request(:deny)) expected_msg = "Provision request #{provreq2.id} denied" expect_single_action_result(:success => true, :message => expected_msg, :href => api_provision_request_url(nil, provreq2.compressed_id)) @@ -405,7 +407,7 @@ it "supports approving multiple requests" do api_basic_authorize collection_action_identifier(:provision_requests, :approve) - post(api_provision_requests_url, gen_request(:approve, [{"href" => provreq1_url}, {"href" => provreq2_url}])) + post(api_provision_requests_url, :params => gen_request(:approve, [{"href" => provreq1_url}, {"href" => provreq2_url}])) expected = { "results" => a_collection_containing_exactly( @@ -428,7 +430,7 @@ it "supports denying multiple requests" do api_basic_authorize collection_action_identifier(:provision_requests, :approve) - post(api_provision_requests_url, gen_request(:deny, [{"href" => provreq1_url}, {"href" => provreq2_url}])) + post(api_provision_requests_url, :params => gen_request(:deny, [{"href" => provreq1_url}, {"href" => provreq2_url}])) expected = { "results" => a_collection_containing_exactly( diff --git a/spec/requests/queries_spec.rb b/spec/requests/queries_spec.rb index b6ab29fb69..702ef42a05 100644 --- a/spec/requests/queries_spec.rb +++ b/spec/requests/queries_spec.rb @@ -30,7 +30,7 @@ def create_vms(count) api_basic_authorize collection_action_identifier(:vms, :read, :get) create_vms(3) - get api_vms_url, :expand => "resources" + get api_vms_url, :params => { :expand => "resources" } expect_query_result(:vms, 3, 3) expected = { @@ -45,7 +45,7 @@ def create_vms(count) api_basic_authorize collection_action_identifier(:vms, :read, :get) vm1 # create resource - get api_vms_url, :expand => "resources", :attributes => "guid" + get api_vms_url, :params => { :expand => "resources", :attributes => "guid" } expect_query_result(:vms, 1, 1) expect_result_resources_to_match_hash([{"id" => vm1.compressed_id, "href" => api_vm_url(nil, vm1.compressed_id), "guid" => vm1.guid}]) @@ -120,7 +120,7 @@ def create_vms(count) acct1 acct2 - get vm1_accounts_url, :expand => "resources" + get vm1_accounts_url, :params => { :expand => "resources" } expect_query_result(:accounts, 2) expect_result_resources_to_include_keys("resources", %w(id href)) @@ -159,7 +159,7 @@ def create_vms(count) provider = FactoryGirl.create(:ext_management_system, :name => "sample", :hostname => "sample.com") provider.update_authentication(:default => credentials) - get(api_provider_url(nil, provider), :attributes => "authentications") + get(api_provider_url(nil, provider), :params => { :attributes => "authentications" }) expect(response).to have_http_status(:ok) expect_result_to_match_hash(response.parsed_body, "name" => "sample") diff --git a/spec/requests/querying_spec.rb b/spec/requests/querying_spec.rb index 4aabc2fbfc..25920dee1b 100644 --- a/spec/requests/querying_spec.rb +++ b/spec/requests/querying_spec.rb @@ -21,7 +21,7 @@ def create_vms_by_name(names) it "supports offset" do create_vms_by_name(%w(aa bb cc)) - get api_vms_url, :offset => 2 + get api_vms_url, :params => { :offset => 2 } expect_query_result(:vms, 1, 3) end @@ -29,7 +29,7 @@ def create_vms_by_name(names) it "supports limit" do create_vms_by_name(%w(aa bb cc)) - get api_vms_url, :limit => 2 + get api_vms_url, :params => { :limit => 2 } expect_query_result(:vms, 2, 3) end @@ -37,7 +37,7 @@ def create_vms_by_name(names) it "supports offset and limit" do create_vms_by_name(%w(aa bb cc)) - get api_vms_url, :offset => 1, :limit => 1 + get api_vms_url, :params => { :offset => 1, :limit => 1 } expect_query_result(:vms, 1, 3) end @@ -45,17 +45,17 @@ def create_vms_by_name(names) it "supports paging via offset and limit" do create_vms_by_name %w(aa bb cc dd ee) - get api_vms_url, :offset => 0, :limit => 2, :sort_by => "name", :expand => "resources" + get api_vms_url, :params => { :offset => 0, :limit => 2, :sort_by => "name", :expand => "resources" } expect_query_result(:vms, 2, 5) expect_result_resources_to_match_hash([{"name" => "aa"}, {"name" => "bb"}]) - get api_vms_url, :offset => 2, :limit => 2, :sort_by => "name", :expand => "resources" + get api_vms_url, :params => { :offset => 2, :limit => 2, :sort_by => "name", :expand => "resources" } expect_query_result(:vms, 2, 5) expect_result_resources_to_match_hash([{"name" => "cc"}, {"name" => "dd"}]) - get api_vms_url, :offset => 4, :limit => 2, :sort_by => "name", :expand => "resources" + get api_vms_url, :params => { :offset => 4, :limit => 2, :sort_by => "name", :expand => "resources" } expect_query_result(:vms, 1, 5) expect_result_resources_to_match_hash([{"name" => "ee"}]) @@ -64,7 +64,7 @@ def create_vms_by_name(names) it 'raises a BadRequestError for attributes that do not exist' do api_basic_authorize action_identifier(:vms, :read, :resource_actions, :get) - get(api_vm_url(nil, vm1), :attributes => 'not_an_attribute') + get(api_vm_url(nil, vm1), :params => { :attributes => 'not_an_attribute' }) expected = { 'error' => a_hash_including( @@ -79,7 +79,7 @@ def create_vms_by_name(names) it "returns correct paging links" do create_vms_by_name %w(bb ff aa cc ee gg dd) - get api_vms_url, :offset => 0, :limit => 2, :sort_by => "name", :expand => "resources" + get api_vms_url, :params => { :offset => 0, :limit => 2, :sort_by => "name", :expand => "resources" } expect_query_result(:vms, 2, 7) expect_result_resources_to_match_hash([{"name" => "aa"}, {"name" => "bb"}]) @@ -109,7 +109,7 @@ def create_vms_by_name(names) expect_query_result(:vms, 2, 7) expect_result_resources_to_match_hash([{"name" => "ee"}, {"name" => "ff"}]) - get api_vms_url, :offset => 4, :limit => 3, :sort_by => "name", :expand => "resources" + get api_vms_url, :params => { :offset => 4, :limit => 3, :sort_by => "name", :expand => "resources" } expect_query_result(:vms, 3, 7) expect_result_resources_to_match_hash([{"name" => "ee"}, {"name" => "ff"}, {"name" => "gg"}]) @@ -119,7 +119,7 @@ def create_vms_by_name(names) it "only returns paging links if both offset and limit are specified" do create_vms_by_name %w(aa bb) - get api_vms_url, :offset => 0, :expand => :resources + get api_vms_url, :params => { :offset => 0, :expand => :resources } expect(response.parsed_body.keys).to eq(%w(name count subcount resources actions)) end @@ -127,19 +127,19 @@ def create_vms_by_name(names) it "returns the correct page count" do create_vms_by_name %w(aa bb cc dd) - get api_vms_url, :offset => 0, :limit => 2 + get api_vms_url, :params => { :offset => 0, :limit => 2 } expect(response.parsed_body['pages']).to eq(2) - get api_vms_url, :offset => 0, :limit => 3 + get api_vms_url, :params => { :offset => 0, :limit => 3 } expect(response.parsed_body['pages']).to eq(2) - get api_vms_url, :offset => 0, :limit => 4 + get api_vms_url, :params => { :offset => 0, :limit => 4 } expect(response.parsed_body['subquery_count']).to be_nil expect(response.parsed_body['pages']).to eq(1) - get api_vms_url, :offset => 0, :limit => 4, :filter => ["name='aa'", "or name='bb'"] + get api_vms_url, :params => { :offset => 0, :limit => 4, :filter => ["name='aa'", "or name='bb'"] } expect(response.parsed_body['subquery_count']).to eq(2) expect(response.parsed_body['pages']).to eq(1) end @@ -147,7 +147,7 @@ def create_vms_by_name(names) it "returns the correct pages if filters are specified" do create_vms_by_name %w(aa bb cc) - get api_vms_url, :sort_by => "name", :filter => ["name='aa'", "or name='bb'"], :expand => "resources", :offset => 0, :limit => 1 + get api_vms_url, :params => { :sort_by => "name", :filter => ["name='aa'", "or name='bb'"], :expand => "resources", :offset => 0, :limit => 1 } expect_query_result(:vms, 1, 3) expect_result_resources_to_match_hash([{"name" => "aa"}]) @@ -164,7 +164,7 @@ def create_vms_by_name(names) it "returns the correct subquery_count" do create_vms_by_name %w(aa bb cc dd) - get api_vms_url, :sort_by => "name", :filter => ["name='aa'", "or name='bb'", "or name='dd'"], :expand => "resources", :offset => 0, :limit => 1 + get api_vms_url, :params => { :sort_by => "name", :filter => ["name='aa'", "or name='bb'", "or name='dd'"], :expand => "resources", :offset => 0, :limit => 1 } expect(response.parsed_body["subquery_count"]).to eq(3) expect_query_result(:vms, 1, 4) @@ -177,7 +177,7 @@ def create_vms_by_name(names) it "supports ascending order" do create_vms_by_name %w(cc aa bb) - get api_vms_url, :sort_by => "name", :sort_order => "asc", :expand => "resources" + get api_vms_url, :params => { :sort_by => "name", :sort_order => "asc", :expand => "resources" } expect_query_result(:vms, 3, 3) expect_result_resources_to_match_hash([{"name" => "aa"}, {"name" => "bb"}, {"name" => "cc"}]) @@ -186,7 +186,7 @@ def create_vms_by_name(names) it "supports decending order" do create_vms_by_name %w(cc aa bb) - get api_vms_url, :sort_by => "name", :sort_order => "desc", :expand => "resources" + get api_vms_url, :params => { :sort_by => "name", :sort_order => "desc", :expand => "resources" } expect_query_result(:vms, 3, 3) expect_result_resources_to_match_hash([{"name" => "cc"}, {"name" => "bb"}, {"name" => "aa"}]) @@ -195,7 +195,7 @@ def create_vms_by_name(names) it "supports case insensitive ordering" do create_vms_by_name %w(B c a) - get api_vms_url, :sort_by => "name", :sort_order => "asc", :sort_options => "ignore_case", :expand => "resources" + get api_vms_url, :params => { :sort_by => "name", :sort_order => "asc", :sort_options => "ignore_case", :expand => "resources" } expect_query_result(:vms, 3, 3) expect_result_resources_to_match_hash([{"name" => "a"}, {"name" => "B"}, {"name" => "c"}]) @@ -205,7 +205,7 @@ def create_vms_by_name(names) FactoryGirl.create(:vm_vmware, :vendor => "vmware", :name => "vmware_vm") FactoryGirl.create(:vm_redhat, :vendor => "redhat", :name => "redhat_vm") - get api_vms_url, :sort_by => "vendor", :sort_order => "asc", :expand => "resources" + get api_vms_url, :params => { :sort_by => "vendor", :sort_order => "asc", :expand => "resources" } expect_query_result(:vms, 2, 2) expect_result_resources_to_match_hash([{"name" => "redhat_vm"}, {"name" => "vmware_vm"}]) @@ -219,7 +219,7 @@ def create_vms_by_name(names) FactoryGirl.create(:vm, :name => 'vm_bar', :host => host_bar) FactoryGirl.create(:vm, :name => 'vm_zap', :host => host_zap) - get api_vms_url, :sort_by => 'host_name', :sort_order => 'desc', :expand => 'resources' + get api_vms_url, :params => { :sort_by => 'host_name', :sort_order => 'desc', :expand => 'resources' } expect_query_result(:vms, 3, 3) expect_result_resources_to_match_hash([{'name' => 'vm_zap'}, {'name' => 'vm_foo'}, {'name' => 'vm_bar'}]) @@ -228,7 +228,7 @@ def create_vms_by_name(names) it 'does not support non sql friendly virtual attributes' do FactoryGirl.create(:vm) - get api_vms_url, :sort_by => 'aggressive_recommended_mem', :sort_order => 'asc' + get api_vms_url, :params => { :sort_by => 'aggressive_recommended_mem', :sort_order => 'asc' } expected = { 'error' => a_hash_including( @@ -246,8 +246,16 @@ def create_vms_by_name(names) FactoryGirl.create(:classification_tag, :name => 'finance', :parent => dept) Classification.classify(svc1, 'department', 'finance') - get api_services_url, :sort_by => 'created_at', :filter => ['tags.name=/managed/department/finance'], - :sort_order => 'asc', :limit => 20, :offset => 0 + get( + api_services_url, + :params => { + :sort_by => 'created_at', + :filter => ['tags.name=/managed/department/finance'], + :sort_order => 'asc', + :limit => 20, + :offset => 0 + } + ) expect(response).to have_http_status(:ok) expect(response.parsed_body['subcount']).to eq(1) @@ -260,7 +268,7 @@ def create_vms_by_name(names) it "supports attribute equality test using double quotes" do _vm1, vm2 = create_vms_by_name(%w(aa bb)) - get api_vms_url, :expand => "resources", :filter => ['name="bb"'] + get api_vms_url, :params => { :expand => "resources", :filter => ['name="bb"'] } expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => vm2.name, "guid" => vm2.guid}]) @@ -269,7 +277,7 @@ def create_vms_by_name(names) it "supports attribute equality test using single quotes" do vm1, _vm2 = create_vms_by_name(%w(aa bb)) - get api_vms_url, :expand => "resources", :filter => ["name='aa'"] + get api_vms_url, :params => { :expand => "resources", :filter => ["name='aa'"] } expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => vm1.name, "guid" => vm1.guid}]) @@ -278,7 +286,7 @@ def create_vms_by_name(names) it "supports attribute pattern matching via %" do vm1, _vm2, vm3 = create_vms_by_name(%w(aa_B2 bb aa_A1)) - get api_vms_url, :expand => "resources", :filter => ["name='aa%'"], :sort_by => "name" + get api_vms_url, :params => { :expand => "resources", :filter => ["name='aa%'"], :sort_by => "name" } expect_query_result(:vms, 2, 3) expect_result_resources_to_match_hash([{"name" => vm3.name, "guid" => vm3.guid}, @@ -288,7 +296,7 @@ def create_vms_by_name(names) it "supports attribute pattern matching via *" do vm1, _vm2, vm3 = create_vms_by_name(%w(aa_B2 bb aa_A1)) - get api_vms_url, :expand => "resources", :filter => ["name='aa*'"], :sort_by => "name" + get api_vms_url, :params => { :expand => "resources", :filter => ["name='aa*'"], :sort_by => "name" } expect_query_result(:vms, 2, 3) expect_result_resources_to_match_hash([{"name" => vm3.name, "guid" => vm3.guid}, @@ -298,7 +306,7 @@ def create_vms_by_name(names) it "supports inequality test via !=" do vm1, _vm2, vm3 = create_vms_by_name(%w(aa bb cc)) - get api_vms_url, :expand => "resources", :filter => ["name!='b%'"], :sort_by => "name" + get api_vms_url, :params => { :expand => "resources", :filter => ["name!='b%'"], :sort_by => "name" } expect_query_result(:vms, 2, 3) expect_result_resources_to_match_hash([{"name" => vm1.name, "guid" => vm1.guid}, @@ -309,7 +317,7 @@ def create_vms_by_name(names) vm1, vm2 = create_vms_by_name(%w(aa bb)) vm2.update_attributes!(:retired => true) - get api_vms_url, :expand => "resources", :filter => ["retired=NULL"] + get api_vms_url, :params => { :expand => "resources", :filter => ["retired=NULL"] } expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => vm1.name, "guid" => vm1.guid}]) @@ -319,7 +327,7 @@ def create_vms_by_name(names) _vm1, vm2 = create_vms_by_name(%w(aa bb)) vm2.update_attributes!(:retired => true) - get api_vms_url, :expand => "resources", :filter => ["retired!=nil"] + get api_vms_url, :params => { :expand => "resources", :filter => ["retired!=nil"] } expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => vm2.name, "guid" => vm2.guid}]) @@ -328,7 +336,7 @@ def create_vms_by_name(names) it "supports numerical less than comparison via <" do vm1, vm2, vm3 = create_vms_by_name(%w(aa bb cc)) - get api_vms_url, :expand => "resources", :filter => ["id < #{vm3.id}"], :sort_by => "name" + get api_vms_url, :params => { :expand => "resources", :filter => ["id < #{vm3.id}"], :sort_by => "name" } expect_query_result(:vms, 2, 3) expect_result_resources_to_match_hash([{"name" => vm1.name, "guid" => vm1.guid}, @@ -338,7 +346,7 @@ def create_vms_by_name(names) it "supports numerical less than or equal comparison via <=" do vm1, vm2, _vm3 = create_vms_by_name(%w(aa bb cc)) - get api_vms_url, :expand => "resources", :filter => ["id <= #{vm2.id}"], :sort_by => "name" + get api_vms_url, :params => { :expand => "resources", :filter => ["id <= #{vm2.id}"], :sort_by => "name" } expect_query_result(:vms, 2, 3) expect_result_resources_to_match_hash([{"name" => vm1.name, "guid" => vm1.guid}, @@ -348,7 +356,7 @@ def create_vms_by_name(names) it "support greater than numerical comparison via >" do vm1, vm2 = create_vms_by_name(%w(aa bb)) - get api_vms_url, :expand => "resources", :filter => ["id > #{vm1.id}"], :sort_by => "name" + get api_vms_url, :params => { :expand => "resources", :filter => ["id > #{vm1.id}"], :sort_by => "name" } expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => vm2.name, "guid" => vm2.guid}]) @@ -357,7 +365,7 @@ def create_vms_by_name(names) it "supports greater or equal than numerical comparison via >=" do _vm1, vm2, vm3 = create_vms_by_name(%w(aa bb cc)) - get api_vms_url, :expand => "resources", :filter => ["id >= #{vm2.id}"], :sort_by => "name" + get api_vms_url, :params => { :expand => "resources", :filter => ["id >= #{vm2.id}"], :sort_by => "name" } expect_query_result(:vms, 2, 3) expect_result_resources_to_match_hash([{"name" => vm2.name, "guid" => vm2.guid}, @@ -367,9 +375,14 @@ def create_vms_by_name(names) it "supports compound logical OR comparisons" do vm1, vm2, vm3 = create_vms_by_name(%w(aa bb cc)) - get api_vms_url, :expand => "resources", - :filter => ["id = #{vm1.id}", "or id > #{vm2.id}"], - :sort_by => "name" + get( + api_vms_url, + :params => { + :expand => "resources", + :filter => ["id = #{vm1.id}", "or id > #{vm2.id}"], + :sort_by => "name" + } + ) expect_query_result(:vms, 2, 3) expect_result_resources_to_match_hash([{"name" => vm1.name, "guid" => vm1.guid}, @@ -379,8 +392,13 @@ def create_vms_by_name(names) it "supports multiple logical AND comparisons" do vm1, _vm2 = create_vms_by_name(%w(aa bb)) - get api_vms_url, :expand => "resources", - :filter => ["id = #{vm1.id}", "name = #{vm1.name}"] + get( + api_vms_url, + :params => { + :expand => "resources", + :filter => ["id = #{vm1.id}", "name = #{vm1.name}"] + } + ) expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => vm1.name, "guid" => vm1.guid}]) @@ -389,9 +407,14 @@ def create_vms_by_name(names) it "supports multiple comparisons with both AND and OR" do vm1, vm2, vm3 = create_vms_by_name(%w(aa bb cc)) - get api_vms_url, :expand => "resources", - :filter => ["id = #{vm1.id}", "name = #{vm1.name}", "or id > #{vm2.id}"], - :sort_by => "name" + get( + api_vms_url, + :params => { + :expand => "resources", + :filter => ["id = #{vm1.id}", "name = #{vm1.name}", "or id > #{vm2.id}"], + :sort_by => "name" + } + ) expect_query_result(:vms, 2, 3) expect_result_resources_to_match_hash([{"name" => vm1.name, "guid" => vm1.guid}, @@ -404,8 +427,13 @@ def create_vms_by_name(names) vm1 = FactoryGirl.create(:vm_vmware, :name => "baz", :host => host1) _vm2 = FactoryGirl.create(:vm_vmware, :name => "qux", :host => host2) - get api_vms_url, :expand => "resources", - :filter => ["host.name='foo'"] + get( + api_vms_url, + :params => { + :expand => "resources", + :filter => ["host.name='foo'"] + } + ) expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => vm1.name, "guid" => vm1.guid}]) @@ -417,15 +445,22 @@ def create_vms_by_name(names) vm1 = FactoryGirl.create(:vm_vmware, :name => "baz", :host => host1) _vm2 = FactoryGirl.create(:vm_vmware, :name => "qux", :host => host2) - get api_vms_url, :expand => "resources", - :filter => ["host.name='foo'"], :offset => 0, :limit => 1 + get( + api_vms_url, + :params => { + :expand => "resources", + :filter => ["host.name='foo'"], + :offset => 0, + :limit => 1 + } + ) expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => vm1.name, "guid" => vm1.guid}]) end it "does not support filtering by attributes of associations' associations" do - get api_vms_url, :expand => "resources", :filter => ["host.hardware.memory_mb>1024"] + get api_vms_url, :params => { :expand => "resources", :filter => ["host.hardware.memory_mb>1024"] } expect_bad_request(/Filtering of attributes with more than one association away is not supported/) end @@ -436,7 +471,7 @@ def create_vms_by_name(names) vm_a = FactoryGirl.create(:vm, :host => host_a) _vm_b = FactoryGirl.create(:vm, :host => host_b) - get(api_vms_url, :filter => ["host_name='aa'"], :expand => "resources") + get(api_vms_url, :params => { :filter => ["host_name='aa'"], :expand => "resources" }) expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => vm_a.name, "guid" => vm_a.guid}]) @@ -448,7 +483,7 @@ def create_vms_by_name(names) vm_a = FactoryGirl.create(:vm, :host => host_a) _vm_b = FactoryGirl.create(:vm, :host => host_b) - get(api_vms_url, :filter => ["host_name='a%'"], :expand => "resources") + get(api_vms_url, :params => { :filter => ["host_name='a%'"], :expand => "resources" }) expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => vm_a.name, "guid" => vm_a.guid}]) @@ -461,7 +496,7 @@ def create_vms_by_name(names) _vm = FactoryGirl.create(:vm, :host => host, :ext_management_system => ems) archived_vm = FactoryGirl.create(:vm) - get(api_vms_url, :filter => ["archived=true"], :expand => "resources") + get(api_vms_url, :params => { :filter => ["archived=true"], :expand => "resources" }) expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => archived_vm.name, "guid" => archived_vm.guid}]) @@ -473,7 +508,7 @@ def create_vms_by_name(names) _vm_1 = FactoryGirl.create(:vm, :hardware => hardware_1) vm_2 = FactoryGirl.create(:vm, :hardware => hardware_2) - get(api_vms_url, :filter => ["num_cpu > 4"], :expand => "resources") + get(api_vms_url, :params => { :filter => ["num_cpu > 4"], :expand => "resources" }) expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => vm_2.name, "guid" => vm_2.guid}]) @@ -484,7 +519,7 @@ def create_vms_by_name(names) vm_2 = FactoryGirl.create(:vm, :retires_on => "2016-01-02", :vendor => "vmware") _vm_3 = FactoryGirl.create(:vm, :retires_on => "2016-01-02", :vendor => "openstack") - get(api_vms_url, :filter => ["retires_on = 2016-01-02", "vendor_display = VMware"]) + get(api_vms_url, :params => { :filter => ["retires_on = 2016-01-02", "vendor_display = VMware"] }) expected = {"resources" => [{"href" => api_vm_url(nil, vm_2.compressed_id)}]} expect(response.parsed_body).to include(expected) @@ -496,7 +531,7 @@ def create_vms_by_name(names) vm_2 = FactoryGirl.create(:vm, :retires_on => "2016-01-02", :vendor => "vmware") _vm_3 = FactoryGirl.create(:vm, :retires_on => "2016-01-03", :vendor => "openstack") - get(api_vms_url, :filter => ["retires_on > 2016-01-01", "vendor_display = VMware"]) + get(api_vms_url, :params => { :filter => ["retires_on > 2016-01-01", "vendor_display = VMware"] }) expected = {"resources" => [{"href" => api_vm_url(nil, vm_2.compressed_id)}]} expect(response.parsed_body).to include(expected) @@ -508,7 +543,7 @@ def create_vms_by_name(names) vm_2 = FactoryGirl.create(:vm, :last_scan_on => "2016-01-01T08:00:00Z", :vendor => "vmware") _vm_3 = FactoryGirl.create(:vm, :last_scan_on => "2016-01-01T08:00:00Z", :vendor => "openstack") - get(api_vms_url, :filter => ["last_scan_on > 2016-01-01T07:59:59Z", "vendor_display = VMware"]) + get(api_vms_url, :params => { :filter => ["last_scan_on > 2016-01-01T07:59:59Z", "vendor_display = VMware"] }) expected = {"resources" => [{"href" => api_vm_url(nil, vm_2.compressed_id)}]} expect(response.parsed_body).to include(expected) @@ -520,7 +555,7 @@ def create_vms_by_name(names) vm_2 = FactoryGirl.create(:vm, :retires_on => "2016-01-02", :vendor => "vmware") _vm_3 = FactoryGirl.create(:vm, :retires_on => "2016-01-03", :vendor => "vmware") - get(api_vms_url, :filter => ["retires_on < 2016-01-03", "vendor_display = VMware"]) + get(api_vms_url, :params => { :filter => ["retires_on < 2016-01-03", "vendor_display = VMware"] }) expected = {"resources" => [{"href" => api_vm_url(nil, vm_2.compressed_id)}]} expect(response.parsed_body).to include(expected) @@ -532,7 +567,7 @@ def create_vms_by_name(names) vm_2 = FactoryGirl.create(:vm, :last_scan_on => "2016-01-01T07:59:59Z", :vendor => "vmware") _vm_3 = FactoryGirl.create(:vm, :last_scan_on => "2016-01-01T08:00:00Z", :vendor => "vmware") - get(api_vms_url, :filter => ["last_scan_on < 2016-01-01T08:00:00Z", "vendor_display = VMware"]) + get(api_vms_url, :params => { :filter => ["last_scan_on < 2016-01-01T08:00:00Z", "vendor_display = VMware"] }) expected = {"resources" => [{"href" => api_vm_url(nil, vm_2.compressed_id)}]} expect(response.parsed_body).to include(expected) @@ -540,28 +575,28 @@ def create_vms_by_name(names) end it "does not support filtering with <= with datetimes" do - get(api_vms_url, :filter => ["retires_on <= 2016-01-03"]) + get(api_vms_url, :params => { :filter => ["retires_on <= 2016-01-03"] }) expect(response.parsed_body).to include_error_with_message("Unsupported operator for datetime: <=") expect(response).to have_http_status(:bad_request) end it "does not support filtering with >= with datetimes" do - get(api_vms_url, :filter => ["retires_on >= 2016-01-03"]) + get(api_vms_url, :params => { :filter => ["retires_on >= 2016-01-03"] }) expect(response.parsed_body).to include_error_with_message("Unsupported operator for datetime: >=") expect(response).to have_http_status(:bad_request) end it "does not support filtering with != with datetimes" do - get(api_vms_url, :filter => ["retires_on != 2016-01-03"]) + get(api_vms_url, :params => { :filter => ["retires_on != 2016-01-03"] }) expect(response.parsed_body).to include_error_with_message("Unsupported operator for datetime: !=") expect(response).to have_http_status(:bad_request) end it "will handle poorly formed datetimes in the filter" do - get(api_vms_url, :filter => ["retires_on > foobar"]) + get(api_vms_url, :params => { :filter => ["retires_on > foobar"] }) expect(response.parsed_body).to include_error_with_message("Bad format for datetime: foobar") expect(response).to have_http_status(:bad_request) @@ -572,7 +607,7 @@ def create_vms_by_name(names) service << FactoryGirl.create(:vm_vmware, :name => "foo") service << FactoryGirl.create(:vm_vmware, :name => "bar") - get(api_service_vms_url(nil, service), :filter => ["name=foo"]) + get(api_service_vms_url(nil, service), :params => { :filter => ["name=foo"] }) expect(response.parsed_body).to include_error_with_message("Filtering is not supported on vms subcollection") expect(response).to have_http_status(:bad_request) @@ -583,7 +618,7 @@ def create_vms_by_name(names) _tag_2 = FactoryGirl.create(:tag, :name => "/managed/bar") api_basic_authorize collection_action_identifier(:tags, :read, :get) - get(api_tags_url, :filter => ["name='*/foo'"]) + get(api_tags_url, :params => { :filter => ["name='*/foo'"] }) expected = { "count" => 2, @@ -597,8 +632,13 @@ def create_vms_by_name(names) it "supports filtering by compressed id" do vm1, _vm2 = create_vms_by_name(%w(aa bb)) - get api_vms_url, :expand => "resources", - :filter => ["id = #{ApplicationRecord.compress_id(vm1.id)}"] + get( + api_vms_url, + :params => { + :expand => "resources", + :filter => ["id = #{ApplicationRecord.compress_id(vm1.id)}"] + } + ) expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => vm1.name, "guid" => vm1.guid}]) @@ -607,8 +647,13 @@ def create_vms_by_name(names) it "supports filtering by compressed id as string" do _vm1, vm2 = create_vms_by_name(%w(aa bb)) - get api_vms_url, :expand => "resources", - :filter => ["id = '#{ApplicationRecord.compress_id(vm2.id)}'"] + get( + api_vms_url, + :params => { + :expand => "resources", + :filter => ["id = '#{ApplicationRecord.compress_id(vm2.id)}'"] + } + ) expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => vm2.name, "guid" => vm2.guid}]) @@ -629,15 +674,20 @@ def create_vms_by_name(names) :ext_management_system => ems2, :raw_power_state => "poweredOff") - get api_vms_url, :expand => "resources", - :filter => ["ems_id = #{ApplicationRecord.compress_id(ems2.id)}"] + get( + api_vms_url, + :params => { + :expand => "resources", + :filter => ["ems_id = #{ApplicationRecord.compress_id(ems2.id)}"] + } + ) expect_query_result(:vms, 1, 2) expect_result_resources_to_match_hash([{"name" => vm2.name, "guid" => vm2.guid}]) end it "returns a bad request if trying to filter on invalid attributes" do - get(api_vms_url, :filter => ["destroy=true"]) + get(api_vms_url, :params => { :filter => ["destroy=true"] }) expected = { "error" => a_hash_including( @@ -655,7 +705,7 @@ def create_vms_by_name(names) api_basic_authorize collection_action_identifier(:vms, :read, :get) vm = create_vms_by_name(%w(aa)).first - get api_vms_url, :expand => "resources", :attributes => "href_slug,name,vendor" + get api_vms_url, :params => { :expand => "resources", :attributes => "href_slug,name,vendor" } expected = { "name" => "vms", @@ -686,7 +736,7 @@ def create_vms_by_name(names) Classification.classify(vm1, "department", "finance") Classification.classify(vm3, "department", "finance") - get api_vms_url, :expand => "resources", :by_tag => "/department/finance" + get api_vms_url, :params => { :expand => "resources", :by_tag => "/department/finance" } expect_query_result(:vms, 2, 3) expect_result_resources_to_include_data("resources", "name" => [vm1.name, vm3.name]) @@ -705,7 +755,7 @@ def create_vms_by_name(names) Classification.classify(vm1, "cc", "cc01") Classification.classify(vm3, "department", "finance") - get api_vms_url, :expand => "resources", :by_tag => "/department/finance,/cc/cc01" + get api_vms_url, :params => { :expand => "resources", :by_tag => "/department/finance,/cc/cc01" } expect_query_result(:vms, 1, 3) expect_result_resources_to_include_data("resources", "name" => [vm1.name]) @@ -716,13 +766,13 @@ def create_vms_by_name(names) before { api_basic_authorize collection_action_identifier(:vms, :read, :get) } it "and sorted by name succeeeds with unreferenced class" do - get api_vms_url, :sort_by => "name", :expand => "resources" + get api_vms_url, :params => { :sort_by => "name", :expand => "resources" } expect_query_result(:vms, 0, 0) end it "by invalid attribute" do - get api_vms_url, :sort_by => "bad_attribute", :expand => "resources" + get api_vms_url, :params => { :sort_by => "bad_attribute", :expand => "resources" } expect_bad_request("bad_attribute is not a valid attribute") end @@ -745,7 +795,7 @@ def create_vms_by_name(names) it "supports expanding resources" do create_vms_by_name(%w(aa bb)) - get api_vms_url, :expand => "resources" + get api_vms_url, :params => { :expand => "resources" } expect_query_result(:vms, 2, 2) expect_result_resources_to_include_keys("resources", %w(id href guid name vendor)) @@ -755,7 +805,7 @@ def create_vms_by_name(names) vm1 = create_vms_by_name(%w(aa)).first FactoryGirl.create(:guest_application, :vm_or_template_id => vm1.id, :name => "LibreOffice") - get api_vms_url, :expand => "resources,software" + get api_vms_url, :params => { :expand => "resources,software" } expect_query_result(:vms, 1, 1) expect_result_resources_to_include_keys("resources", %w(id href guid name vendor software)) @@ -764,7 +814,7 @@ def create_vms_by_name(names) it "supports suppressing resources" do FactoryGirl.create(:vm) - get(api_vms_url, :hide => "resources") + get(api_vms_url, :params => { :hide => "resources" }) expect(response.parsed_body).not_to include("resources") expect(response).to have_http_status(:ok) @@ -877,7 +927,7 @@ def create_vms_by_name(names) it "returns actions if asked for with physical attributes" do api_basic_authorize action_identifier(:vms, :start), action_identifier(:vms, :read, :resource_actions, :get) - get api_vm_url(nil, vm1), :attributes => "name,vendor,actions" + get api_vm_url(nil, vm1), :params => { :attributes => "name,vendor,actions" } expect(response).to have_http_status(:ok) expect_result_to_have_only_keys(%w(id href name vendor actions)) @@ -886,7 +936,7 @@ def create_vms_by_name(names) it "does not return actions if asking for a physical attribute" do api_basic_authorize action_identifier(:vms, :start), action_identifier(:vms, :read, :resource_actions, :get) - get api_vm_url(nil, vm1), :attributes => "name" + get api_vm_url(nil, vm1), :params => { :attributes => "name" } expect(response).to have_http_status(:ok) expect_result_to_have_only_keys(%w(id href name)) @@ -895,7 +945,7 @@ def create_vms_by_name(names) it "does return actions if asking for virtual attributes" do api_basic_authorize action_identifier(:vms, :start), action_identifier(:vms, :read, :resource_actions, :get) - get api_vm_url(nil, vm1), :attributes => "disconnected" + get api_vm_url(nil, vm1), :params => { :attributes => "disconnected" } expect(response).to have_http_status(:ok) expect_result_to_have_keys(%w(id href name vendor disconnected actions)) @@ -904,7 +954,7 @@ def create_vms_by_name(names) it "does not return actions if asking for physical and virtual attributes" do api_basic_authorize action_identifier(:vms, :start), action_identifier(:vms, :read, :resource_actions, :get) - get api_vm_url(nil, vm1), :attributes => "name,disconnected" + get api_vm_url(nil, vm1), :params => { :attributes => "name,disconnected" } expect(response).to have_http_status(:ok) expect_result_to_have_only_keys(%w(id href name disconnected)) @@ -922,7 +972,7 @@ def create_vms_by_name(names) before { api_basic_authorize collection_action_identifier(:vms, :read, :get) } it "fail with invalid collection_class specified" do - get api_vms_url, :collection_class => "BogusClass" + get api_vms_url, :params => { :collection_class => "BogusClass" } expect_bad_request("Invalid collection_class BogusClass specified for the vms collection") end @@ -930,7 +980,7 @@ def create_vms_by_name(names) it "succeed with collection_class matching the collection class" do create_vms_by_name(%w(aa bb)) - get api_vms_url, :collection_class => "Vm" + get api_vms_url, :params => { :collection_class => "Vm" } expect_query_result(:vms, 2, 2) end @@ -940,7 +990,7 @@ def create_vms_by_name(names) FactoryGirl.create(:vm_vmware_cloud, :name => "bb") FactoryGirl.create(:vm_vmware_cloud, :name => "cc") - get api_vms_url, :expand => "resources", :collection_class => "Vm" + get api_vms_url, :params => { :expand => "resources", :collection_class => "Vm" } expect_query_result(:vms, 3, 3) expect(response.parsed_body["resources"].collect { |vm| vm["name"] }).to match_array(%w(aa bb cc)) @@ -951,7 +1001,7 @@ def create_vms_by_name(names) FactoryGirl.create(:vm_vmware_cloud, :name => "bb") vmcc = FactoryGirl.create(:vm_vmware_cloud, :name => "cc") - get api_vms_url, :expand => "resources", :collection_class => vmcc.class.name + get api_vms_url, :params => { :expand => "resources", :collection_class => vmcc.class.name } expect_query_result(:vms, 2, 2) expect(response.parsed_body["resources"].collect { |vm| vm["name"] }).to match_array(%w(bb cc)) diff --git a/spec/requests/reports_spec.rb b/spec/requests/reports_spec.rb index 90a91fb7f8..02110763f4 100644 --- a/spec/requests/reports_spec.rb +++ b/spec/requests/reports_spec.rb @@ -21,7 +21,7 @@ FactoryGirl.create(:miq_report_with_results) api_basic_authorize collection_action_identifier(:reports, :read, :get) - get api_reports_url, :expand => 'resources', :attributes => 'template_type' + get api_reports_url, :params => { :expand => 'resources', :attributes => 'template_type' } expect(response).to have_http_status(:ok) response.parsed_body['resources'].each { |res| expect_hash_to_have_only_keys(res, %w(href id template_type)) } @@ -208,7 +208,7 @@ expect do api_basic_authorize action_identifier(:reports, :run) - post api_report_url(nil, report).to_s, :action => "run" + post api_report_url(nil, report).to_s, :params => { :action => "run" } end.to change(MiqReportResult, :count).by(1) expect_single_action_result( :href => api_report_url(nil, report.compressed_id), @@ -224,14 +224,18 @@ expect do api_basic_authorize action_identifier(:reports, :schedule) - post api_report_url(nil, report), - :action => 'schedule', - :name => 'schedule_name', - :enabled => true, - :description => 'unit test', - :start_date => '05/05/2016', - :interval => {:unit => 'daily', :value => '110'}, - :time_zone => 'UTC' + post( + api_report_url(nil, report), + :params => { + :action => 'schedule', + :name => 'schedule_name', + :enabled => true, + :description => 'unit test', + :start_date => '05/05/2016', + :interval => {:unit => 'daily', :value => '110'}, + :time_zone => 'UTC' + } + ) end.to change(MiqSchedule, :count).by(1) expect_single_action_result( :href => api_report_url(nil, report.compressed_id), @@ -255,7 +259,7 @@ api_basic_authorize collection_action_identifier(:reports, :import) expect do - post api_reports_url, gen_request(:import, :report => serialized_report, :options => options) + post api_reports_url, :params => gen_request(:import, :report => serialized_report, :options => options) end.to change(MiqReport, :count).by(1) expect_result_to_match_hash( response.parsed_body["results"].first["result"], @@ -301,7 +305,7 @@ expect do post( api_reports_url, - gen_request( + :params => gen_request( :import, [{:report => serialized_report, :options => options}, {:report => serialized_report2, :options => options}] @@ -317,7 +321,7 @@ expect do api_basic_authorize - post api_report_url(nil, report).to_s, :action => "run" + post api_report_url(nil, report).to_s, :params => { :action => "run" } end.not_to change(MiqReportResult, :count) expect(response).to have_http_status(:forbidden) end @@ -337,7 +341,7 @@ api_basic_authorize expect do - post api_reports_url, gen_request(:import, :report => serialized_report, :options => options) + post api_reports_url, :params => gen_request(:import, :report => serialized_report, :options => options) end.not_to change(MiqReport, :count) expect(response).to have_http_status(:forbidden) end diff --git a/spec/requests/requests_spec.rb b/spec/requests/requests_spec.rb index e38c90b33b..ff441bdc5d 100644 --- a/spec/requests/requests_spec.rb +++ b/spec/requests/requests_spec.rb @@ -121,7 +121,7 @@ it "is forbidden for a user to create a request without appropriate role" do api_basic_authorize - post(api_requests_url, gen_request(:create, :options => { :request_type => "service_reconfigure" })) + post(api_requests_url, :params => gen_request(:create, :options => { :request_type => "service_reconfigure" })) expect(response).to have_http_status(:forbidden) end @@ -129,7 +129,7 @@ it "is forbidden for a user to create a request with a different request role" do api_basic_authorize :vm_reconfigure - post(api_requests_url, gen_request(:create, :options => { :request_type => "service_reconfigure" })) + post(api_requests_url, :params => gen_request(:create, :options => { :request_type => "service_reconfigure" })) expect(response).to have_http_status(:forbidden) end @@ -137,7 +137,7 @@ it "fails if the request_type is missing" do api_basic_authorize - post(api_requests_url, gen_request(:create, :options => { :src_id => 4 })) + post(api_requests_url, :params => gen_request(:create, :options => { :src_id => 4 })) expect_bad_request(/Invalid request - /) end @@ -145,10 +145,10 @@ it "fails if the request_type is unknown" do api_basic_authorize - post(api_requests_url, gen_request(:create, - :options => { - :request_type => "invalid_request" - })) + post(api_requests_url, :params => gen_request(:create, + :options => { + :request_type => "invalid_request" + })) expect_bad_request(/Invalid request - /) end @@ -156,7 +156,7 @@ it "fails if the request is missing a src_id" do api_basic_authorize :service_reconfigure - post(api_requests_url, gen_request(:create, :options => { :request_type => "service_reconfigure" })) + post(api_requests_url, :params => gen_request(:create, :options => { :request_type => "service_reconfigure" })) expect_bad_request(/Could not create the request - /) end @@ -164,12 +164,12 @@ it "fails if the requester is invalid" do api_basic_authorize :service_reconfigure - post(api_requests_url, gen_request(:create, - :options => { - :request_type => "service_reconfigure", - :src_id => 4 - }, - :requester => { "user_name" => "invalid_user"})) + post(api_requests_url, :params => gen_request(:create, + :options => { + :request_type => "service_reconfigure", + :src_id => 4 + }, + :requester => { "user_name" => "invalid_user"})) expect_bad_request(/Unknown requester user_name invalid_user specified/) end @@ -178,12 +178,12 @@ api_basic_authorize :service_reconfigure service = FactoryGirl.create(:service, :name => "service1") - post(api_requests_url, gen_request(:create, - :options => { - :request_type => "service_reconfigure", - :src_id => service.id - }, - :auto_approve => false)) + post(api_requests_url, :params => gen_request(:create, + :options => { + :request_type => "service_reconfigure", + :src_id => service.id + }, + :auto_approve => false)) expected = { "results" => [ @@ -205,14 +205,14 @@ approver = FactoryGirl.create(:user_miq_request_approver) service = FactoryGirl.create(:service, :name => "service1") - post(api_requests_url, gen_request(:create, - :options => { - :request_type => "service_reconfigure", - :src_id => service.id, - :other_attr => "other value" - }, - :requester => { "user_name" => approver.userid }, - :auto_approve => true)) + post(api_requests_url, :params => gen_request(:create, + :options => { + :request_type => "service_reconfigure", + :src_id => service.id, + :other_attr => "other value" + }, + :requester => { "user_name" => approver.userid }, + :auto_approve => true)) expected = { "results" => [ @@ -246,7 +246,7 @@ request.add_tag(t.name, t.children.first.name) api_basic_authorize action_identifier(:requests, :read, :resource_actions, :get) - get api_request_url(nil, request), :attributes => "workflow,v_allowed_tags,v_workflow_class" + get api_request_url(nil, request), :params => { :attributes => "workflow,v_allowed_tags,v_workflow_class" } expected_response = a_hash_including( "id" => request.compressed_id, @@ -277,7 +277,7 @@ request.add_tag(t.name, t.children.first.name) api_basic_authorize action_identifier(:requests, :read, :resource_actions, :get) - get api_request_url(nil, request), :attributes => "workflow.values" + get api_request_url(nil, request), :params => { :attributes => "workflow.values" } expected_response = a_hash_including( "id" => request.compressed_id, @@ -297,7 +297,7 @@ :source_type => vm_template.class.name) api_basic_authorize action_identifier(:requests, :read, :resource_actions, :get) - get api_request_url(nil, request), :attributes => "workflow,v_allowed_tags,v_workflow_class" + get api_request_url(nil, request), :params => { :attributes => "workflow,v_allowed_tags,v_workflow_class" } expected_response = a_hash_including( "id" => request.compressed_id, @@ -315,7 +315,7 @@ it "is forbidden for a user without appropriate role" do api_basic_authorize - post(api_requests_url, gen_request(:edit)) + post(api_requests_url, :params => gen_request(:edit)) expect(response).to have_http_status(:forbidden) end @@ -323,7 +323,7 @@ it "fails with an invalid request id" do api_basic_authorize collection_action_identifier(:requests, :edit) - post(api_request_url(nil, 999_999), gen_request(:edit, :options => { :some_option => "some_value" })) + post(api_request_url(nil, 999_999), :params => gen_request(:edit, :options => { :some_option => "some_value" })) expected = { "error" => a_hash_including( @@ -340,7 +340,7 @@ service = FactoryGirl.create(:service, :name => "service1") request = ServiceReconfigureRequest.create_request({ :src_id => service.id }, @user, false) - post(api_request_url(nil, request), gen_request(:edit, :options => { :some_option => "some_value" })) + post(api_request_url(nil, request), :params => gen_request(:edit, :options => { :some_option => "some_value" })) expected = { "id" => request.compressed_id, @@ -356,7 +356,7 @@ service = FactoryGirl.create(:service, :name => "service1") ServiceReconfigureRequest.create_request({:src_id => service.id}, @user, false) - post(api_requests_url, gen_request(:edit, :options => {:some_option => "some_value"})) + post(api_requests_url, :params => gen_request(:edit, :options => {:some_option => "some_value"})) expect(response.parsed_body).to include_error_with_message(/Must specify a id/) expect(response).to have_http_status(:bad_request) @@ -375,7 +375,7 @@ it "supports approving a request" do api_basic_authorize collection_action_identifier(:requests, :approve) - post(request1_url, gen_request(:approve, :reason => "approval reason")) + post(request1_url, :params => gen_request(:approve, :reason => "approval reason")) expected_msg = "Request #{request1.id} approved" expect_single_action_result(:success => true, :message => expected_msg, :href => api_request_url(nil, request1.compressed_id)) @@ -384,7 +384,7 @@ it "fails approving a request if the reason is missing" do api_basic_authorize collection_action_identifier(:requests, :approve) - post(request1_url, gen_request(:approve)) + post(request1_url, :params => gen_request(:approve)) expected_msg = /Must specify a reason for approving a request/ expect_single_action_result(:success => false, :message => expected_msg) @@ -393,7 +393,7 @@ it "supports denying a request" do api_basic_authorize collection_action_identifier(:requests, :deny) - post(request1_url, gen_request(:deny, :reason => "denial reason")) + post(request1_url, :params => gen_request(:deny, :reason => "denial reason")) expected_msg = "Request #{request1.id} denied" expect_single_action_result(:success => true, :message => expected_msg, :href => api_request_url(nil, request1.compressed_id)) @@ -402,7 +402,7 @@ it "fails denying a request if the reason is missing" do api_basic_authorize collection_action_identifier(:requests, :deny) - post(request1_url, gen_request(:deny)) + post(request1_url, :params => gen_request(:deny)) expected_msg = /Must specify a reason for denying a request/ expect_single_action_result(:success => false, :message => expected_msg) @@ -411,8 +411,8 @@ it "supports approving multiple requests" do api_basic_authorize collection_action_identifier(:requests, :approve) - post(api_requests_url, gen_request(:approve, [{:href => request1_url, :reason => "approval reason"}, - {:href => request2_url, :reason => "approval reason"}])) + post(api_requests_url, :params => gen_request(:approve, [{:href => request1_url, :reason => "approval reason"}, + {:href => request2_url, :reason => "approval reason"}])) expected = { "results" => a_collection_containing_exactly( @@ -435,8 +435,8 @@ it "supports denying multiple requests" do api_basic_authorize collection_action_identifier(:requests, :approve) - post(api_requests_url, gen_request(:deny, [{:href => request1_url, :reason => "denial reason"}, - {:href => request2_url, :reason => "denial reason"}])) + post(api_requests_url, :params => gen_request(:deny, [{:href => request1_url, :reason => "denial reason"}, + {:href => request2_url, :reason => "denial reason"}])) expected = { "results" => a_collection_containing_exactly( @@ -463,7 +463,7 @@ automation_request = FactoryGirl.create(:automation_request, :requester => @user) api_basic_authorize collection_action_identifier(:requests, :read, :get) - get api_requests_url, :expand => :resources + get api_requests_url, :params => { :expand => :resources } expected = [ a_hash_including('href' => a_string_including(api_request_url(nil, provision_request.compressed_id))), diff --git a/spec/requests/roles_spec.rb b/spec/requests/roles_spec.rb index 6e26dcfa3c..88a27d985f 100644 --- a/spec/requests/roles_spec.rb +++ b/spec/requests/roles_spec.rb @@ -62,7 +62,7 @@ def test_features_query(role, role_url, klass, attr = :id) api_basic_authorize action_identifier(:roles, :read, :resource_actions, :get) - get role_url, :expand => "features" + get role_url, :params => { :expand => "features" } expect(response).to have_http_status(:ok) expect(response.parsed_body).to have_key("name") @@ -84,7 +84,7 @@ def test_features_query(role, role_url, klass, attr = :id) it 'returns only the requested attributes' do api_basic_authorize action_identifier(:roles, :read, :collection_actions, :get) - get api_roles_url, :expand => 'resources', :attributes => 'name' + get api_roles_url, :params => { :expand => 'resources', :attributes => 'name' } expect(response).to have_http_status(:ok) response.parsed_body['resources'].each { |res| expect_hash_to_have_only_keys(res, %w(href id name)) } @@ -95,7 +95,7 @@ def test_features_query(role, role_url, klass, attr = :id) it "rejects creation without appropriate role" do api_basic_authorize - post(api_roles_url, sample_role1) + post(api_roles_url, :params => sample_role1) expect(response).to have_http_status(:forbidden) end @@ -103,7 +103,7 @@ def test_features_query(role, role_url, klass, attr = :id) it "rejects role creation with id specified" do api_basic_authorize collection_action_identifier(:roles, :create) - post(api_roles_url, "name" => "sample role", "id" => 100) + post(api_roles_url, :params => { "name" => "sample role", "id" => 100 }) expect_bad_request(/id or href should not be specified/i) end @@ -111,14 +111,14 @@ def test_features_query(role, role_url, klass, attr = :id) it "supports single role creation" do api_basic_authorize collection_action_identifier(:roles, :create) - post(api_roles_url, sample_role1) + post(api_roles_url, :params => sample_role1) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_attributes) role_id = ApplicationRecord.uncompress_id(response.parsed_body["results"].first["id"]) - get(api_role_url(nil, role_id), :expand => "features") + get(api_role_url(nil, role_id), :params => { :expand => "features" }) role = MiqUserRole.find(role_id) @@ -130,7 +130,7 @@ def test_features_query(role, role_url, klass, attr = :id) it "supports single role creation via action" do api_basic_authorize collection_action_identifier(:roles, :create) - post(api_roles_url, gen_request(:create, sample_role1)) + post(api_roles_url, :params => gen_request(:create, sample_role1)) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_attributes) @@ -145,7 +145,7 @@ def test_features_query(role, role_url, klass, attr = :id) it "supports multiple role creation" do api_basic_authorize collection_action_identifier(:roles, :create) - post(api_roles_url, gen_request(:create, [sample_role1, sample_role2])) + post(api_roles_url, :params => gen_request(:create, [sample_role1, sample_role2])) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_attributes) @@ -170,7 +170,7 @@ def test_features_query(role, role_url, klass, attr = :id) it "rejects role edits without appropriate role" do role = FactoryGirl.create(:miq_user_role) api_basic_authorize - post(api_roles_url, gen_request(:edit, "name" => "role name", "href" => api_role_url(nil, role.compressed_id))) + post(api_roles_url, :params => gen_request(:edit, "name" => "role name", "href" => api_role_url(nil, role.compressed_id))) expect(response).to have_http_status(:forbidden) end @@ -178,7 +178,7 @@ def test_features_query(role, role_url, klass, attr = :id) it "rejects role edits for invalid resources" do api_basic_authorize collection_action_identifier(:roles, :edit) - post(api_role_url(nil, 999_999), gen_request(:edit, "name" => "updated role name")) + post(api_role_url(nil, 999_999), :params => gen_request(:edit, "name" => "updated role name")) expect(response).to have_http_status(:not_found) end @@ -188,8 +188,14 @@ def test_features_query(role, role_url, klass, attr = :id) role = FactoryGirl.create(:miq_user_role) - post(api_role_url(nil, role), gen_request(:edit, "name" => "updated role", - "settings" => {"restrictions" => {"vms" => "user_or_group"}})) + post( + api_role_url(nil, role), + :params => gen_request( + :edit, + "name" => "updated role", + "settings" => {"restrictions" => {"vms" => "user_or_group"}} + ) + ) expect_single_resource_query("id" => role.compressed_id, "name" => "updated role", @@ -204,9 +210,9 @@ def test_features_query(role, role_url, klass, attr = :id) r1 = FactoryGirl.create(:miq_user_role, :name => "role1") r2 = FactoryGirl.create(:miq_user_role, :name => "role2") - post(api_roles_url, gen_request(:edit, - [{"href" => api_role_url(nil, r1), "name" => "updated role1"}, - {"href" => api_role_url(nil, r2), "name" => "updated role2"}])) + post(api_roles_url, :params => gen_request(:edit, + [{"href" => api_role_url(nil, r1), "name" => "updated role1"}, + {"href" => api_role_url(nil, r2), "name" => "updated role2"}])) expect_results_to_match_hash("results", [{"id" => r1.compressed_id, "name" => "updated role1"}, @@ -224,7 +230,7 @@ def test_features_query(role, role_url, klass, attr = :id) new_feature = {:identifier => "miq_request_view"} url = api_role_features_url(nil, role) - post(url, gen_request(:assign, new_feature)) + post(url, :params => gen_request(:assign, new_feature)) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", %w(id name read_only)) @@ -243,7 +249,7 @@ def test_features_query(role, role_url, klass, attr = :id) api_basic_authorize collection_action_identifier(:roles, :edit) role = FactoryGirl.create(:miq_user_role, :features => "miq_request_approval") - post(api_role_features_url(nil, role), gen_request(:assign, features_list)) + post(api_role_features_url(nil, role), :params => gen_request(:assign, features_list)) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", %w(id name read_only)) @@ -266,7 +272,7 @@ def test_features_query(role, role_url, klass, attr = :id) removed_feature = {:identifier => "ems_infra_tag"} url = api_role_features_url(nil, role) - post(url, gen_request(:unassign, removed_feature)) + post(url, :params => gen_request(:unassign, removed_feature)) expect(response).to have_http_status(:ok) # Confirm that we've only removed ems_infra_tag @@ -290,7 +296,7 @@ def test_features_query(role, role_url, klass, attr = :id) role = FactoryGirl.create(:miq_user_role, :miq_product_features => @product_features) url = api_role_features_url(nil, role) - post(url, gen_request(:unassign, features_list)) + post(url, :params => gen_request(:unassign, features_list)) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", %w(id name read_only)) @@ -317,7 +323,7 @@ def test_features_query(role, role_url, klass, attr = :id) it "rejects role deletion, by post action, without appropriate role" do api_basic_authorize - post(api_roles_url, gen_request(:delete, "name" => "role name", "href" => api_role_url(nil, 100))) + post(api_roles_url, :params => gen_request(:delete, "name" => "role name", "href" => api_role_url(nil, 100))) expect(response).to have_http_status(:forbidden) end @@ -354,7 +360,7 @@ def test_features_query(role, role_url, klass, attr = :id) role = FactoryGirl.create(:miq_user_role, :name => "role1") - post(api_role_url(nil, role), gen_request(:delete)) + post(api_role_url(nil, role), :params => gen_request(:delete)) expect(response).to have_http_status(:ok) expect(MiqUserRole.exists?(role.id)).to be_falsey @@ -366,9 +372,9 @@ def test_features_query(role, role_url, klass, attr = :id) r1 = FactoryGirl.create(:miq_user_role, :name => "role name 1") r2 = FactoryGirl.create(:miq_user_role, :name => "role name 2") - post(api_roles_url, gen_request(:delete, - [{"href" => api_role_url(nil, r1)}, - {"href" => api_role_url(nil, r2)}])) + post(api_roles_url, :params => gen_request(:delete, + [{"href" => api_role_url(nil, r1)}, + {"href" => api_role_url(nil, r2)}])) expect(response).to have_http_status(:ok) expect(MiqUserRole.exists?(r1.id)).to be_falsey diff --git a/spec/requests/service_catalogs_spec.rb b/spec/requests/service_catalogs_spec.rb index 8527f351a5..7561457272 100644 --- a/spec/requests/service_catalogs_spec.rb +++ b/spec/requests/service_catalogs_spec.rb @@ -32,7 +32,7 @@ def sc_template_url(id, st_id = nil) FactoryGirl.create(:service_template_catalog) api_basic_authorize collection_action_identifier(:service_catalogs, :read, :get) - get api_service_catalogs_url, :expand => 'resources', :attributes => 'name' + get api_service_catalogs_url, :params => { :expand => 'resources', :attributes => 'name' } expect(response).to have_http_status(:ok) response.parsed_body['resources'].each { |res| expect_hash_to_have_only_keys(res, %w(href id name)) } @@ -43,7 +43,7 @@ def sc_template_url(id, st_id = nil) it "rejects resource creation without appropriate role" do api_basic_authorize - post(api_service_catalogs_url, gen_request(:add, "name" => "sample service catalog")) + post(api_service_catalogs_url, :params => gen_request(:add, "name" => "sample service catalog")) expect(response).to have_http_status(:forbidden) end @@ -51,7 +51,7 @@ def sc_template_url(id, st_id = nil) it "rejects resource creation via create action without appropriate role" do api_basic_authorize - post(api_service_catalogs_url, "name" => "sample service catalog") + post(api_service_catalogs_url, :params => { "name" => "sample service catalog" }) expect(response).to have_http_status(:forbidden) end @@ -59,7 +59,7 @@ def sc_template_url(id, st_id = nil) it "rejects resource creation with id specified" do api_basic_authorize collection_action_identifier(:service_catalogs, :add) - post(api_service_catalogs_url, gen_request(:add, "name" => "sample service catalog", "id" => 100)) + post(api_service_catalogs_url, :params => gen_request(:add, "name" => "sample service catalog", "id" => 100)) expect_bad_request(/id or href should not be specified/i) end @@ -67,7 +67,7 @@ def sc_template_url(id, st_id = nil) it "supports single resource creation" do api_basic_authorize collection_action_identifier(:service_catalogs, :add) - post(api_service_catalogs_url, gen_request(:add, "name" => "sample service catalog")) + post(api_service_catalogs_url, :params => gen_request(:add, "name" => "sample service catalog")) expect(response).to have_http_status(:ok) expected = { @@ -88,7 +88,7 @@ def sc_template_url(id, st_id = nil) it "supports single resource creation via create action" do api_basic_authorize collection_action_identifier(:service_catalogs, :add) - post(api_service_catalogs_url, "name" => "sample service catalog") + post(api_service_catalogs_url, :params => { "name" => "sample service catalog" }) expect(response).to have_http_status(:ok) expected = { @@ -109,7 +109,7 @@ def sc_template_url(id, st_id = nil) it "supports multiple resource creation" do api_basic_authorize collection_action_identifier(:service_catalogs, :add) - post(api_service_catalogs_url, gen_request(:add, [{"name" => "sc1"}, {"name" => "sc2"}])) + post(api_service_catalogs_url, :params => gen_request(:add, [{"name" => "sc1"}, {"name" => "sc2"}])) expect(response).to have_http_status(:ok) expected = { @@ -133,13 +133,18 @@ def sc_template_url(id, st_id = nil) st1 = FactoryGirl.create(:service_template) st2 = FactoryGirl.create(:service_template) - post(api_service_catalogs_url, gen_request(:add, - "name" => "sc", - "description" => "sc description", - "service_templates" => [ - {"href" => api_service_template_url(nil, st1)}, - {"href" => api_service_template_url(nil, st2)} - ])) + post( + api_service_catalogs_url, + :params => gen_request( + :add, + "name" => "sc", + "description" => "sc description", + "service_templates" => [ + {"href" => api_service_template_url(nil, st1)}, + {"href" => api_service_template_url(nil, st2)} + ] + ) + ) expect(response).to have_http_status(:ok) expect_results_to_match_hash("results", [{"name" => "sc", "description" => "sc description"}]) @@ -155,7 +160,7 @@ def sc_template_url(id, st_id = nil) it "rejects resource edits without appropriate role" do api_basic_authorize - post(api_service_catalogs_url, gen_request(:edit, "name" => "sc1", "href" => api_service_catalog_url(nil, 999_999))) + post(api_service_catalogs_url, :params => gen_request(:edit, "name" => "sc1", "href" => api_service_catalog_url(nil, 999_999))) expect(response).to have_http_status(:forbidden) end @@ -163,7 +168,7 @@ def sc_template_url(id, st_id = nil) it "rejects edits for invalid resources" do api_basic_authorize collection_action_identifier(:service_catalogs, :edit) - post(api_service_catalog_url(nil, 999_999), gen_request(:edit, "description" => "updated sc description")) + post(api_service_catalog_url(nil, 999_999), :params => gen_request(:edit, "description" => "updated sc description")) expect(response).to have_http_status(:not_found) end @@ -173,7 +178,7 @@ def sc_template_url(id, st_id = nil) sc = FactoryGirl.create(:service_template_catalog, :name => "sc", :description => "sc description") - post(api_service_catalog_url(nil, sc), gen_request(:edit, "description" => "updated sc description")) + post(api_service_catalog_url(nil, sc), :params => gen_request(:edit, "description" => "updated sc description")) expected = { "service_templates" => a_hash_including( @@ -200,9 +205,9 @@ def sc_template_url(id, st_id = nil) sc1 = FactoryGirl.create(:service_template_catalog, :name => "sc1", :description => "sc1 description") sc2 = FactoryGirl.create(:service_template_catalog, :name => "sc2", :description => "sc2 description") - post(api_service_catalogs_url, gen_request(:edit, - [{"href" => api_service_catalog_url(nil, sc1), "name" => "sc1 updated"}, - {"href" => api_service_catalog_url(nil, sc2), "name" => "sc2 updated"}])) + post(api_service_catalogs_url, :params => gen_request(:edit, + [{"href" => api_service_catalog_url(nil, sc1), "name" => "sc1 updated"}, + {"href" => api_service_catalog_url(nil, sc2), "name" => "sc2 updated"}])) expect_results_to_match_hash("results", [{"id" => sc1.compressed_id, "name" => "sc1 updated", "description" => "sc1 description"}, @@ -217,7 +222,7 @@ def sc_template_url(id, st_id = nil) it "rejects deletion without appropriate role" do api_basic_authorize - post(api_service_catalogs_url, gen_request(:delete, "name" => "sc1", "href" => api_service_catalog_url(nil, 100))) + post(api_service_catalogs_url, :params => gen_request(:delete, "name" => "sc1", "href" => api_service_catalog_url(nil, 100))) expect(response).to have_http_status(:forbidden) end @@ -254,7 +259,7 @@ def sc_template_url(id, st_id = nil) sc = FactoryGirl.create(:service_template_catalog, :name => "sc", :description => "sc description") - post(api_service_catalog_url(nil, sc), gen_request(:delete)) + post(api_service_catalog_url(nil, sc), :params => gen_request(:delete)) expect_single_action_result(:success => true, :message => "deleting", :href => api_service_catalog_url(nil, sc.compressed_id)) expect { sc.reload }.to raise_error(ActiveRecord::RecordNotFound) @@ -266,9 +271,9 @@ def sc_template_url(id, st_id = nil) sc1 = FactoryGirl.create(:service_template_catalog, :name => "sc1", :description => "sc1 description") sc2 = FactoryGirl.create(:service_template_catalog, :name => "sc2", :description => "sc2 description") - post(api_service_catalogs_url, gen_request(:delete, - [{"href" => api_service_catalog_url(nil, sc1)}, - {"href" => api_service_catalog_url(nil, sc2)}])) + post(api_service_catalogs_url, :params => gen_request(:delete, + [{"href" => api_service_catalog_url(nil, sc1)}, + {"href" => api_service_catalog_url(nil, sc2)}])) expect_multiple_action_result(2) expect_result_resources_to_include_hrefs("results", [api_service_catalog_url(nil, sc1.compressed_id), api_service_catalog_url(nil, sc2.compressed_id)]) @@ -281,7 +286,7 @@ def sc_template_url(id, st_id = nil) it "rejects assign requests without appropriate role" do api_basic_authorize - post(sc_template_url(100), gen_request(:assign, "href" => api_service_template_url(nil, 1))) + post(sc_template_url(100), :params => gen_request(:assign, "href" => api_service_template_url(nil, 1))) expect(response).to have_http_status(:forbidden) end @@ -289,7 +294,7 @@ def sc_template_url(id, st_id = nil) it "rejects unassign requests without appropriate role" do api_basic_authorize - post(sc_template_url(100), gen_request(:unassign, "href" => api_service_template_url(nil, 1))) + post(sc_template_url(100), :params => gen_request(:unassign, "href" => api_service_template_url(nil, 1))) expect(response).to have_http_status(:forbidden) end @@ -299,7 +304,7 @@ def sc_template_url(id, st_id = nil) sc = FactoryGirl.create(:service_template_catalog, :name => "sc", :description => "sc description") - post(sc_template_url(sc.id), gen_request(:assign, "href" => api_service_template_url(nil, 999_999))) + post(sc_template_url(sc.id), :params => gen_request(:assign, "href" => api_service_template_url(nil, 999_999))) expect(response).to have_http_status(:ok) expect_results_to_match_hash("results", [{"success" => false, "href" => api_service_catalog_url(nil, sc.compressed_id)}]) @@ -311,7 +316,7 @@ def sc_template_url(id, st_id = nil) sc = FactoryGirl.create(:service_template_catalog, :name => "sc", :description => "sc description") st = FactoryGirl.create(:service_template) - post(sc_template_url(sc.id), gen_request(:assign, "href" => api_service_template_url(nil, st.compressed_id))) + post(sc_template_url(sc.id), :params => gen_request(:assign, "href" => api_service_template_url(nil, st.compressed_id))) expect(response).to have_http_status(:ok) expect_results_to_match_hash("results", @@ -331,7 +336,7 @@ def sc_template_url(id, st_id = nil) st2 = FactoryGirl.create(:service_template) sc.service_templates = [st1, st2] - post(sc_template_url(sc.id), gen_request(:unassign, "href" => api_service_template_url(nil, st1))) + post(sc_template_url(sc.id), :params => gen_request(:unassign, "href" => api_service_template_url(nil, st1))) expect(response).to have_http_status(:ok) expect_results_to_match_hash("results", @@ -401,7 +406,7 @@ def init_st(service_template, resource_action) it "rejects order requests without appropriate role" do api_basic_authorize - post(sc_template_url(100), gen_request(:order, "href" => api_service_template_url(nil, 1))) + post(sc_template_url(100), :params => gen_request(:order, "href" => api_service_template_url(nil, 1))) expect(response).to have_http_status(:forbidden) end @@ -412,7 +417,7 @@ def init_st(service_template, resource_action) init_st(st1, ra1) sc.service_templates = [st1] - post(sc_template_url(sc.id, st1.id), gen_request(:order)) + post(sc_template_url(sc.id, st1.id), :params => gen_request(:order)) expect_single_resource_query(order_request.merge("href" => /service_requests/)) end @@ -424,7 +429,7 @@ def init_st(service_template, resource_action) init_st(st1, ra1) sc.service_templates = [st1] - post(sc_template_url(sc.id, st1.id), gen_request(:order, "text1" => "value1")) + post(sc_template_url(sc.id, st1.id), :params => gen_request(:order, "text1" => "value1")) expect_single_resource_query(order_request) end @@ -436,7 +441,7 @@ def init_st(service_template, resource_action) init_st(st1, ra1) sc.service_templates = [st1] - post(sc_template_url(sc.id, st1.id), gen_request(:order)) + post(sc_template_url(sc.id, st1.id), :params => gen_request(:order)) expect_bad_request("Failed to order") end @@ -448,8 +453,8 @@ def init_st(service_template, resource_action) init_st(st2, ra2) sc.service_templates = [st1, st2] - post(sc_template_url(sc.id), gen_request(:order, [{"href" => api_service_template_url(nil, st1)}, - {"href" => api_service_template_url(nil, st2)}])) + post(sc_template_url(sc.id), :params => gen_request(:order, [{"href" => api_service_template_url(nil, st1)}, + {"href" => api_service_template_url(nil, st2)}])) expect(response).to have_http_status(:ok) expect_results_to_match_hash("results", [order_request, order_request]) end @@ -479,7 +484,7 @@ def init_st_dialog it "rejects refresh dialog fields requests without appropriate role" do api_basic_authorize - post(sc_template_url(sc.id, st1.id), gen_request(:refresh_dialog_fields, "fields" => %w(test1))) + post(sc_template_url(sc.id, st1.id), :params => gen_request(:refresh_dialog_fields, "fields" => %w(test1))) expect(response).to have_http_status(:forbidden) end @@ -488,7 +493,7 @@ def init_st_dialog api_basic_authorize subcollection_action_identifier(:service_catalogs, :service_templates, :refresh_dialog_fields) sc.service_templates = [st1] - post(sc_template_url(sc.id, st1.id), gen_request(:refresh_dialog_fields)) + post(sc_template_url(sc.id, st1.id), :params => gen_request(:refresh_dialog_fields)) expect_single_action_result(:success => false, :message => /must specify fields/i) end @@ -497,7 +502,7 @@ def init_st_dialog api_basic_authorize subcollection_action_identifier(:service_catalogs, :service_templates, :refresh_dialog_fields) init_st_dialog - post(sc_template_url(sc.id, st1.id), gen_request(:refresh_dialog_fields, "fields" => %w(bad_field))) + post(sc_template_url(sc.id, st1.id), :params => gen_request(:refresh_dialog_fields, "fields" => %w(bad_field))) expect_single_action_result(:success => false, :message => /unknown dialog field bad_field/i) end @@ -506,7 +511,7 @@ def init_st_dialog api_basic_authorize subcollection_action_identifier(:service_catalogs, :service_templates, :refresh_dialog_fields) init_st_dialog - post(sc_template_url(sc.id, st1.id), gen_request(:refresh_dialog_fields, "fields" => %w(text1))) + post(sc_template_url(sc.id, st1.id), :params => gen_request(:refresh_dialog_fields, "fields" => %w(text1))) expected = { "success" => true, diff --git a/spec/requests/service_dialogs_spec.rb b/spec/requests/service_dialogs_spec.rb index 6ce822f6b7..b9661a43be 100644 --- a/spec/requests/service_dialogs_spec.rb +++ b/spec/requests/service_dialogs_spec.rb @@ -32,7 +32,7 @@ it "query with expanded resources to include content" do api_basic_authorize collection_action_identifier(:service_dialogs, :read, :get) - get api_service_dialogs_url, :expand => "resources" + get api_service_dialogs_url, :params => { :expand => "resources" } expect_query_result(:service_dialogs, Dialog.count, Dialog.count) expect_result_resources_to_include_keys("resources", %w(id href label content)) @@ -53,7 +53,7 @@ it "query single dialog to exclude content when attributes are asked for" do api_basic_authorize action_identifier(:service_dialogs, :read, :resource_actions, :get) - get api_service_dialog_url(nil, dialog1), :attributes => "id,label" + get api_service_dialog_url(nil, dialog1), :params => { :attributes => "id,label" } expect_result_to_have_only_keys(%w(href id label)) end @@ -74,7 +74,7 @@ api_basic_authorize collection_action_identifier(:service_dialogs, :delete) expect do - post(api_service_dialog_url(nil, dialog), 'action' => 'delete') + post(api_service_dialog_url(nil, dialog), :params => { 'action' => 'delete' }) end.to change(Dialog, :count).by(-1) expect(response).to have_http_status(:ok) end @@ -84,7 +84,7 @@ api_basic_authorize collection_action_identifier(:service_dialogs, :delete) expect do - post(api_service_dialogs_url, 'action' => 'delete', 'resources' => [{ 'id' => dialog.id }]) + post(api_service_dialogs_url, :params => { 'action' => 'delete', 'resources' => [{ 'id' => dialog.id }] }) end.to change(Dialog, :count).by(-1) expect(response).to have_http_status(:ok) end @@ -94,8 +94,13 @@ api_basic_authorize collection_action_identifier(:service_dialogs, :delete) expect do - post(api_service_dialogs_url, 'action' => 'delete', - 'resources' => [{'id' => dialog_a.id}, {'id' => dialog_b.id}]) + post( + api_service_dialogs_url, + :params => { + 'action' => 'delete', + 'resources' => [{'id' => dialog_a.id}, {'id' => dialog_b.id}] + } + ) end.to change(Dialog, :count).by(-2) expect(response).to have_http_status(:ok) end @@ -107,7 +112,7 @@ it 'POST /api/service_dialogs/:id rejects a request without appropriate role' do api_basic_authorize - post(api_service_dialog_url(nil, dialog), gen_request(:edit, :label => 'updated label')) + post(api_service_dialog_url(nil, dialog), :params => gen_request(:edit, :label => 'updated label')) expect(response).to have_http_status(:forbidden) end @@ -146,7 +151,7 @@ } expect do - post(api_service_dialog_url(nil, dialog), gen_request(:edit, updated_dialog)) + post(api_service_dialog_url(nil, dialog), :params => gen_request(:edit, updated_dialog)) dialog.reload end.to change(dialog, :content) expect(response).to have_http_status(:ok) @@ -158,9 +163,16 @@ api_basic_authorize collection_action_identifier(:service_dialogs, :edit) - post(api_service_dialogs_url, :action => 'edit', :resources => [{:id => dialog.id, 'label' => 'foo bar'}, - {:id => dialog2.id, :label => 'bar'} - ]) + post( + api_service_dialogs_url, + :params => { + :action => 'edit', + :resources => [ + {:id => dialog.id, 'label' => 'foo bar'}, + {:id => dialog2.id, :label => 'bar'} + ] + } + ) expected = { 'results' => a_collection_containing_exactly( @@ -185,7 +197,7 @@ dialog = FactoryGirl.create(:dialog_with_tab_and_group_and_field) api_basic_authorize - post(api_service_dialog_url(nil, dialog), :action => 'copy') + post(api_service_dialog_url(nil, dialog), :params => { :action => 'copy' }) expect(response).to have_http_status(:forbidden) end @@ -207,8 +219,16 @@ } expect do - post(api_service_dialogs_url, :action => 'copy', :resources => [{:id => dialog1.id}, - {:id => dialog2.id}]) + post( + api_service_dialogs_url, + :params => { + :action => 'copy', + :resources => [ + {:id => dialog1.id}, + {:id => dialog2.id} + ] + } + ) end.to change(Dialog, :count).by(2) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) @@ -223,7 +243,7 @@ } expect do - post(api_service_dialog_url(nil, dialog), :action => 'copy') + post(api_service_dialog_url(nil, dialog), :params => { :action => 'copy' }) end.to change(Dialog, :count).by(1) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) @@ -238,7 +258,7 @@ } expect do - post(api_service_dialog_url(nil, dialog), :action => 'copy', 'label' => 'foo') + post(api_service_dialog_url(nil, dialog), :params => { :action => 'copy', 'label' => 'foo' }) end.to change(Dialog, :count).by(1) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) @@ -253,7 +273,7 @@ end it "query all service dialogs of a Service Template" do - get(api_service_template_service_dialogs_url(nil, template), :expand => "resources") + get(api_service_template_service_dialogs_url(nil, template), :params => { :expand => "resources" }) dialogs = template.dialogs expect_query_result(:service_dialogs, dialogs.count, dialogs.count) @@ -263,7 +283,7 @@ it "query all service dialogs of a Service" do service.update_attributes!(:service_template_id => template.id) - get(api_service_service_dialogs_url(nil, service), :expand => "resources") + get(api_service_service_dialogs_url(nil, service), :params => { :expand => "resources" }) dialogs = service.dialogs expect_query_result(:service_dialogs, dialogs.count, dialogs.count) @@ -271,7 +291,7 @@ end it "queries service dialogs content with the template and related resource action specified and returns IDs" do - get(api_service_template_service_dialog_url(nil, template, dialog1), :attributes => "content") + get(api_service_template_service_dialog_url(nil, template, dialog1), :params => { :attributes => "content" }) expected = { 'content' => a_collection_including( a_hash_including('id' => dialog1.compressed_id) @@ -297,7 +317,7 @@ def init_dialog it "rejects refresh dialog fields requests without appropriate role" do api_basic_authorize - post(api_service_dialog_url(nil, dialog1), gen_request(:refresh_dialog_fields, "fields" => %w(test1))) + post(api_service_dialog_url(nil, dialog1), :params => gen_request(:refresh_dialog_fields, "fields" => %w(test1))) expect(response).to have_http_status(:forbidden) end @@ -306,7 +326,7 @@ def init_dialog api_basic_authorize action_identifier(:service_dialogs, :refresh_dialog_fields) init_dialog - post(api_service_dialog_url(nil, dialog1), gen_request(:refresh_dialog_fields)) + post(api_service_dialog_url(nil, dialog1), :params => gen_request(:refresh_dialog_fields)) expect_single_action_result(:success => false, :message => /must specify fields/i) end @@ -315,7 +335,7 @@ def init_dialog api_basic_authorize action_identifier(:service_dialogs, :refresh_dialog_fields) init_dialog - post(api_service_dialog_url(nil, dialog1), gen_request(:refresh_dialog_fields, "fields" => %w(bad_field))) + post(api_service_dialog_url(nil, dialog1), :params => gen_request(:refresh_dialog_fields, "fields" => %w(bad_field))) expect_single_action_result(:success => false, :message => /unknown dialog field bad_field/i) end @@ -324,7 +344,7 @@ def init_dialog api_basic_authorize action_identifier(:service_dialogs, :refresh_dialog_fields) init_dialog - post(api_service_dialog_url(nil, dialog1), gen_request(:refresh_dialog_fields, "fields" => %w(text1))) + post(api_service_dialog_url(nil, dialog1), :params => gen_request(:refresh_dialog_fields, "fields" => %w(text1))) expect(response.parsed_body).to include( "success" => true, @@ -365,7 +385,7 @@ def init_dialog it 'rejects service dialog creation without appropriate role' do api_basic_authorize - post(api_service_dialogs_url, dialog_request) + post(api_service_dialogs_url, :params => dialog_request) expect(response).to have_http_status(:forbidden) end @@ -373,7 +393,7 @@ def init_dialog it 'rejects service dialog creation with an href specified' do api_basic_authorize collection_action_identifier(:service_dialogs, :create) - post(api_service_dialogs_url, dialog_request.merge!("href" => api_service_dialog_url(nil, 123))) + post(api_service_dialogs_url, :params => dialog_request.merge!("href" => api_service_dialog_url(nil, 123))) expected = { "error" => a_hash_including( "kind" => "bad_request", @@ -387,7 +407,7 @@ def init_dialog it 'rejects service dialog creation with an id specified' do api_basic_authorize collection_action_identifier(:service_dialogs, :create) - post(api_service_dialogs_url, dialog_request.merge!("id" => 123)) + post(api_service_dialogs_url, :params => dialog_request.merge!("id" => 123)) expected = { "error" => a_hash_including( "kind" => "bad_request", @@ -412,7 +432,7 @@ def init_dialog } expect do - post(api_service_dialogs_url, dialog_request) + post(api_service_dialogs_url, :params => dialog_request) end.to change(Dialog, :count).by(1) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) @@ -458,7 +478,7 @@ def init_dialog } expect do - post(api_service_dialogs_url, gen_request(:create, [dialog_request, dialog_request_2])) + post(api_service_dialogs_url, :params => gen_request(:create, [dialog_request, dialog_request_2])) end.to change(Dialog, :count).by(2) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) @@ -480,7 +500,7 @@ def init_dialog } expect do - post(api_service_dialogs_url, invalid_request) + post(api_service_dialogs_url, :params => invalid_request) end.to change(Dialog, :count).by(0) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:bad_request) diff --git a/spec/requests/service_orders_spec.rb b/spec/requests/service_orders_spec.rb index d098176be9..ca7b4f8265 100644 --- a/spec/requests/service_orders_spec.rb +++ b/spec/requests/service_orders_spec.rb @@ -29,7 +29,7 @@ api_basic_authorize collection_action_identifier(:service_orders, :create) expect do - post api_service_orders_url, :name => "service order", :state => "wish" + post api_service_orders_url, :params => { :name => "service order", :state => "wish" } end.to change(ServiceOrder, :count).by(1) expect(response).to have_http_status(:ok) @@ -39,9 +39,16 @@ api_basic_authorize collection_action_identifier(:service_orders, :create) expect do - post(api_service_orders_url, - :action => "create", :resources => [{:name => "service order 1", :state => "wish"}, - {:name => "service order 2", :state => "wish"}]) + post( + api_service_orders_url, + :params => { + :action => "create", + :resources => [ + {:name => "service order 1", :state => "wish"}, + {:name => "service order 2", :state => "wish"} + ] + } + ) end.to change(ServiceOrder, :count).by(2) expect(response).to have_http_status(:ok) end @@ -49,7 +56,7 @@ specify "the default state for a service order is 'cart'" do api_basic_authorize collection_action_identifier(:service_orders, :create) - post(api_service_orders_url, :name => "shopping cart") + post(api_service_orders_url, :params => { :name => "shopping cart" }) expect(response.parsed_body).to include("results" => [a_hash_including("state" => ServiceOrder::STATE_CART)]) end @@ -58,7 +65,7 @@ api_basic_authorize collection_action_identifier(:service_orders, :create) expect do - post(api_service_orders_url, :name => "service order", :state => ServiceOrder::STATE_ORDERED) + post(api_service_orders_url, :params => { :name => "service order", :state => ServiceOrder::STATE_ORDERED }) end.not_to change(ServiceOrder, :count) expect(response).to have_http_status(:bad_request) @@ -101,7 +108,7 @@ service_order = FactoryGirl.create(:service_order, :name => "old name", :user => @user) api_basic_authorize action_identifier(:service_orders, :edit) - post api_service_order_url(nil, service_order), :action => "edit", :resource => {:name => "new name"} + post api_service_order_url(nil, service_order), :params => { :action => "edit", :resource => {:name => "new name"} } expect_result_to_match_hash(response.parsed_body, "name" => "new name") expect(response).to have_http_status(:ok) @@ -112,9 +119,16 @@ service_order_2 = FactoryGirl.create(:service_order, :user => @user, :name => "old name 2") api_basic_authorize collection_action_identifier(:service_orders, :edit) - post(api_service_orders_url, - :action => "edit", :resources => [{:id => service_order_1.id, :name => "new name 1"}, - {:id => service_order_2.id, :name => "new name 2"}]) + post( + api_service_orders_url, + :params => { + :action => "edit", + :resources => [ + {:id => service_order_1.id, :name => "new name 1"}, + {:id => service_order_2.id, :name => "new name 2"} + ] + } + ) expect_results_to_match_hash("results", [{"name" => "new name 1"}, {"name" => "new name 2"}]) expect(response).to have_http_status(:ok) @@ -135,7 +149,7 @@ api_basic_authorize action_identifier(:service_orders, :delete) expect do - post api_service_order_url(nil, service_order), :action => "delete" + post api_service_order_url(nil, service_order), :params => { :action => "delete" } end.to change(ServiceOrder, :count).by(-1) expect(response).to have_http_status(:ok) end @@ -146,9 +160,16 @@ api_basic_authorize collection_action_identifier(:service_orders, :delete) expect do - post(api_service_orders_url, - :action => "delete", :resources => [{:id => service_order_1.id}, - {:id => service_order_2.id}]) + post( + api_service_orders_url, + :params => { + :action => "delete", + :resources => [ + {:id => service_order_1.id}, + {:id => service_order_2.id} + ] + } + ) end.to change(ServiceOrder, :count).by(-2) expect(response).to have_http_status(:ok) end @@ -195,9 +216,15 @@ api_basic_authorize action_identifier(:service_requests, :add, :subcollection_actions) expect do - post(api_service_order_service_requests_url(nil, "cart"), - :action => :add, - :resources => [{:service_template_href => api_service_template_url(nil, service_template)}]) + post( + api_service_order_service_requests_url(nil, "cart"), + :params => { + :action => :add, + :resources => [ + {:service_template_href => api_service_template_url(nil, service_template)} + ] + } + ) end.to change { shopping_cart.reload.miq_requests.count }.by(1) actual_requests = shopping_cart.reload.miq_requests @@ -232,11 +259,13 @@ expect do post( api_service_order_service_requests_url(nil, "cart"), - :action => :add, - :resources => [ - {:service_template_href => api_service_template_url(nil, service_template_1)}, - {:service_template_href => api_service_template_url(nil, service_template_2)} - ] + :params => { + :action => :add, + :resources => [ + {:service_template_href => api_service_template_url(nil, service_template_1)}, + {:service_template_href => api_service_template_url(nil, service_template_2)} + ] + } ) end.to change { shopping_cart.reload.miq_requests.count }.by(2) @@ -266,7 +295,7 @@ shopping_cart = FactoryGirl.create(:shopping_cart, :user => @user, :miq_requests => [service_request]) api_basic_authorize action_identifier(:service_requests, :remove, :subresource_actions) - post(api_service_order_service_request_url(nil, "cart", service_request), :action => :remove) + post(api_service_order_service_request_url(nil, "cart", service_request), :params => { :action => :remove }) expected = { "success" => true, @@ -290,11 +319,13 @@ post( api_service_order_service_requests_url(nil, "cart"), - :action => :remove, - :resources => [ - {:href => api_service_request_url(nil, service_request_1)}, - {:href => api_service_request_url(nil, service_request_2)} - ] + :params => { + :action => :remove, + :resources => [ + {:href => api_service_request_url(nil, service_request_1)}, + {:href => api_service_request_url(nil, service_request_2)} + ] + } ) expected = { @@ -329,11 +360,13 @@ post( api_service_order_service_requests_url(nil, "cart"), - :action => :remove, - :resources => [ - {:id => service_request_1.id}, - {:id => service_request_2.id} - ] + :params => { + :action => :remove, + :resources => [ + {:id => service_request_1.id}, + {:id => service_request_2.id} + ] + } ) expected = { @@ -366,7 +399,7 @@ :miq_requests => [service_request_1, service_request_2]) api_basic_authorize action_identifier(:service_orders, :clear) - post api_service_order_url(nil, "cart"), :action => :clear + post api_service_order_url(nil, "cart"), :params => { :action => :clear } expected = { "href" => api_service_order_url(nil, shopping_cart.compressed_id), @@ -383,7 +416,7 @@ api_basic_authorize action_identifier(:service_orders, :clear) shopping_cart.checkout - post api_service_order_url(nil, shopping_cart), :action => :clear + post api_service_order_url(nil, shopping_cart), :params => { :action => :clear } expected = { "error" => a_hash_including( @@ -404,7 +437,7 @@ :miq_requests => [service_request_1, service_request_2]) api_basic_authorize action_identifier(:service_orders, :order) - post api_service_order_url(nil, "cart"), :action => :order + post api_service_order_url(nil, "cart"), :params => { :action => :order } expected = { "state" => ServiceOrder::STATE_ORDERED @@ -445,9 +478,15 @@ shopping_cart = FactoryGirl.create(:shopping_cart, :user => @user) api_basic_authorize - post(api_service_order_service_requests_url(nil, "cart"), - :action => :add, - :resources => [{:service_template_href => api_service_template_url(nil, service_template)}]) + post( + api_service_order_service_requests_url(nil, "cart"), + :params => { + :action => :add, + :resources => [ + {:service_template_href => api_service_template_url(nil, service_template)} + ] + } + ) expect(response).to have_http_status(:forbidden) expect(shopping_cart.reload.miq_requests).to be_empty @@ -468,11 +507,13 @@ expect do post( api_service_order_service_requests_url(nil, "cart"), - :action => :add, - :resources => [ - {:service_template_href => api_service_template_url(nil, service_template_1)}, - {:service_template_href => api_service_template_url(nil, service_template_2)} - ] + :params => { + :action => :add, + :resources => [ + {:service_template_href => api_service_template_url(nil, service_template_1)}, + {:service_template_href => api_service_template_url(nil, service_template_2)} + ] + } ) end.not_to change { shopping_cart.reload.miq_requests.count } @@ -484,7 +525,7 @@ shopping_cart = FactoryGirl.create(:shopping_cart, :user => @user, :miq_requests => [service_request]) api_basic_authorize - post(api_service_order_service_request_url(nil, "cart", service_request), :action => :remove) + post(api_service_order_service_request_url(nil, "cart", service_request), :params => { :action => :remove }) expect(response).to have_http_status(:forbidden) expect(shopping_cart.reload.miq_requests).to include(service_request) @@ -501,11 +542,13 @@ post( api_service_order_service_requests_url(nil, "cart"), - :action => :remove, - :resources => [ - {:href => api_service_request_url(nil, service_request_1)}, - {:href => api_service_request_url(nil, service_request_2)} - ] + :params => { + :action => :remove, + :resources => [ + {:href => api_service_request_url(nil, service_request_1)}, + {:href => api_service_request_url(nil, service_request_2)} + ] + } ) expect(response).to have_http_status(:forbidden) @@ -521,7 +564,7 @@ :miq_requests => [service_request_1, service_request_2]) api_basic_authorize - post api_service_order_url(nil, "cart"), :action => :clear + post api_service_order_url(nil, "cart"), :params => { :action => :clear } expect(response).to have_http_status(:forbidden) expect(shopping_cart.reload.miq_requests).to include(service_request_1, service_request_2) @@ -536,7 +579,7 @@ :miq_requests => [service_request_1, service_request_2]) api_basic_authorize - post api_service_order_url(nil, "cart"), :action => :order + post api_service_order_url(nil, "cart"), :params => { :action => :order } expect(response).to have_http_status(:forbidden) expect(shopping_cart.reload.state).to eq(ServiceOrder::STATE_CART) @@ -553,7 +596,7 @@ it 'forbids service order copy without an appropriate role' do api_basic_authorize - post(api_service_order_url(nil, @service_order), :action => 'copy') + post(api_service_order_url(nil, @service_order), :params => { :action => 'copy' }) expect(response).to have_http_status(:forbidden) end @@ -562,7 +605,7 @@ api_basic_authorize action_identifier(:service_orders, :copy) expect do - post(api_service_order_url(nil, @service_order), :action => 'copy', :name => 'foo') + post(api_service_order_url(nil, @service_order), :params => { :action => 'copy', :name => 'foo' }) end.to change(ServiceOrder, :count).by(1) expect(response.parsed_body).to include('name' => 'foo') expect(response).to have_http_status(:ok) @@ -578,10 +621,16 @@ ) } expect do - post(api_service_orders_url, :action => 'copy', :resources => [ - { :id => @service_order.id, :name => 'foo'}, - { :id => @service_order2.id, :name => 'bar' } - ]) + post( + api_service_orders_url, + :params => { + :action => 'copy', + :resources => [ + { :id => @service_order.id, :name => 'foo'}, + { :id => @service_order2.id, :name => 'bar' } + ] + } + ) end.to change(ServiceOrder, :count).by(2) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) diff --git a/spec/requests/service_requests_spec.rb b/spec/requests/service_requests_spec.rb index 2a087620ba..54f5abb7ed 100644 --- a/spec/requests/service_requests_spec.rb +++ b/spec/requests/service_requests_spec.rb @@ -47,14 +47,14 @@ def expect_result_to_have_user_email(email) end it "can return the provision_dialog" do - get api_service_request_url(nil, service_request), :attributes => "provision_dialog" + get api_service_request_url(nil, service_request), :params => { :attributes => "provision_dialog" } expect_result_to_have_provision_dialog end it "can return the request's user.email" do @user.update_attributes!(:email => "admin@api.net") - get api_service_request_url(nil, service_request), :attributes => "user.email" + get api_service_request_url(nil, service_request), :params => { :attributes => "user.email" } expect_result_to_have_user_email(@user.email) end @@ -67,14 +67,14 @@ def expect_result_to_have_user_email(email) end it "can return the provision_dialog" do - get api_service_url(nil, service), :attributes => "provision_dialog" + get api_service_url(nil, service), :params => { :attributes => "provision_dialog" } expect_result_to_have_provision_dialog end it "can return the request's user.email" do @user.update_attributes!(:email => "admin@api.net") - get api_service_url(nil, service), :attributes => "user.email" + get api_service_url(nil, service), :params => { :attributes => "user.email" } expect_result_to_have_user_email(@user.email) end @@ -99,7 +99,7 @@ def expect_result_to_have_user_email(email) it "supports approving a request" do api_basic_authorize collection_action_identifier(:service_requests, :approve) - post(svcreq1_url, gen_request(:approve, :reason => "approve reason")) + post(svcreq1_url, :params => gen_request(:approve, :reason => "approve reason")) expected_msg = "Service request #{svcreq1.id} approved" expect_single_action_result(:success => true, :message => expected_msg, :href => api_service_request_url(nil, svcreq1.compressed_id)) @@ -108,7 +108,7 @@ def expect_result_to_have_user_email(email) it "supports denying a request" do api_basic_authorize collection_action_identifier(:service_requests, :approve) - post(svcreq2_url, gen_request(:deny, :reason => "deny reason")) + post(svcreq2_url, :params => gen_request(:deny, :reason => "deny reason")) expected_msg = "Service request #{svcreq2.id} denied" expect_single_action_result(:success => true, :message => expected_msg, :href => api_service_request_url(nil, svcreq2.compressed_id)) @@ -117,8 +117,8 @@ def expect_result_to_have_user_email(email) it "supports approving multiple requests" do api_basic_authorize collection_action_identifier(:service_requests, :approve) - post(api_service_requests_url, gen_request(:approve, [{"href" => svcreq1_url, "reason" => "approve reason"}, - {"href" => svcreq2_url, "reason" => "approve reason"}])) + post(api_service_requests_url, :params => gen_request(:approve, [{"href" => svcreq1_url, "reason" => "approve reason"}, + {"href" => svcreq2_url, "reason" => "approve reason"}])) expected = { "results" => a_collection_containing_exactly( @@ -141,8 +141,8 @@ def expect_result_to_have_user_email(email) it "supports denying multiple requests" do api_basic_authorize collection_action_identifier(:service_requests, :approve) - post(api_service_requests_url, gen_request(:deny, [{"href" => svcreq1_url, "reason" => "deny reason"}, - {"href" => svcreq2_url, "reason" => "deny reason"}])) + post(api_service_requests_url, :params => gen_request(:deny, [{"href" => svcreq1_url, "reason" => "deny reason"}, + {"href" => svcreq2_url, "reason" => "deny reason"}])) expected = { "results" => a_collection_containing_exactly( @@ -283,7 +283,7 @@ def expect_result_to_have_user_email(email) it 'forbids deletion without an appropriate role' do api_basic_authorize - post(api_service_request_url(nil, service_request), :action => 'delete') + post(api_service_request_url(nil, service_request), :params => { :action => 'delete' }) expect(response).to have_http_status(:forbidden) end @@ -291,7 +291,7 @@ def expect_result_to_have_user_email(email) it 'can delete a single service request resource' do api_basic_authorize collection_action_identifier(:service_requests, :delete) - post(api_service_request_url(nil, service_request), :action => 'delete') + post(api_service_request_url(nil, service_request), :params => { :action => 'delete' }) expected = { 'success' => true, @@ -309,9 +309,16 @@ def expect_result_to_have_user_email(email) :source_type => template.class.name) api_basic_authorize collection_action_identifier(:service_requests, :delete) - post(api_service_requests_url, :action => 'delete', :resources => [ - { :id => service_request.id }, { :id => service_request_2.id } - ]) + post( + api_service_requests_url, + :params => { + :action => 'delete', + :resources => [ + { :id => service_request.id }, + { :id => service_request_2.id } + ] + } + ) expected = { 'results' => a_collection_including( @@ -350,7 +357,7 @@ def expect_result_to_have_user_email(email) api_basic_authorize collection_action_identifier(:service_requests, :add_approver) expect do - post(api_service_request_url(nil, service_request), :action => 'add_approver', :user_id => user.id) + post(api_service_request_url(nil, service_request), :params => { :action => 'add_approver', :user_id => user.id }) end.to change(MiqApproval, :count).by(1) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include('id' => service_request.compressed_id) @@ -373,10 +380,16 @@ def expect_result_to_have_user_email(email) ) } expect do - post(api_service_requests_url, :action => 'add_approver', :resources => [ - { :id => service_request.id, :user_id => user.id }, - { :id => service_request_2.id, :user_id => user.id } - ]) + post( + api_service_requests_url, + :params => { + :action => 'add_approver', + :resources => [ + { :id => service_request.id, :user_id => user.id }, + { :id => service_request_2.id, :user_id => user.id } + ] + } + ) end.to change(MiqApproval, :count).by(2) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include(expected) @@ -385,7 +398,7 @@ def expect_result_to_have_user_email(email) it 'forbids adding an approver without an appropriate role' do api_basic_authorize - post(api_service_requests_url, :action => 'add_approver') + post(api_service_requests_url, :params => { :action => 'add_approver' }) expect(response).to have_http_status(:forbidden) end @@ -396,7 +409,7 @@ def expect_result_to_have_user_email(email) api_basic_authorize collection_action_identifier(:service_requests, :add_approver) expect do - post(api_service_request_url(nil, service_request), :action => 'add_approver', :user => { :id => user.id }) + post(api_service_request_url(nil, service_request), :params => { :action => 'add_approver', :user => { :id => user.id } }) end.to change(MiqApproval, :count).by(1) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include('id' => service_request.compressed_id) @@ -408,8 +421,13 @@ def expect_result_to_have_user_email(email) api_basic_authorize collection_action_identifier(:service_requests, :add_approver) expect do - post(api_service_request_url(nil, service_request), - :action => 'add_approver', :user => { :href => api_user_url(nil, user)}) + post( + api_service_request_url(nil, service_request), + :params => { + :action => 'add_approver', + :user => {:href => api_user_url(nil, user)} + } + ) end.to change(MiqApproval, :count).by(1) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include('id' => service_request.compressed_id) @@ -424,7 +442,7 @@ def expect_result_to_have_user_email(email) 'message' => 'Cannot add approver - Must specify a valid user_id or user' ) } - post(api_service_request_url(nil, service_request), :action => 'add_approver') + post(api_service_request_url(nil, service_request), :params => { :action => 'add_approver' }) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:bad_request) end @@ -437,7 +455,7 @@ def expect_result_to_have_user_email(email) api_basic_authorize collection_action_identifier(:service_requests, :add_approver) expect do - post(api_service_request_url(nil, service_request), :action => 'remove_approver', :user_id => user.id) + post(api_service_request_url(nil, service_request), :params => { :action => 'remove_approver', :user_id => user.id }) end.to change(MiqApproval, :count).by(-1) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include('id' => service_request.compressed_id) @@ -462,11 +480,13 @@ def expect_result_to_have_user_email(email) expect do post( api_service_requests_url, - :action => 'remove_approver', - :resources => [ - { :id => service_request.id, :user_id => user.id }, - { :id => service_request2.id, :user_id => user.id } - ] + :params => { + :action => 'remove_approver', + :resources => [ + { :id => service_request.id, :user_id => user.id }, + { :id => service_request2.id, :user_id => user.id } + ] + } ) end.to change(MiqApproval, :count).by(-2) expect(response).to have_http_status(:ok) @@ -476,7 +496,7 @@ def expect_result_to_have_user_email(email) it 'forbids adding an approver without an appropriate role' do api_basic_authorize - post(api_service_requests_url, :action => 'remove_approver') + post(api_service_requests_url, :params => { :action => 'remove_approver' }) expect(response).to have_http_status(:forbidden) end @@ -487,9 +507,13 @@ def expect_result_to_have_user_email(email) api_basic_authorize collection_action_identifier(:service_requests, :add_approver) expect do - post(api_service_request_url(nil, service_request), - :action => 'remove_approver', - :user => { :href => api_user_url(nil, user)}) + post( + api_service_request_url(nil, service_request), + :params => { + :action => 'remove_approver', + :user => { :href => api_user_url(nil, user)} + } + ) end.to change(MiqApproval, :count).by(-1) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include('id' => service_request.compressed_id) @@ -504,7 +528,7 @@ def expect_result_to_have_user_email(email) 'message' => 'Cannot remove approver - Must specify a valid user_id or user' ) } - post(api_service_request_url(nil, service_request), :action => 'remove_approver') + post(api_service_request_url(nil, service_request), :params => { :action => 'remove_approver' }) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:bad_request) end @@ -514,7 +538,7 @@ def expect_result_to_have_user_email(email) service_request.miq_approvals << FactoryGirl.create(:miq_approval) api_basic_authorize collection_action_identifier(:service_requests, :add_approver) - post(api_service_request_url(nil, service_request), :action => 'remove_approver', :user_id => user.id) + post(api_service_request_url(nil, service_request), :params => { :action => 'remove_approver', :user_id => user.id }) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include('id' => service_request.compressed_id) end @@ -527,7 +551,7 @@ def expect_result_to_have_user_email(email) :options => {:foo => "bar"}) api_basic_authorize - post(api_service_request_url(nil, service_request), :action => "edit", :options => {:baz => "qux"}) + post(api_service_request_url(nil, service_request), :params => { :action => "edit", :options => {:baz => "qux"} }) expect(response).to have_http_status(:forbidden) end @@ -538,7 +562,7 @@ def expect_result_to_have_user_email(email) :options => {:foo => "bar"}) api_basic_authorize(action_identifier(:service_requests, :edit)) - post(api_service_request_url(nil, service_request), :action => "edit", :options => {:baz => "qux"}) + post(api_service_request_url(nil, service_request), :params => { :action => "edit", :options => {:baz => "qux"} }) expected = { "id" => service_request.compressed_id, @@ -557,11 +581,13 @@ def expect_result_to_have_user_email(email) post( api_service_requests_url, - :action => "edit", - :resources => [ - {:id => service_request.id, :options => {:baz => "qux"}}, - {:id => service_request2.id, :options => {:quux => "quuz"}} - ] + :params => { + :action => "edit", + :resources => [ + {:id => service_request.id, :options => {:baz => "qux"}}, + {:id => service_request2.id, :options => {:quux => "quuz"}} + ] + } ) expected = { diff --git a/spec/requests/service_templates_spec.rb b/spec/requests/service_templates_spec.rb index 09a81fc99d..9b1aa7e938 100644 --- a/spec/requests/service_templates_spec.rb +++ b/spec/requests/service_templates_spec.rb @@ -25,7 +25,7 @@ it "queries all resource actions of a Service Template" do api_basic_authorize - get(api_service_template_resource_actions_url(nil, template), :expand => "resources") + get(api_service_template_resource_actions_url(nil, template), :params => { :expand => "resources" }) resource_actions = template.resource_actions expect_query_result(:resource_actions, resource_actions.count, resource_actions.count) @@ -35,9 +35,13 @@ it "queries a specific resource action of a Service Template" do api_basic_authorize - get(api_service_template_resource_actions_url(nil, template), - :expand => "resources", - :filter => ["action='Provision'"]) + get( + api_service_template_resource_actions_url(nil, template), + :params => { + :expand => "resources", + :filter => ["action='Provision'"] + } + ) expect_query_result(:resource_actions, 1, 2) expect_result_resources_to_match_hash(["id" => ra1.compressed_id, "action" => ra1.action, "dialog_id" => dialog1.compressed_id]) @@ -46,7 +50,7 @@ it "allows queries of the related picture" do api_basic_authorize action_identifier(:service_templates, :read, :resource_actions, :get) - get api_service_template_url(nil, template), :attributes => "picture" + get api_service_template_url(nil, template), :params => { :attributes => "picture" } expect_result_to_have_keys(%w(id href picture)) expected = {"id" => template.compressed_id, "href" => api_service_template_url(nil, template.compressed_id)} @@ -56,7 +60,7 @@ it "allows queries of the related picture and image_href" do api_basic_authorize action_identifier(:service_templates, :read, :resource_actions, :get) - get api_service_template_url(nil, template), :attributes => "picture,picture.image_href" + get api_service_template_url(nil, template), :params => { :attributes => "picture,picture.image_href" } expect_result_to_have_keys(%w(id href picture)) expect_result_to_match_hash(response.parsed_body["picture"], @@ -123,7 +127,7 @@ api_basic_authorize st = FactoryGirl.create(:service_template, :name => "st") - post(api_service_template_url(nil, st), gen_request(:edit, updated_catalog_item_options)) + post(api_service_template_url(nil, st), :params => gen_request(:edit, updated_catalog_item_options)) expect(response).to have_http_status(:forbidden) end @@ -132,7 +136,7 @@ api_basic_authorize collection_action_identifier(:service_templates, :edit) st = FactoryGirl.create(:service_template, :name => "st1") - post(api_service_template_url(nil, st), gen_request(:edit, updated_catalog_item_options)) + post(api_service_template_url(nil, st), :params => gen_request(:edit, updated_catalog_item_options)) expect_single_resource_query("id" => st.compressed_id, "href" => api_service_template_url(nil, st.compressed_id), "name" => "Updated Template Name") expect(st.reload.name).to eq("Updated Template Name") @@ -144,8 +148,8 @@ st1 = FactoryGirl.create(:service_template, :name => "st1") st2 = FactoryGirl.create(:service_template, :name => "st2") - post(api_service_templates_url, gen_request(:edit, [updated_catalog_item_options.merge('id' => st1.id), - updated_catalog_item_options.merge('id' => st2.id)])) + post(api_service_templates_url, :params => gen_request(:edit, [updated_catalog_item_options.merge('id' => st1.id), + updated_catalog_item_options.merge('id' => st2.id)])) expect(response).to have_http_status(:ok) expect_results_to_match_hash("results", @@ -159,7 +163,7 @@ api_basic_authorize collection_action_identifier(:service_templates, :edit) st1 = FactoryGirl.create(:service_template, :name => 'st1') - post(api_service_template_url(nil, st1), gen_request(:edit, 'name' => 'updated template')) + post(api_service_template_url(nil, st1), :params => gen_request(:edit, 'name' => 'updated template')) expected = { 'id' => st1.compressed_id, @@ -174,7 +178,7 @@ it "rejects requests without appropriate role" do api_basic_authorize - post(api_service_templates_url, gen_request(:delete, "href" => api_service_template_url(nil, 100))) + post(api_service_templates_url, :params => gen_request(:delete, "href" => api_service_template_url(nil, 100))) expect(response).to have_http_status(:forbidden) end @@ -211,7 +215,7 @@ service_template = FactoryGirl.create(:service_template) expect do - post(api_service_template_url(nil, service_template), :action => "delete") + post(api_service_template_url(nil, service_template), :params => { :action => "delete" }) end.to change(ServiceTemplate, :count).by(-1) expected = { @@ -228,7 +232,7 @@ service_template = FactoryGirl.create(:service_template) expect do - post(api_service_template_url(nil, service_template), :action => "delete") + post(api_service_template_url(nil, service_template), :params => { :action => "delete" }) end.not_to change(ServiceTemplate, :count) expect(response).to have_http_status(:forbidden) @@ -240,9 +244,9 @@ st1 = FactoryGirl.create(:service_template, :name => "st1", :description => "st1 description") st2 = FactoryGirl.create(:service_template, :name => "st2", :description => "st2 description") - post(api_service_templates_url, gen_request(:delete, - [{"href" => api_service_template_url(nil, st1)}, - {"href" => api_service_template_url(nil, st2)}])) + post(api_service_templates_url, :params => gen_request(:delete, + [{"href" => api_service_template_url(nil, st1)}, + {"href" => api_service_template_url(nil, st2)}])) expect_multiple_action_result(2) expect_result_resources_to_include_hrefs("results", [api_service_template_url(nil, st1.compressed_id), api_service_template_url(nil, st2.compressed_id)]) @@ -327,7 +331,7 @@ it 'rejects requests without appropriate role' do api_basic_authorize - post(api_service_templates_url, :name => 'foobar') + post(api_service_templates_url, :params => { :name => 'foobar' }) expect(response).to have_http_status(:forbidden) end @@ -347,7 +351,7 @@ } expect do - post(api_service_templates_url, template_parameters) + post(api_service_templates_url, :params => template_parameters) end.to change(ServiceTemplate, :count).by(1) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include(expected) @@ -373,7 +377,7 @@ ) } expect do - post(api_service_templates_url, :action => 'create', :resources => [template_parameters, template_parameters]) + post(api_service_templates_url, :params => { :action => 'create', :resources => [template_parameters, template_parameters] }) end.to change(ServiceTemplate, :count).by(2) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include(expected) @@ -408,7 +412,7 @@ )] } expect do - post(api_service_templates_url, template_parameters) + post(api_service_templates_url, :params => template_parameters) end.to change(ServiceTemplateOrchestration, :count).by(1) expect(response).to have_http_status(:ok) expect(response.parsed_body).to include(expected) @@ -435,7 +439,7 @@ ) } expect do - post(api_service_templates_url, template_parameters) + post(api_service_templates_url, :params => template_parameters) end.to change(ServiceTemplateOrchestration, :count).by(0) expect(response).to have_http_status(:bad_request) expect(response.parsed_body).to include(expected) diff --git a/spec/requests/services_spec.rb b/spec/requests/services_spec.rb index 342243a083..4103730e5d 100644 --- a/spec/requests/services_spec.rb +++ b/spec/requests/services_spec.rb @@ -34,7 +34,7 @@ it "rejects requests without appropriate role" do api_basic_authorize - post(api_services_url, gen_request(:create, "name" => "svc_new_1")) + post(api_services_url, :params => gen_request(:create, "name" => "svc_new_1")) expect(response).to have_http_status(:forbidden) end @@ -43,7 +43,7 @@ api_basic_authorize collection_action_identifier(:services, :create) expect do - post(api_services_url, gen_request(:create, "name" => "svc_new_1")) + post(api_services_url, :params => gen_request(:create, "name" => "svc_new_1")) end.to change(Service, :count).by(1) expect(response).to have_http_status(:ok) @@ -54,9 +54,9 @@ api_basic_authorize collection_action_identifier(:services, :create) expect do - post(api_services_url, gen_request(:create, - [{"name" => "svc_new_1"}, - {"name" => "svc_new_2"}])) + post(api_services_url, :params => gen_request(:create, + [{"name" => "svc_new_1"}, + {"name" => "svc_new_2"}])) end.to change(Service, :count).by(2) expect(response).to have_http_status(:ok) @@ -79,7 +79,7 @@ } } expect do - post(api_services_url, request) + post(api_services_url, :params => request) end.to change(Service, :count).by(1) expect(response).to have_http_status(:ok) expect_results_to_match_hash("results", [{"name" => "svc_new"}]) @@ -99,7 +99,7 @@ } } expect do - post(api_services_url, request) + post(api_services_url, :params => request) end.to change(Service, :count).by(1) expect(response).to have_http_status(:ok) expect_results_to_match_hash("results", [{"name" => "svc_new"}]) @@ -110,7 +110,7 @@ it "rejects requests without appropriate role" do api_basic_authorize - post(api_service_url(nil, svc), gen_request(:edit, "name" => "sample service")) + post(api_service_url(nil, svc), :params => gen_request(:edit, "name" => "sample service")) expect(response).to have_http_status(:forbidden) end @@ -118,7 +118,7 @@ it "supports edits of single resource" do api_basic_authorize collection_action_identifier(:services, :edit) - post(api_service_url(nil, svc), gen_request(:edit, "name" => "updated svc1")) + post(api_service_url(nil, svc), :params => gen_request(:edit, "name" => "updated svc1")) expect_single_resource_query("id" => svc.compressed_id, "href" => api_service_url(nil, svc.compressed_id), "name" => "updated svc1") expect(svc.reload.name).to eq("updated svc1") @@ -135,7 +135,7 @@ 'orchestration_manager' => { 'href' => api_provider_url(nil, ems.compressed_id) } } } - post(api_service_url(nil, svc_orchestration), resource) + post(api_service_url(nil, svc_orchestration), :params => resource) expected = { 'id' => svc_orchestration.compressed_id, @@ -159,7 +159,7 @@ 'orchestration_manager' => { 'id' => ems.id } } } - post(api_service_url(nil, svc_orchestration), resource) + post(api_service_url(nil, svc_orchestration), :params => resource) expected = { 'id' => svc_orchestration.compressed_id, @@ -175,7 +175,7 @@ it "supports edits of single resource via PUT" do api_basic_authorize collection_action_identifier(:services, :edit) - put(api_service_url(nil, svc), "name" => "updated svc1") + put(api_service_url(nil, svc), :params => { "name" => "updated svc1" }) expect_single_resource_query("id" => svc.compressed_id, "href" => api_service_url(nil, svc.compressed_id), "name" => "updated svc1") expect(svc.reload.name).to eq("updated svc1") @@ -184,9 +184,9 @@ it "supports edits of single resource via PATCH" do api_basic_authorize collection_action_identifier(:services, :edit) - patch(api_service_url(nil, svc), [{"action" => "edit", "path" => "name", "value" => "updated svc1"}, - {"action" => "remove", "path" => "description"}, - {"action" => "add", "path" => "display", "value" => true}]) + patch(api_service_url(nil, svc), :params => [{"action" => "edit", "path" => "name", "value" => "updated svc1"}, + {"action" => "remove", "path" => "description"}, + {"action" => "add", "path" => "display", "value" => true}]) expect_single_resource_query("id" => svc.compressed_id, "name" => "updated svc1", "display" => true) expect(svc.reload.name).to eq("updated svc1") @@ -197,9 +197,9 @@ it "supports edits of multiple resources" do api_basic_authorize collection_action_identifier(:services, :edit) - post(api_services_url, gen_request(:edit, - [{"href" => api_service_url(nil, svc1), "name" => "updated svc1"}, - {"href" => api_service_url(nil, svc2), "name" => "updated svc2"}])) + post(api_services_url, :params => gen_request(:edit, + [{"href" => api_service_url(nil, svc1), "name" => "updated svc1"}, + {"href" => api_service_url(nil, svc2), "name" => "updated svc2"}])) expect(response).to have_http_status(:ok) expect_results_to_match_hash("results", @@ -214,7 +214,7 @@ it "rejects POST delete requests without appropriate role" do api_basic_authorize - post(api_services_url, gen_request(:delete, "href" => api_service_url(nil, 100))) + post(api_services_url, :params => gen_request(:delete, "href" => api_service_url(nil, 100))) expect(response).to have_http_status(:forbidden) end @@ -249,7 +249,7 @@ api_basic_authorize(action_identifier(:services, :delete)) expect do - post(api_service_url(nil, service), :action => "delete") + post(api_service_url(nil, service), :params => { :action => "delete" }) end.to change(Service, :count).by(-1) expected = { @@ -266,7 +266,7 @@ api_basic_authorize expect do - post(api_service_url(nil, service), :action => "delete") + post(api_service_url(nil, service), :params => { :action => "delete" }) end.not_to change(Service, :count) expect(response).to have_http_status(:forbidden) @@ -275,9 +275,9 @@ it "supports multiple resource deletes" do api_basic_authorize collection_action_identifier(:services, :delete) - post(api_services_url, gen_request(:delete, - [{"href" => api_service_url(nil, svc1)}, - {"href" => api_service_url(nil, svc2)}])) + post(api_services_url, :params => gen_request(:delete, + [{"href" => api_service_url(nil, svc1)}, + {"href" => api_service_url(nil, svc2)}])) expect_multiple_action_result(2) expect_result_resources_to_include_hrefs("results", [api_service_url(nil, svc1.compressed_id), api_service_url(nil, svc2.compressed_id)]) @@ -294,7 +294,7 @@ def format_retirement_date(time) it "rejects requests without appropriate role" do api_basic_authorize - post(api_service_url(nil, 100), gen_request(:retire)) + post(api_service_url(nil, 100), :params => gen_request(:retire)) expect(response).to have_http_status(:forbidden) end @@ -302,7 +302,7 @@ def format_retirement_date(time) it "rejects multiple requests without appropriate role" do api_basic_authorize - post(api_services_url, gen_request(:retire, [{"href" => api_service_url(nil, 1)}, {"href" => api_service_url(nil, 2)}])) + post(api_services_url, :params => gen_request(:retire, [{"href" => api_service_url(nil, 1)}, {"href" => api_service_url(nil, 2)}])) expect(response).to have_http_status(:forbidden) end @@ -312,7 +312,7 @@ def format_retirement_date(time) expect(MiqEvent).to receive(:raise_evm_event).once - post(api_service_url(nil, svc), gen_request(:retire)) + post(api_service_url(nil, svc), :params => gen_request(:retire)) expect_single_resource_query("id" => svc.compressed_id, "href" => api_service_url(nil, svc.compressed_id)) end @@ -322,7 +322,7 @@ def format_retirement_date(time) ret_date = format_retirement_date(Time.now + 5.days) - post(api_service_url(nil, svc), gen_request(:retire, "date" => ret_date, "warn" => 2)) + post(api_service_url(nil, svc), :params => gen_request(:retire, "date" => ret_date, "warn" => 2)) expect_single_resource_query("id" => svc.compressed_id, "retires_on" => ret_date, "retirement_warn" => 2) expect(format_retirement_date(svc.reload.retires_on)).to eq(ret_date) @@ -334,9 +334,9 @@ def format_retirement_date(time) expect(MiqEvent).to receive(:raise_evm_event).twice - post(api_services_url, gen_request(:retire, - [{"href" => api_service_url(nil, svc1)}, - {"href" => api_service_url(nil, svc2)}])) + post(api_services_url, :params => gen_request(:retire, + [{"href" => api_service_url(nil, svc1)}, + {"href" => api_service_url(nil, svc2)}])) expect_results_to_match_hash("results", [{"id" => svc1.compressed_id}, {"id" => svc2.compressed_id}]) end @@ -346,9 +346,9 @@ def format_retirement_date(time) ret_date = format_retirement_date(Time.now + 2.days) - post(api_services_url, gen_request(:retire, - [{"href" => api_service_url(nil, svc1), "date" => ret_date, "warn" => 3}, - {"href" => api_service_url(nil, svc2), "date" => ret_date, "warn" => 5}])) + post(api_services_url, :params => gen_request(:retire, + [{"href" => api_service_url(nil, svc1), "date" => ret_date, "warn" => 3}, + {"href" => api_service_url(nil, svc2), "date" => ret_date, "warn" => 5}])) expect_results_to_match_hash("results", [{"id" => svc1.compressed_id, "retires_on" => ret_date, "retirement_warn" => 3}, @@ -371,7 +371,7 @@ def format_retirement_date(time) it "rejects requests without appropriate role" do api_basic_authorize - post(api_service_url(nil, 100), gen_request(:reconfigure)) + post(api_service_url(nil, 100), :params => gen_request(:reconfigure)) expect(response).to have_http_status(:forbidden) end @@ -410,7 +410,7 @@ def format_retirement_date(time) svc1.service_template_id = st1.id svc1.save - post(api_service_url(nil, svc1), gen_request(:reconfigure, "text1" => "updated_text")) + post(api_service_url(nil, svc1), :params => gen_request(:reconfigure, "text1" => "updated_text")) expect_single_action_result(:success => true, :message => /reconfiguring/i, :href => api_service_url(nil, svc1.compressed_id)) end @@ -447,7 +447,7 @@ def expect_svc_with_vms end it "supports expansion of virtual attributes" do - get api_services_url, :expand => "resources", :attributes => "power_states" + get api_services_url, :params => { :expand => "resources", :attributes => "power_states" } expected = { "resources" => [ @@ -459,13 +459,13 @@ def expect_svc_with_vms end it "can query vms as subcollection via expand" do - get api_service_url(nil, svc1), :expand => "vms" + get api_service_url(nil, svc1), :params => { :expand => "vms" } expect_svc_with_vms end it "can query vms as subcollection via expand with additional virtual attributes" do - get api_service_url(nil, svc1), :expand => "vms", :attributes => "vms.cpu_total_cores" + get api_service_url(nil, svc1), :params => { :expand => "vms", :attributes => "vms.cpu_total_cores" } expect_svc_with_vms expect_results_to_match_hash("vms", [{"id" => vm1.compressed_id, "cpu_total_cores" => 2}, @@ -473,7 +473,7 @@ def expect_svc_with_vms end it "can query vms as subcollection via decorators with additional decorators" do - get api_service_url(nil, svc1), :expand => "vms", :attributes => "", :decorators => "vms.supports_console?" + get api_service_url(nil, svc1), :params => { :expand => "vms", :attributes => "", :decorators => "vms.supports_console?" } expect_svc_with_vms expect_results_to_match_hash("vms", [{"id" => vm1.compressed_id, "supports_console?" => true}, @@ -481,7 +481,7 @@ def expect_svc_with_vms end it "cannot query vms via both virtual attribute and subcollection" do - get api_service_url(nil, svc1), :expand => "vms", :attributes => "vms" + get api_service_url(nil, svc1), :params => { :expand => "vms", :attributes => "vms" } expect_bad_request("Cannot expand subcollection vms by name and virtual attribute") end @@ -493,7 +493,7 @@ def expect_svc_with_vms service = FactoryGirl.create(:service) api_basic_authorize(action_identifier(:services, :start)) - post(api_service_url(nil, service), :action => "start") + post(api_service_url(nil, service), :params => { :action => "start" }) expected = { "href" => api_service_url(nil, service.compressed_id), @@ -508,7 +508,7 @@ def expect_svc_with_vms service_1, service_2 = FactoryGirl.create_list(:service, 2) api_basic_authorize(collection_action_identifier(:services, :start)) - post(api_services_url, :action => "start", :resources => [{:id => service_1.id}, {:id => service_2.id}]) + post(api_services_url, :params => { :action => "start", :resources => [{:id => service_1.id}, {:id => service_2.id}] }) expected = { "results" => a_collection_containing_exactly( @@ -532,7 +532,7 @@ def expect_svc_with_vms service = FactoryGirl.create(:service) api_basic_authorize - post(api_service_url(nil, service), :action => "start") + post(api_service_url(nil, service), :params => { :action => "start" }) expect(response).to have_http_status(:forbidden) end @@ -543,7 +543,7 @@ def expect_svc_with_vms service = FactoryGirl.create(:service) api_basic_authorize(action_identifier(:services, :stop)) - post(api_service_url(nil, service), :action => "stop") + post(api_service_url(nil, service), :params => { :action => "stop" }) expected = { "href" => api_service_url(nil, service.compressed_id), @@ -558,7 +558,7 @@ def expect_svc_with_vms service_1, service_2 = FactoryGirl.create_list(:service, 2) api_basic_authorize(collection_action_identifier(:services, :stop)) - post(api_services_url, :action => "stop", :resources => [{:id => service_1.id}, {:id => service_2.id}]) + post(api_services_url, :params => { :action => "stop", :resources => [{:id => service_1.id}, {:id => service_2.id}] }) expected = { "results" => a_collection_containing_exactly( @@ -582,7 +582,7 @@ def expect_svc_with_vms service = FactoryGirl.create(:service) api_basic_authorize - post(api_service_url(nil, service), :action => "stop") + post(api_service_url(nil, service), :params => { :action => "stop" }) expect(response).to have_http_status(:forbidden) end @@ -593,7 +593,7 @@ def expect_svc_with_vms service = FactoryGirl.create(:service) api_basic_authorize(action_identifier(:services, :suspend)) - post(api_service_url(nil, service), :action => "suspend") + post(api_service_url(nil, service), :params => { :action => "suspend" }) expected = { "href" => api_service_url(nil, service.compressed_id), @@ -608,7 +608,7 @@ def expect_svc_with_vms service_1, service_2 = FactoryGirl.create_list(:service, 2) api_basic_authorize(collection_action_identifier(:services, :suspend)) - post(api_services_url, :action => "suspend", :resources => [{:id => service_1.id}, {:id => service_2.id}]) + post(api_services_url, :params => { :action => "suspend", :resources => [{:id => service_1.id}, {:id => service_2.id}] }) expected = { "results" => a_collection_containing_exactly( @@ -632,7 +632,7 @@ def expect_svc_with_vms service = FactoryGirl.create(:service) api_basic_authorize - post(api_service_url(nil, service), :action => "suspend") + post(api_service_url(nil, service), :params => { :action => "suspend" }) expect(response).to have_http_status(:forbidden) end @@ -649,7 +649,7 @@ def expect_svc_with_vms it 'can query orchestration stacks as a subcollection' do api_basic_authorize subcollection_action_identifier(:services, :orchestration_stacks, :read, :get) - get(api_service_orchestration_stacks_url(nil, svc), :expand => 'resources') + get(api_service_orchestration_stacks_url(nil, svc), :params => { :expand => 'resources' }) expected = { 'resources' => [ @@ -674,7 +674,7 @@ def expect_svc_with_vms api_basic_authorize subcollection_action_identifier(:services, :orchestration_stacks, :read, :get) allow_any_instance_of(OrchestrationStack).to receive(:stdout).with(nil).and_return("default text stdout") - get(api_service_orchestration_stack_url(nil, svc, os), :attributes => "stdout") + get(api_service_orchestration_stack_url(nil, svc, os), :params => { :attributes => "stdout" }) expected = { 'id' => os.compressed_id, @@ -688,7 +688,7 @@ def expect_svc_with_vms api_basic_authorize subcollection_action_identifier(:services, :orchestration_stacks, :read, :get) allow_any_instance_of(OrchestrationStack).to receive(:stdout).with("json").and_return("json stdout") - get(api_service_orchestration_stack_url(nil, svc, os), :attributes => "stdout", :format_attributes => "stdout=json") + get(api_service_orchestration_stack_url(nil, svc, os), :params => { :attributes => "stdout", :format_attributes => "stdout=json" }) expected = { 'id' => os.compressed_id, @@ -721,7 +721,7 @@ def expect_svc_with_vms ] } - post(api_services_url, request) + post(api_services_url, :params => request) expected = { 'results' => [ @@ -747,7 +747,7 @@ def expect_svc_with_vms ] } - post(api_services_url, request) + post(api_services_url, :params => request) expected = { 'results' => [ @@ -768,7 +768,7 @@ def expect_svc_with_vms 'resource' => { 'resource' => { 'href' => '1' } } } - post(api_service_url(nil, svc), request) + post(api_service_url(nil, svc), :params => request) expected = { 'success' => false, 'message' => "Invalid resource href specified 1"} @@ -784,7 +784,7 @@ def expect_svc_with_vms 'resource' => { 'resource' => { 'href' => api_user_url(nil, user.compressed_id) } } } - post(api_service_url(nil, svc), request) + post(api_service_url(nil, svc), :params => request) expected = { 'success' => false, 'message' => "Cannot assign users to Service id:#{svc.id} name:'#{svc.name}'"} @@ -799,7 +799,7 @@ def expect_svc_with_vms 'resource' => { 'resource' => {} } } - post(api_service_url(nil, svc), request) + post(api_service_url(nil, svc), :params => request) expected = { 'success' => false, 'message' => "Must specify a resource reference"} @@ -814,7 +814,7 @@ def expect_svc_with_vms 'resource' => { 'resource' => {'href' => api_vm_url(nil, vm1)} } } - post(api_service_url(nil, svc), request) + post(api_service_url(nil, svc), :params => request) expected = { 'success' => true, 'message' => "Assigned resource vms id:#{vm1.id} to Service id:#{svc.id} name:'#{svc.name}'"} @@ -826,7 +826,7 @@ def expect_svc_with_vms it 'cannot add multiple vms to multiple services by href without an appropriate role' do api_basic_authorize - post(api_services_url, 'action' => 'add_resource') + post(api_services_url, :params => { 'action' => 'add_resource' }) expect(response).to have_http_status(:forbidden) end @@ -844,7 +844,7 @@ def expect_svc_with_vms it 'cannot remove vms from services without an appropriate role' do api_basic_authorize - post(api_services_url, 'action' => 'remove_resource') + post(api_services_url, :params => { 'action' => 'remove_resource' }) expect(response).to have_http_status(:forbidden) end @@ -859,7 +859,7 @@ def expect_svc_with_vms ] } - post(api_services_url, request) + post(api_services_url, :params => request) expected = { 'results' => [ @@ -882,7 +882,7 @@ def expect_svc_with_vms ] } - post(api_services_url, request) + post(api_services_url, :params => request) expected = { 'results' => [ @@ -902,7 +902,7 @@ def expect_svc_with_vms ] } - post(api_services_url, request) + post(api_services_url, :params => request) expected = { 'results' => [ @@ -916,7 +916,7 @@ def expect_svc_with_vms it 'cannot remove a vm from a service without an appropriate role' do api_basic_authorize - post(api_service_url(nil, svc), 'action' => 'remove_resource') + post(api_service_url(nil, svc), :params => { 'action' => 'remove_resource' }) expect(response).to have_http_status(:forbidden) end @@ -928,7 +928,7 @@ def expect_svc_with_vms 'resource' => { 'resource' => {'href' => api_vm_url(nil, vm1)} } } - post(api_service_url(nil, svc), request) + post(api_service_url(nil, svc), :params => request) expected = { 'success' => true, @@ -954,7 +954,7 @@ def expect_svc_with_vms it 'cannot remove all resources without an appropriate role' do api_basic_authorize - post(api_services_url, 'action' => 'remove_all_resources') + post(api_services_url, :params => { 'action' => 'remove_all_resources' }) expect(response).to have_http_status(:forbidden) end @@ -969,7 +969,7 @@ def expect_svc_with_vms ] } - post(api_services_url, request) + post(api_services_url, :params => request) expected = { 'results' => [ @@ -986,7 +986,7 @@ def expect_svc_with_vms it 'cannot remove all resources without an appropriate role' do api_basic_authorize - post(api_service_url(nil, svc), :action => 'remove_all_resources') + post(api_service_url(nil, svc), :params => { :action => 'remove_all_resources' }) expect(response).to have_http_status(:forbidden) end @@ -994,7 +994,7 @@ def expect_svc_with_vms it 'can remove all resources from a service' do api_basic_authorize collection_action_identifier(:services, :remove_all_resources) - post(api_service_url(nil, svc), :action => 'remove_all_resources') + post(api_service_url(nil, svc), :params => { :action => 'remove_all_resources' }) expected = { 'success' => true, 'message' => "Removed all resources from Service id:#{svc.id} name:'#{svc.name}'" @@ -1018,7 +1018,7 @@ def expect_svc_with_vms it 'returns the metric rollups for the service' do api_basic_authorize subcollection_action_identifier(:services, :metric_rollups, :read, :get) - get(url, :capture_interval => 'hourly', :start_date => Time.zone.today.to_s) + get(url, :params => { :capture_interval => 'hourly', :start_date => Time.zone.today.to_s }) expected = { 'count' => 5, @@ -1033,7 +1033,7 @@ def expect_svc_with_vms it 'will not return metric rollups without an appropriate role' do api_basic_authorize - get(url, :capture_interval => 'hourly', :start_date => Time.zone.today.to_s) + get(url, :params => { :capture_interval => 'hourly', :start_date => Time.zone.today.to_s }) expect(response).to have_http_status(:forbidden) end diff --git a/spec/requests/set_ownership_spec.rb b/spec/requests/set_ownership_spec.rb index 6006df3b92..330df6f97d 100644 --- a/spec/requests/set_ownership_spec.rb +++ b/spec/requests/set_ownership_spec.rb @@ -19,7 +19,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "to an invalid service" do api_basic_authorize action_identifier(:services, :set_ownership) - post(api_service_url(nil, 999_999), gen_request(:set_ownership, "owner" => {"id" => 1})) + post(api_service_url(nil, 999_999), :params => gen_request(:set_ownership, "owner" => {"id" => 1})) expect(response).to have_http_status(:not_found) end @@ -27,7 +27,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "without appropriate action role" do api_basic_authorize - post(api_service_url(nil, svc), gen_request(:set_ownership, "owner" => {"id" => 1})) + post(api_service_url(nil, svc), :params => gen_request(:set_ownership, "owner" => {"id" => 1})) expect(response).to have_http_status(:forbidden) end @@ -35,7 +35,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "with missing owner or group" do api_basic_authorize action_identifier(:services, :set_ownership) - post(api_service_url(nil, svc), gen_request(:set_ownership)) + post(api_service_url(nil, svc), :params => gen_request(:set_ownership)) expect_bad_request("Must specify an owner or group") end @@ -43,7 +43,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "with invalid owner" do api_basic_authorize action_identifier(:services, :set_ownership) - post(api_service_url(nil, svc), gen_request(:set_ownership, "owner" => {"id" => 999_999})) + post(api_service_url(nil, svc), :params => gen_request(:set_ownership, "owner" => {"id" => 999_999})) expect_single_action_result(:success => false, :message => /.*/, :href => api_service_url(nil, svc.compressed_id)) end @@ -51,7 +51,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "to a service" do api_basic_authorize action_identifier(:services, :set_ownership) - post(api_service_url(nil, svc), gen_request(:set_ownership, "owner" => {"userid" => api_config(:user)})) + post(api_service_url(nil, svc), :params => gen_request(:set_ownership, "owner" => {"userid" => api_config(:user)})) expect_set_ownership_success(svc, api_service_url(nil, svc.compressed_id), @user) end @@ -59,7 +59,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "by owner name to a service" do api_basic_authorize action_identifier(:services, :set_ownership) - post(api_service_url(nil, svc), gen_request(:set_ownership, "owner" => {"name" => @user.name})) + post(api_service_url(nil, svc), :params => gen_request(:set_ownership, "owner" => {"name" => @user.name})) expect_set_ownership_success(svc, api_service_url(nil, svc.compressed_id), @user) end @@ -67,7 +67,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "by owner href to a service" do api_basic_authorize action_identifier(:services, :set_ownership) - post(api_service_url(nil, svc), gen_request(:set_ownership, "owner" => {"href" => api_user_url(nil, @user)})) + post(api_service_url(nil, svc), :params => gen_request(:set_ownership, "owner" => {"href" => api_user_url(nil, @user)})) expect_set_ownership_success(svc, api_service_url(nil, svc.compressed_id), @user) end @@ -75,7 +75,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "by owner id to a service" do api_basic_authorize action_identifier(:services, :set_ownership) - post(api_service_url(nil, svc), gen_request(:set_ownership, "owner" => {"id" => @user.id})) + post(api_service_url(nil, svc), :params => gen_request(:set_ownership, "owner" => {"id" => @user.id})) expect_set_ownership_success(svc, api_service_url(nil, svc.compressed_id), @user) end @@ -83,7 +83,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "by group id to a service" do api_basic_authorize action_identifier(:services, :set_ownership) - post(api_service_url(nil, svc), gen_request(:set_ownership, "group" => {"id" => @group.id})) + post(api_service_url(nil, svc), :params => gen_request(:set_ownership, "group" => {"id" => @group.id})) expect_set_ownership_success(svc, api_service_url(nil, svc.compressed_id), nil, @group) end @@ -91,7 +91,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "by group description to a service" do api_basic_authorize action_identifier(:services, :set_ownership) - post(api_service_url(nil, svc), gen_request(:set_ownership, "group" => {"description" => @group.description})) + post(api_service_url(nil, svc), :params => gen_request(:set_ownership, "group" => {"description" => @group.description})) expect_set_ownership_success(svc, api_service_url(nil, svc.compressed_id), nil, @group) end @@ -99,7 +99,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "with owner and group to a service" do api_basic_authorize action_identifier(:services, :set_ownership) - post(api_service_url(nil, svc), gen_request(:set_ownership, "owner" => {"userid" => api_config(:user)})) + post(api_service_url(nil, svc), :params => gen_request(:set_ownership, "owner" => {"userid" => api_config(:user)})) expect_set_ownership_success(svc, api_service_url(nil, svc.compressed_id), @user) end @@ -111,7 +111,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) svc2 = FactoryGirl.create(:service, :name => "svc2", :description => "svc2 description") svc_urls = [api_service_url(nil, svc1), api_service_url(nil, svc2)] - post(api_services_url, gen_request(:set_ownership, {"owner" => {"userid" => api_config(:user)}}, *svc_urls)) + post(api_services_url, :params => gen_request(:set_ownership, {"owner" => {"userid" => api_config(:user)}}, *svc_urls)) expect_multiple_action_result(2) expect_result_resources_to_include_hrefs("results", [api_service_url(nil, svc1.compressed_id), api_service_url(nil, svc2.compressed_id)]) @@ -126,7 +126,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "to an invalid vm" do api_basic_authorize action_identifier(:vms, :set_ownership) - post(api_vm_url(nil, 999_999), gen_request(:set_ownership, "owner" => {"id" => 1})) + post(api_vm_url(nil, 999_999), :params => gen_request(:set_ownership, "owner" => {"id" => 1})) expect(response).to have_http_status(:not_found) end @@ -134,7 +134,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "without appropriate action role" do api_basic_authorize - post(api_vm_url(nil, vm), gen_request(:set_ownership, "owner" => {"id" => 1})) + post(api_vm_url(nil, vm), :params => gen_request(:set_ownership, "owner" => {"id" => 1})) expect(response).to have_http_status(:forbidden) end @@ -142,7 +142,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "with missing owner or group" do api_basic_authorize action_identifier(:vms, :set_ownership) - post(api_vm_url(nil, vm), gen_request(:set_ownership)) + post(api_vm_url(nil, vm), :params => gen_request(:set_ownership)) expect_bad_request("Must specify an owner or group") end @@ -150,7 +150,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "with invalid owner" do api_basic_authorize action_identifier(:vms, :set_ownership) - post(api_vm_url(nil, vm), gen_request(:set_ownership, "owner" => {"id" => 999_999})) + post(api_vm_url(nil, vm), :params => gen_request(:set_ownership, "owner" => {"id" => 999_999})) expect_single_action_result(:success => false, :message => /.*/, :href => api_vm_url(nil, vm.compressed_id)) end @@ -158,7 +158,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "to a vm" do api_basic_authorize action_identifier(:vms, :set_ownership) - post(api_vm_url(nil, vm), gen_request(:set_ownership, "owner" => {"userid" => api_config(:user)})) + post(api_vm_url(nil, vm), :params => gen_request(:set_ownership, "owner" => {"userid" => api_config(:user)})) expect_set_ownership_success(vm, api_vm_url(nil, vm.compressed_id), @user) end @@ -166,7 +166,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "by owner name to a vm" do api_basic_authorize action_identifier(:vms, :set_ownership) - post(api_vm_url(nil, vm), gen_request(:set_ownership, "owner" => {"name" => @user.name})) + post(api_vm_url(nil, vm), :params => gen_request(:set_ownership, "owner" => {"name" => @user.name})) expect_set_ownership_success(vm, api_vm_url(nil, vm.compressed_id), @user) end @@ -174,7 +174,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "by owner href to a vm" do api_basic_authorize action_identifier(:vms, :set_ownership) - post(api_vm_url(nil, vm), gen_request(:set_ownership, "owner" => {"href" => api_user_url(nil, @user)})) + post(api_vm_url(nil, vm), :params => gen_request(:set_ownership, "owner" => {"href" => api_user_url(nil, @user)})) expect_set_ownership_success(vm, api_vm_url(nil, vm.compressed_id), @user) end @@ -182,7 +182,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "by owner id to a vm" do api_basic_authorize action_identifier(:vms, :set_ownership) - post(api_vm_url(nil, vm), gen_request(:set_ownership, "owner" => {"id" => @user.id})) + post(api_vm_url(nil, vm), :params => gen_request(:set_ownership, "owner" => {"id" => @user.id})) expect_set_ownership_success(vm, api_vm_url(nil, vm.compressed_id), @user) end @@ -190,7 +190,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "by group id to a vm" do api_basic_authorize action_identifier(:vms, :set_ownership) - post(api_vm_url(nil, vm), gen_request(:set_ownership, "group" => {"id" => @group.id})) + post(api_vm_url(nil, vm), :params => gen_request(:set_ownership, "group" => {"id" => @group.id})) expect_set_ownership_success(vm, api_vm_url(nil, vm.compressed_id), nil, @group) end @@ -198,7 +198,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "by group description to a vm" do api_basic_authorize action_identifier(:vms, :set_ownership) - post(api_vm_url(nil, vm), gen_request(:set_ownership, "group" => {"description" => @group.description})) + post(api_vm_url(nil, vm), :params => gen_request(:set_ownership, "group" => {"description" => @group.description})) expect_set_ownership_success(vm, api_vm_url(nil, vm.compressed_id), nil, @group) end @@ -206,7 +206,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "with owner and group to a vm" do api_basic_authorize action_identifier(:vms, :set_ownership) - post(api_vm_url(nil, vm), gen_request(:set_ownership, "owner" => {"userid" => api_config(:user)})) + post(api_vm_url(nil, vm), :params => gen_request(:set_ownership, "owner" => {"userid" => api_config(:user)})) expect_set_ownership_success(vm, api_vm_url(nil, vm.compressed_id), @user) end @@ -218,7 +218,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) vm2 = FactoryGirl.create(:vm, :name => "vm2", :description => "vm2 description") vm_urls = [api_vm_url(nil, vm1), api_vm_url(nil, vm2)] - post(api_vms_url, gen_request(:set_ownership, {"owner" => {"userid" => api_config(:user)}}, *vm_urls)) + post(api_vms_url, :params => gen_request(:set_ownership, {"owner" => {"userid" => api_config(:user)}}, *vm_urls)) expect_multiple_action_result(2) expect_result_resources_to_include_hrefs("results", [api_vm_url(nil, vm1.compressed_id), api_vm_url(nil, vm2.compressed_id)]) @@ -233,7 +233,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "to an invalid template" do api_basic_authorize action_identifier(:templates, :set_ownership) - post(api_template_url(nil, 999_999), gen_request(:set_ownership, "owner" => {"id" => 1})) + post(api_template_url(nil, 999_999), :params => gen_request(:set_ownership, "owner" => {"id" => 1})) expect(response).to have_http_status(:not_found) end @@ -241,7 +241,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "without appropriate action role" do api_basic_authorize - post(api_template_url(nil, template), gen_request(:set_ownership, "owner" => {"id" => 1})) + post(api_template_url(nil, template), :params => gen_request(:set_ownership, "owner" => {"id" => 1})) expect(response).to have_http_status(:forbidden) end @@ -249,7 +249,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "with missing owner or group" do api_basic_authorize action_identifier(:templates, :set_ownership) - post(api_template_url(nil, template), gen_request(:set_ownership)) + post(api_template_url(nil, template), :params => gen_request(:set_ownership)) expect_bad_request("Must specify an owner or group") end @@ -257,7 +257,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "with invalid owner" do api_basic_authorize action_identifier(:templates, :set_ownership) - post(api_template_url(nil, template), gen_request(:set_ownership, "owner" => {"id" => 999_999})) + post(api_template_url(nil, template), :params => gen_request(:set_ownership, "owner" => {"id" => 999_999})) expect_single_action_result(:success => false, :message => /.*/, :href => api_template_url(nil, template.compressed_id)) end @@ -265,7 +265,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "to a template" do api_basic_authorize action_identifier(:templates, :set_ownership) - post(api_template_url(nil, template), gen_request(:set_ownership, "owner" => {"userid" => api_config(:user)})) + post(api_template_url(nil, template), :params => gen_request(:set_ownership, "owner" => {"userid" => api_config(:user)})) expect_set_ownership_success(template, api_template_url(nil, template.compressed_id), @user) end @@ -273,7 +273,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "by owner name to a template" do api_basic_authorize action_identifier(:templates, :set_ownership) - post(api_template_url(nil, template), gen_request(:set_ownership, "owner" => {"name" => @user.name})) + post(api_template_url(nil, template), :params => gen_request(:set_ownership, "owner" => {"name" => @user.name})) expect_set_ownership_success(template, api_template_url(nil, template.compressed_id), @user) end @@ -281,7 +281,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "by owner href to a template" do api_basic_authorize action_identifier(:templates, :set_ownership) - post(api_template_url(nil, template), gen_request(:set_ownership, "owner" => {"href" => api_user_url(nil, @user)})) + post(api_template_url(nil, template), :params => gen_request(:set_ownership, "owner" => {"href" => api_user_url(nil, @user)})) expect_set_ownership_success(template, api_template_url(nil, template.compressed_id), @user) end @@ -289,7 +289,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "by owner id to a template" do api_basic_authorize action_identifier(:templates, :set_ownership) - post(api_template_url(nil, template), gen_request(:set_ownership, "owner" => {"id" => @user.id})) + post(api_template_url(nil, template), :params => gen_request(:set_ownership, "owner" => {"id" => @user.id})) expect_set_ownership_success(template, api_template_url(nil, template.compressed_id), @user) end @@ -297,7 +297,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "by group id to a template" do api_basic_authorize action_identifier(:templates, :set_ownership) - post(api_template_url(nil, template), gen_request(:set_ownership, "group" => {"id" => @group.id})) + post(api_template_url(nil, template), :params => gen_request(:set_ownership, "group" => {"id" => @group.id})) expect_set_ownership_success(template, api_template_url(nil, template.compressed_id), nil, @group) end @@ -306,7 +306,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) api_basic_authorize action_identifier(:templates, :set_ownership) post(api_template_url(nil, template), - gen_request(:set_ownership, "group" => {"description" => @group.description})) + :params => gen_request(:set_ownership, "group" => {"description" => @group.description})) expect_set_ownership_success(template, api_template_url(nil, template.compressed_id), nil, @group) end @@ -314,7 +314,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) it "with owner and group to a template" do api_basic_authorize action_identifier(:templates, :set_ownership) - post(api_template_url(nil, template), gen_request(:set_ownership, "owner" => {"userid" => api_config(:user)})) + post(api_template_url(nil, template), :params => gen_request(:set_ownership, "owner" => {"userid" => api_config(:user)})) expect_set_ownership_success(template, api_template_url(nil, template.compressed_id), @user) end @@ -326,7 +326,7 @@ def expect_set_ownership_success(object, href, user = nil, group = nil) template2 = FactoryGirl.create(:template_vmware, :name => "template2") template_urls = [api_template_url(nil, template1), api_template_url(nil, template2)] - post(api_templates_url, gen_request(:set_ownership, {"owner" => {"userid" => api_config(:user)}}, *template_urls)) + post(api_templates_url, :params => gen_request(:set_ownership, {"owner" => {"userid" => api_config(:user)}}, *template_urls)) expect_multiple_action_result(2) expect_result_resources_to_include_hrefs("results", [api_template_url(nil, template1.compressed_id), api_template_url(nil, template2.compressed_id)]) diff --git a/spec/requests/snapshots_spec.rb b/spec/requests/snapshots_spec.rb index 87840b2c45..d068ce6f82 100644 --- a/spec/requests/snapshots_spec.rb +++ b/spec/requests/snapshots_spec.rb @@ -69,7 +69,7 @@ host = FactoryGirl.create(:host, :ext_management_system => ems) vm = FactoryGirl.create(:vm_vmware, :name => "Alice's VM", :host => host, :ext_management_system => ems) - post(api_vm_snapshots_url(nil, vm), :name => "Alice's snapshot") + post(api_vm_snapshots_url(nil, vm), :params => { :name => "Alice's snapshot" }) expected = { "results" => [ @@ -89,7 +89,7 @@ api_basic_authorize(subcollection_action_identifier(:vms, :snapshots, :create)) vm = FactoryGirl.create(:vm_vmware) - post(api_vm_snapshots_url(nil, vm), :name => "Alice's snapsnot") + post(api_vm_snapshots_url(nil, vm), :params => { :name => "Alice's snapsnot" }) expected = { "results" => [ @@ -109,7 +109,7 @@ host = FactoryGirl.create(:host, :ext_management_system => ems) vm = FactoryGirl.create(:vm_vmware, :name => "Alice's VM", :host => host, :ext_management_system => ems) - post(api_vm_snapshots_url(nil, vm), :description => "Alice's snapshot") + post(api_vm_snapshots_url(nil, vm), :params => { :description => "Alice's snapshot" }) expected = { "results" => [ @@ -127,7 +127,7 @@ api_basic_authorize vm = FactoryGirl.create(:vm_vmware) - post(api_vm_snapshots_url(nil, vm), :description => "Alice's snapshot") + post(api_vm_snapshots_url(nil, vm), :params => { :description => "Alice's snapshot" }) expect(response).to have_http_status(:forbidden) end @@ -141,7 +141,7 @@ vm = FactoryGirl.create(:vm_vmware, :name => "Alice's VM", :host => host, :ext_management_system => ems) snapshot = FactoryGirl.create(:snapshot, :name => "Alice's snapshot", :vm_or_template => vm) - post(api_vm_snapshot_url(nil, vm, snapshot), :action => "revert") + post(api_vm_snapshot_url(nil, vm, snapshot), :params => { :action => "revert" }) expected = { "message" => "Reverting to snapshot Alice's snapshot for Virtual Machine id:#{vm.id} name:'Alice's VM'", @@ -158,7 +158,7 @@ vm = FactoryGirl.create(:vm_vmware) snapshot = FactoryGirl.create(:snapshot, :vm_or_template => vm) - post(api_vm_snapshot_url(nil, vm, snapshot), :action => "revert") + post(api_vm_snapshot_url(nil, vm, snapshot), :params => { :action => "revert" }) expected = { "success" => false, @@ -173,7 +173,7 @@ vm = FactoryGirl.create(:vm_vmware) snapshot = FactoryGirl.create(:snapshot, :vm_or_template => vm) - post(api_vm_snapshot_url(nil, vm, snapshot), :action => "revert") + post(api_vm_snapshot_url(nil, vm, snapshot), :params => { :action => "revert" }) expect(response).to have_http_status(:forbidden) end @@ -187,7 +187,7 @@ vm = FactoryGirl.create(:vm_vmware, :name => "Alice's VM", :host => host, :ext_management_system => ems) snapshot = FactoryGirl.create(:snapshot, :name => "Alice's snapshot", :vm_or_template => vm) - post(api_vm_snapshot_url(nil, vm, snapshot), :action => "delete") + post(api_vm_snapshot_url(nil, vm, snapshot), :params => { :action => "delete" }) expected = { "message" => "Deleting snapshot Alice's snapshot for Virtual Machine id:#{vm.id} name:'Alice's VM'", @@ -204,7 +204,7 @@ vm = FactoryGirl.create(:vm_vmware) snapshot = FactoryGirl.create(:snapshot, :vm_or_template => vm) - post(api_vm_snapshot_url(nil, vm, snapshot), :action => "delete") + post(api_vm_snapshot_url(nil, vm, snapshot), :params => { :action => "delete" }) expected = { "success" => false, @@ -219,7 +219,7 @@ vm = FactoryGirl.create(:vm_vmware) snapshot = FactoryGirl.create(:snapshot, :vm_or_template => vm) - post(api_vm_snapshot_url(nil, vm, snapshot), :action => "delete") + post(api_vm_snapshot_url(nil, vm, snapshot), :params => { :action => "delete" }) expect(response).to have_http_status(:forbidden) end @@ -228,7 +228,7 @@ api_basic_authorize(action_identifier(:vms, :delete, :snapshots_subresource_actions, :post)) vm = FactoryGirl.create(:vm_vmware) - post(api_vm_snapshot_url(nil, vm, 0), :action => "delete") + post(api_vm_snapshot_url(nil, vm, 0), :params => { :action => "delete" }) expected = { "error" => a_hash_including( @@ -253,11 +253,13 @@ post( api_vm_snapshots_url(nil, vm), - :action => "delete", - :resources => [ - {:href => api_vm_snapshot_url(nil, vm, snapshot1)}, - {:href => api_vm_snapshot_url(nil, vm, snapshot2)} - ] + :params => { + :action => "delete", + :resources => [ + {:href => api_vm_snapshot_url(nil, vm, snapshot1)}, + {:href => api_vm_snapshot_url(nil, vm, snapshot2)} + ] + } ) expected = { @@ -286,10 +288,10 @@ post( api_vm_snapshots_url(nil, vm), - :action => "delete", - :resources => [ - {:href => api_vm_snapshot_url(nil, vm, 0)} - ] + :params => { + :action => "delete", + :resources => [{:href => api_vm_snapshot_url(nil, vm, 0)}] + } ) expected = { @@ -414,7 +416,7 @@ host = FactoryGirl.create(:host_openstack_infra, :ext_management_system => ems) instance = FactoryGirl.create(:vm_openstack, :name => "Alice's Instance", :ext_management_system => ems, :host => host) - post(api_instance_snapshots_url(nil, instance), :name => "Alice's snapshot") + post(api_instance_snapshots_url(nil, instance), :params => { :name => "Alice's snapshot" }) expected = { "results" => [ @@ -434,7 +436,7 @@ api_basic_authorize(subcollection_action_identifier(:instances, :snapshots, :create)) instance = FactoryGirl.create(:vm_openstack) - post(api_instance_snapshots_url(nil, instance), :name => "Alice's snapsnot") + post(api_instance_snapshots_url(nil, instance), :params => { :name => "Alice's snapsnot" }) expected = { "results" => [ @@ -454,7 +456,7 @@ host = FactoryGirl.create(:host_openstack_infra, :ext_management_system => ems) instance = FactoryGirl.create(:vm_openstack, :name => "Alice's Instance", :ext_management_system => ems, :host => host) - post(api_instance_snapshots_url(nil, instance), :description => "Alice's snapshot") + post(api_instance_snapshots_url(nil, instance), :params => { :description => "Alice's snapshot" }) expected = { "results" => [ @@ -472,7 +474,7 @@ api_basic_authorize instance = FactoryGirl.create(:vm_openstack) - post(api_instance_snapshots_url(nil, instance), :description => "Alice's snapshot") + post(api_instance_snapshots_url(nil, instance), :params => { :description => "Alice's snapshot" }) expect(response).to have_http_status(:forbidden) end @@ -487,7 +489,7 @@ instance = FactoryGirl.create(:vm_openstack, :name => "Alice's Instance", :ext_management_system => ems, :host => host) snapshot = FactoryGirl.create(:snapshot, :name => "Alice's snapshot", :vm_or_template => instance) - post(api_instance_snapshot_url(nil, instance, snapshot), :action => "delete") + post(api_instance_snapshot_url(nil, instance, snapshot), :params => { :action => "delete" }) expected = { "message" => "Deleting snapshot Alice's snapshot for Instance id:#{instance.id} name:'Alice's Instance'", @@ -504,7 +506,7 @@ instance = FactoryGirl.create(:vm_openstack) snapshot = FactoryGirl.create(:snapshot, :vm_or_template => instance) - post(api_instance_snapshot_url(nil, instance, snapshot), :action => "delete") + post(api_instance_snapshot_url(nil, instance, snapshot), :params => { :action => "delete" }) expected = { "success" => false, @@ -519,7 +521,7 @@ instance = FactoryGirl.create(:vm_openstack) snapshot = FactoryGirl.create(:snapshot, :vm_or_template => instance) - post(api_instance_snapshot_url(nil, instance, snapshot), :action => "delete") + post(api_instance_snapshot_url(nil, instance, snapshot), :params => { :action => "delete" }) expect(response).to have_http_status(:forbidden) end @@ -537,11 +539,13 @@ post( api_instance_snapshots_url(nil, instance), - :action => "delete", - :resources => [ - {:href => api_instance_snapshot_url(nil, instance, snapshot1)}, - {:href => api_instance_snapshot_url(nil, instance, snapshot2)} - ] + :params => { + :action => "delete", + :resources => [ + {:href => api_instance_snapshot_url(nil, instance, snapshot1)}, + {:href => api_instance_snapshot_url(nil, instance, snapshot2)} + ] + } ) expected = { diff --git a/spec/requests/tag_collections_spec.rb b/spec/requests/tag_collections_spec.rb index 3598d78027..dc9748d204 100644 --- a/spec/requests/tag_collections_spec.rb +++ b/spec/requests/tag_collections_spec.rb @@ -37,7 +37,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize classify_resource(provider) - get api_provider_tags_url(nil, provider), :expand => "resources" + get api_provider_tags_url(nil, provider), :params => { :expand => "resources" } expect_query_result(:tags, 2, Tag.count) expect_result_resources_to_include_data("resources", "name" => tag_paths) @@ -46,7 +46,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not assign a tag to a Provider without appropriate role" do api_basic_authorize - post(api_provider_tags_url(nil, provider), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_provider_tags_url(nil, provider), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -54,7 +54,7 @@ def expect_resource_has_tags(resource, tag_names) it "assigns a tag to a Provider" do api_basic_authorize subcollection_action_identifier(:providers, :tags, :assign) - post(api_provider_tags_url(nil, provider), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_provider_tags_url(nil, provider), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_provider_url(nil, provider.compressed_id))) end @@ -62,7 +62,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not unassign a tag from a Provider without appropriate role" do api_basic_authorize - post(api_provider_tags_url(nil, provider), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_provider_tags_url(nil, provider), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -71,7 +71,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize subcollection_action_identifier(:providers, :tags, :unassign) classify_resource(provider) - post(api_provider_tags_url(nil, provider), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_provider_tags_url(nil, provider), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_provider_url(nil, provider.compressed_id))) expect_resource_has_tags(provider, tag2[:path]) @@ -83,7 +83,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize classify_resource(host) - get api_host_tags_url(nil, host), :expand => "resources" + get api_host_tags_url(nil, host), :params => { :expand => "resources" } expect_query_result(:tags, 2, Tag.count) expect_result_resources_to_include_data("resources", "name" => tag_paths) @@ -92,7 +92,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not assign a tag to a Host without appropriate role" do api_basic_authorize - post(api_host_tags_url(nil, host), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_host_tags_url(nil, host), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -100,7 +100,7 @@ def expect_resource_has_tags(resource, tag_names) it "assigns a tag to a Host" do api_basic_authorize subcollection_action_identifier(:hosts, :tags, :assign) - post(api_host_tags_url(nil, host), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_host_tags_url(nil, host), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_host_url(nil, host.compressed_id))) end @@ -108,7 +108,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not unassign a tag from a Host without appropriate role" do api_basic_authorize - post(api_host_tags_url(nil, host), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_host_tags_url(nil, host), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -117,7 +117,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize subcollection_action_identifier(:hosts, :tags, :unassign) classify_resource(host) - post(api_host_tags_url(nil, host), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_host_tags_url(nil, host), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_host_url(nil, host.compressed_id))) expect_resource_has_tags(host, tag2[:path]) @@ -131,7 +131,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize classify_resource(ds) - get api_data_store_tags_url(nil, ds), :expand => "resources" + get api_data_store_tags_url(nil, ds), :params => { :expand => "resources" } expect_query_result(:tags, 2, Tag.count) expect_result_resources_to_include_data("resources", "name" => tag_paths) @@ -140,7 +140,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not assign a tag to a Data Store without appropriate role" do api_basic_authorize - post(api_data_store_tags_url(nil, ds), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_data_store_tags_url(nil, ds), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -148,7 +148,7 @@ def expect_resource_has_tags(resource, tag_names) it "assigns a tag to a Data Store" do api_basic_authorize subcollection_action_identifier(:data_stores, :tags, :assign) - post(api_data_store_tags_url(nil, ds), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_data_store_tags_url(nil, ds), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_data_store_url(nil, ds.compressed_id))) end @@ -156,7 +156,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not unassign a tag from a Data Store without appropriate role" do api_basic_authorize - post(api_data_store_tags_url(nil, ds), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_data_store_tags_url(nil, ds), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -165,7 +165,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize subcollection_action_identifier(:data_stores, :tags, :unassign) classify_resource(ds) - post(api_data_store_tags_url(nil, ds), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_data_store_tags_url(nil, ds), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_data_store_url(nil, ds.compressed_id))) expect_resource_has_tags(ds, tag2[:path]) @@ -179,7 +179,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize classify_resource(rp) - get api_resource_pool_tags_url(nil, rp), :expand => "resources" + get api_resource_pool_tags_url(nil, rp), :params => { :expand => "resources" } expect_query_result(:tags, 2, Tag.count) expect_result_resources_to_include_data("resources", "name" => tag_paths) @@ -188,7 +188,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not assign a tag to a Resource Pool without appropriate role" do api_basic_authorize - post(api_resource_pool_tags_url(nil, rp), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_resource_pool_tags_url(nil, rp), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -196,7 +196,7 @@ def expect_resource_has_tags(resource, tag_names) it "assigns a tag to a Resource Pool" do api_basic_authorize subcollection_action_identifier(:resource_pools, :tags, :assign) - post(api_resource_pool_tags_url(nil, rp), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_resource_pool_tags_url(nil, rp), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_resource_pool_url(nil, rp.compressed_id))) end @@ -204,7 +204,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not unassign a tag from a Resource Pool without appropriate role" do api_basic_authorize - post(api_resource_pool_tags_url(nil, rp), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_resource_pool_tags_url(nil, rp), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -213,7 +213,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize subcollection_action_identifier(:resource_pools, :tags, :unassign) classify_resource(rp) - post(api_resource_pool_tags_url(nil, rp), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_resource_pool_tags_url(nil, rp), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_resource_pool_url(nil, rp.compressed_id))) expect_resource_has_tags(rp, tag2[:path]) @@ -233,7 +233,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize classify_resource(cluster) - get api_cluster_tags_url(nil, cluster), :expand => "resources" + get api_cluster_tags_url(nil, cluster), :params => { :expand => "resources" } expect_query_result(:tags, 2, Tag.count) expect_result_resources_to_include_data("resources", "name" => tag_paths) @@ -242,7 +242,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not assign a tag to a Cluster without appropriate role" do api_basic_authorize - post(api_cluster_tags_url(nil, cluster), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_cluster_tags_url(nil, cluster), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -250,7 +250,7 @@ def expect_resource_has_tags(resource, tag_names) it "assigns a tag to a Cluster" do api_basic_authorize subcollection_action_identifier(:clusters, :tags, :assign) - post(api_cluster_tags_url(nil, cluster), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_cluster_tags_url(nil, cluster), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_cluster_url(nil, cluster.compressed_id))) end @@ -258,7 +258,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not unassign a tag from a Cluster without appropriate role" do api_basic_authorize - post(api_cluster_tags_url(nil, cluster), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_cluster_tags_url(nil, cluster), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -267,7 +267,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize subcollection_action_identifier(:clusters, :tags, :unassign) classify_resource(cluster) - post(api_cluster_tags_url(nil, cluster), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_cluster_tags_url(nil, cluster), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_cluster_url(nil, cluster.compressed_id))) expect_resource_has_tags(cluster, tag2[:path]) @@ -281,7 +281,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize classify_resource(service) - get api_service_tags_url(nil, service), :expand => "resources" + get api_service_tags_url(nil, service), :params => { :expand => "resources" } expect_query_result(:tags, 2, Tag.count) expect_result_resources_to_include_data("resources", "name" => tag_paths) @@ -290,7 +290,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not assign a tag to a Service without appropriate role" do api_basic_authorize - post(api_service_tags_url(nil, service), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_service_tags_url(nil, service), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -298,7 +298,7 @@ def expect_resource_has_tags(resource, tag_names) it "assigns a tag to a Service" do api_basic_authorize subcollection_action_identifier(:services, :tags, :assign) - post(api_service_tags_url(nil, service), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_service_tags_url(nil, service), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_service_url(nil, service.compressed_id))) end @@ -306,7 +306,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not unassign a tag from a Service without appropriate role" do api_basic_authorize - post(api_service_tags_url(nil, service), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_service_tags_url(nil, service), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -315,7 +315,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize subcollection_action_identifier(:services, :tags, :unassign) classify_resource(service) - post(api_service_tags_url(nil, service), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_service_tags_url(nil, service), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_service_url(nil, service.compressed_id))) expect_resource_has_tags(service, tag2[:path]) @@ -329,7 +329,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize classify_resource(service_template) - get api_service_template_tags_url(nil, service_template), :expand => "resources" + get api_service_template_tags_url(nil, service_template), :params => { :expand => "resources" } expect_query_result(:tags, 2, Tag.count) expect_result_resources_to_include_data("resources", "name" => tag_paths) @@ -338,7 +338,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not assign a tag to a Service Template without appropriate role" do api_basic_authorize - post(api_service_template_tags_url(nil, service_template), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_service_template_tags_url(nil, service_template), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -346,7 +346,7 @@ def expect_resource_has_tags(resource, tag_names) it "assigns a tag to a Service Template" do api_basic_authorize subcollection_action_identifier(:service_templates, :tags, :assign) - post(api_service_template_tags_url(nil, service_template), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_service_template_tags_url(nil, service_template), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_service_template_url(nil, service_template.compressed_id))) end @@ -354,7 +354,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not unassign a tag from a Service Template without appropriate role" do api_basic_authorize - post(api_service_template_tags_url(nil, service_template), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_service_template_tags_url(nil, service_template), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -363,7 +363,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize subcollection_action_identifier(:service_templates, :tags, :unassign) classify_resource(service_template) - post(api_service_template_tags_url(nil, service_template), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_service_template_tags_url(nil, service_template), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_service_template_url(nil, service_template.compressed_id))) expect_resource_has_tags(service_template, tag2[:path]) @@ -377,7 +377,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize classify_resource(tenant) - get api_tenant_tags_url(nil, tenant), :expand => "resources" + get api_tenant_tags_url(nil, tenant), :params => { :expand => "resources" } expect_query_result(:tags, 2, Tag.count) expect_result_resources_to_include_data("resources", "name" => tag_paths) @@ -386,7 +386,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not assign a tag to a Tenant without appropriate role" do api_basic_authorize - post(api_tenant_tags_url(nil, tenant), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_tenant_tags_url(nil, tenant), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -394,7 +394,7 @@ def expect_resource_has_tags(resource, tag_names) it "assigns a tag to a Tenant" do api_basic_authorize subcollection_action_identifier(:tenants, :tags, :assign) - post(api_tenant_tags_url(nil, tenant), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_tenant_tags_url(nil, tenant), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_tenant_url(nil, tenant.compressed_id))) end @@ -402,7 +402,7 @@ def expect_resource_has_tags(resource, tag_names) it "does not unassign a tag from a Tenant without appropriate role" do api_basic_authorize - post(api_tenant_tags_url(nil, tenant), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_tenant_tags_url(nil, tenant), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -411,7 +411,7 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize subcollection_action_identifier(:tenants, :tags, :unassign) classify_resource(tenant) - post(api_tenant_tags_url(nil, tenant), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_tenant_tags_url(nil, tenant), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result(tag1_results(api_tenant_url(nil, tenant.compressed_id))) expect_resource_has_tags(tenant, tag2[:path]) @@ -432,10 +432,14 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize subcollection_action_identifier(:blueprints, :tags, :assign) blueprint = FactoryGirl.create(:blueprint) - post(api_blueprint_tags_url(nil, blueprint), - :action => "assign", - :category => tag1[:category], - :name => tag1[:name]) + post( + api_blueprint_tags_url(nil, blueprint), + :params => { + :action => "assign", + :category => tag1[:category], + :name => tag1[:name] + } + ) expect(response).to have_http_status(:ok) end @@ -445,10 +449,14 @@ def expect_resource_has_tags(resource, tag_names) blueprint = FactoryGirl.create(:blueprint) classify_resource(blueprint) - post(api_blueprint_tags_url(nil, blueprint), - :action => "unassign", - :category => tag1[:category], - :name => tag1[:name]) + post( + api_blueprint_tags_url(nil, blueprint), + :params => { + :action => "unassign", + :category => tag1[:category], + :name => tag1[:name] + } + ) expect(response).to have_http_status(:ok) end @@ -457,10 +465,14 @@ def expect_resource_has_tags(resource, tag_names) api_basic_authorize blueprint = FactoryGirl.create(:blueprint) - post(api_blueprint_tags_url(nil, blueprint), - :action => "assign", - :category => tag1[:category], - :name => tag1[:name]) + post( + api_blueprint_tags_url(nil, blueprint), + :params => { + :action => "assign", + :category => tag1[:category], + :name => tag1[:name] + } + ) expect(response).to have_http_status(:forbidden) end @@ -470,10 +482,14 @@ def expect_resource_has_tags(resource, tag_names) blueprint = FactoryGirl.create(:blueprint) classify_resource(blueprint) - post(api_blueprint_tags_url(nil, blueprint), - :action => "unassign", - :category => tag1[:category], - :name => tag1[:name]) + post( + api_blueprint_tags_url(nil, blueprint), + :params => { + :action => "unassign", + :category => tag1[:category], + :name => tag1[:name] + } + ) expect(response).to have_http_status(:forbidden) end @@ -494,7 +510,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_vms_url, request_body) + post(api_vms_url, :params => request_body) expected = { 'results' => [ @@ -520,7 +536,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_vms_url, request_body) + post(api_vms_url, :params => request_body) expected = { 'results' => [ @@ -551,7 +567,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_vms_url, request_body) + post(api_vms_url, :params => request_body) expected = { 'results' => [ @@ -573,7 +589,7 @@ def expect_resource_has_tags(resource, tag_names) it 'fails without an appropriate role' do api_basic_authorize - post(api_vms_url, :action => 'assign_tags') + post(api_vms_url, :params => { :action => 'assign_tags' }) expect(response).to have_http_status(:forbidden) end @@ -588,7 +604,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_vms_url, request_body) + post(api_vms_url, :params => request_body) expected = { 'results' => [ @@ -616,7 +632,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_vms_url, request_body) + post(api_vms_url, :params => request_body) expected = { 'results' => [ @@ -648,7 +664,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_services_url, request_body) + post(api_services_url, :params => request_body) expected = { 'results' => [ @@ -674,7 +690,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_services_url, request_body) + post(api_services_url, :params => request_body) expected = { 'results' => [ @@ -703,7 +719,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_services_url, request_body) + post(api_services_url, :params => request_body) expected = { 'results' => [ @@ -723,7 +739,7 @@ def expect_resource_has_tags(resource, tag_names) it 'fails without an appropriate role' do api_basic_authorize - post(api_services_url, :action => 'assign_tags') + post(api_services_url, :params => { :action => 'assign_tags' }) expect(response).to have_http_status(:forbidden) end @@ -738,7 +754,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_services_url, request_body) + post(api_services_url, :params => request_body) expected = { 'results' => [ @@ -764,7 +780,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_services_url, request_body) + post(api_services_url, :params => request_body) expected = { 'results' => [ @@ -801,7 +817,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_services_url, request_body) + post(api_services_url, :params => request_body) expected = { 'results' => [ @@ -829,7 +845,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_services_url, request_body) + post(api_services_url, :params => request_body) expected = { 'results' => [ @@ -860,7 +876,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_services_url, request_body) + post(api_services_url, :params => request_body) expected = { 'results' => [ @@ -881,7 +897,7 @@ def expect_resource_has_tags(resource, tag_names) it 'fails without an appropriate role' do api_basic_authorize - post(api_services_url, :action => 'unassign_tags') + post(api_services_url, :params => { :action => 'unassign_tags' }) expect(response).to have_http_status(:forbidden) end @@ -896,7 +912,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_services_url, request_body) + post(api_services_url, :params => request_body) expected = { 'results' => [ @@ -922,7 +938,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_services_url, request_body) + post(api_services_url, :params => request_body) expected = { 'results' => [ @@ -959,7 +975,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_vms_url, request_body) + post(api_vms_url, :params => request_body) expected = { 'results' => [ @@ -985,7 +1001,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_vms_url, request_body) + post(api_vms_url, :params => request_body) expected = { 'results' => [ @@ -1014,7 +1030,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_vms_url, request_body) + post(api_vms_url, :params => request_body) expected = { 'results' => [ @@ -1035,7 +1051,7 @@ def expect_resource_has_tags(resource, tag_names) it 'fails without an appropriate role' do api_basic_authorize - post(api_vms_url, :action => 'unassign_tags') + post(api_vms_url, :params => { :action => 'unassign_tags' }) expect(response).to have_http_status(:forbidden) end @@ -1050,7 +1066,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_vms_url, request_body) + post(api_vms_url, :params => request_body) expected = { 'results' => [ @@ -1076,7 +1092,7 @@ def expect_resource_has_tags(resource, tag_names) ] } - post(api_vms_url, request_body) + post(api_vms_url, :params => request_body) expected = { 'results' => [ diff --git a/spec/requests/tags_spec.rb b/spec/requests/tags_spec.rb index 0f69588f00..0eda36808c 100644 --- a/spec/requests/tags_spec.rb +++ b/spec/requests/tags_spec.rb @@ -26,7 +26,7 @@ category = FactoryGirl.create(:category) options = {:name => "test_tag", :description => "Test Tag", :category => {:href => api_category_url(nil, category)}} - expect { post api_tags_url, options }.to change(Tag, :count).by(1) + expect { post api_tags_url, :params => options }.to change(Tag, :count).by(1) result = response.parsed_body["results"].first tag = Tag.find(ApplicationRecord.uncompress_id(result["id"])) @@ -41,7 +41,7 @@ category = FactoryGirl.create(:category) expect do - post api_tags_url, :name => "test_tag", :description => "Test Tag", :category => {:id => category.id} + post api_tags_url, :params => { :name => "test_tag", :description => "Test Tag", :category => {:id => category.id} } end.to change(Tag, :count).by(1) tag = Tag.find(ApplicationRecord.uncompress_id(response.parsed_body["results"].first["id"])) @@ -56,7 +56,7 @@ category = FactoryGirl.create(:category) expect do - post api_tags_url, :name => "test_tag", :description => "Test Tag", :category => {:name => category.name} + post api_tags_url, :params => { :name => "test_tag", :description => "Test Tag", :category => {:name => category.name} } end.to change(Tag, :count).by(1) tag = Tag.find(ApplicationRecord.uncompress_id(response.parsed_body["results"].first["id"])) @@ -71,7 +71,7 @@ category = FactoryGirl.create(:category) expect do - post(api_category_tags_url(nil, category), :name => "test_tag", :description => "Test Tag") + post(api_category_tags_url(nil, category), :params => { :name => "test_tag", :description => "Test Tag" }) end.to change(Tag, :count).by(1) tag = Tag.find(ApplicationRecord.uncompress_id(response.parsed_body["results"].first["id"])) tag_category = Category.find(tag.category.id) @@ -83,7 +83,7 @@ it "returns bad request when the category doesn't exist" do api_basic_authorize collection_action_identifier(:tags, :create) - post api_tags_url, :name => "test_tag", :description => "Test Tag" + post api_tags_url, :params => { :name => "test_tag", :description => "Test Tag" } expect(response).to have_http_status(:bad_request) end @@ -95,7 +95,7 @@ tag = classification.tag expect do - post api_tag_url(nil, tag), gen_request(:edit, :name => "new_name") + post api_tag_url(nil, tag), :params => gen_request(:edit, :name => "new_name") end.to change { classification.reload.tag.name }.to("#{category.tag.name}/new_name") expect(response.parsed_body["name"]).to eq("#{category.tag.name}/new_name") expect(response).to have_http_status(:ok) @@ -108,7 +108,7 @@ tag = classification.tag expect do - post api_tag_url(nil, tag), gen_request(:edit, :description => "New Description") + post api_tag_url(nil, tag), :params => gen_request(:edit, :description => "New Description") end.to change { tag.reload.classification.description }.to("New Description") expect(response).to have_http_status(:ok) @@ -119,7 +119,7 @@ classification = FactoryGirl.create(:classification_tag) tag = classification.tag - expect { post api_tag_url(nil, tag), :action => :delete }.to change(Tag, :count).by(-1) + expect { post api_tag_url(nil, tag), :params => { :action => :delete } }.to change(Tag, :count).by(-1) expect { classification.reload }.to raise_error(ActiveRecord::RecordNotFound) expect(response).to have_http_status(:ok) end @@ -151,7 +151,7 @@ tag_id = classification.tag.id classification.destroy! - post api_tag_url(nil, tag_id), :action => :delete + post api_tag_url(nil, tag_id), :params => { :action => :delete } expect(response).to have_http_status(:not_found) end @@ -165,7 +165,7 @@ tag2 = classification2.tag expect do - post(api_category_tags_url(nil, category.id), gen_request(:delete, [{:id => tag1.id}, {:id => tag2.id}])) + post(api_category_tags_url(nil, category.id), :params => gen_request(:delete, [{:id => tag1.id}, {:id => tag2.id}])) end.to change(Tag, :count).by(-2) expect { classification1.reload }.to raise_error(ActiveRecord::RecordNotFound) expect { classification2.reload }.to raise_error(ActiveRecord::RecordNotFound) @@ -189,7 +189,7 @@ body = gen_request(:delete, [{:name => tag1.name}, {:name => tag2.name}]) expect do - post(api_category_tags_url(nil, category), body) + post(api_category_tags_url(nil, category), :params => body) end.to change(Tag, :count).by(-2) expect { classification1.reload }.to raise_error(ActiveRecord::RecordNotFound) expect { classification2.reload }.to raise_error(ActiveRecord::RecordNotFound) @@ -209,7 +209,7 @@ api_basic_authorize expect do - post api_tags_url, :name => "test_tag", :description => "Test Tag" + post api_tags_url, :params => { :name => "test_tag", :description => "Test Tag" } end.not_to change(Tag, :count) expect(response).to have_http_status(:forbidden) @@ -220,7 +220,7 @@ tag = Tag.create(:name => "Old name") expect do - post api_tag_url(nil, tag), gen_request(:edit, :name => "New name") + post api_tag_url(nil, tag), :params => gen_request(:edit, :name => "New name") end.not_to change { tag.reload.name } expect(response).to have_http_status(:forbidden) @@ -230,7 +230,7 @@ api_basic_authorize tag = Tag.create(:name => "Test tag") - expect { post api_tag_url(nil, tag), :action => :delete }.not_to change(Tag, :count) + expect { post api_tag_url(nil, tag), :params => { :action => :delete } }.not_to change(Tag, :count) expect(response).to have_http_status(:forbidden) end @@ -256,7 +256,7 @@ it "query tags with expanded resources" do api_basic_authorize collection_action_identifier(:tags, :read, :get) - get api_tags_url, :expand => "resources" + get api_tags_url, :params => { :expand => "resources" } expect_query_result(:tags, Tag.count, Tag.count) expect_result_resources_to_include_keys("resources", %w(id name)) @@ -267,7 +267,7 @@ tag = Tag.last attr_list = "category.name,category.description,classification.name,classification.description" - get api_tag_url(nil, tag), :attributes => attr_list + get api_tag_url(nil, tag), :params => { :attributes => attr_list } expect_single_resource_query( "href" => api_tag_url(nil, tag.compressed_id), @@ -282,7 +282,7 @@ api_basic_authorize action_identifier(:tags, :read, :resource_actions, :get) tag = Tag.last - get api_tag_url(nil, tag), :attributes => "categorization" + get api_tag_url(nil, tag), :params => { :attributes => "categorization" } expect_single_resource_query( "href" => api_tag_url(nil, tag.compressed_id), @@ -300,7 +300,7 @@ it "query all tags with categorization" do api_basic_authorize action_identifier(:tags, :read, :resource_actions, :get) - get api_tags_url, :expand => "resources", :attributes => "categorization" + get api_tags_url, :params => { :expand => "resources", :attributes => "categorization" } expect_query_result(:tags, Tag.count, Tag.count) expect_result_resources_to_include_keys("resources", %w(id name categorization)) diff --git a/spec/requests/templates_spec.rb b/spec/requests/templates_spec.rb index 15b39af3d2..787ab80986 100644 --- a/spec/requests/templates_spec.rb +++ b/spec/requests/templates_spec.rb @@ -5,7 +5,7 @@ template = FactoryGirl.create(:template) expect do - post(api_template_url(nil, template), :action => "delete") + post(api_template_url(nil, template), :params => { :action => "delete" }) end.to change(MiqTemplate, :count).by(-1) expected = { @@ -22,7 +22,7 @@ template = FactoryGirl.create(:template) expect do - post(api_template_url(nil, template), :action => "delete") + post(api_template_url(nil, template), :params => { :action => "delete" }) end.not_to change(MiqTemplate, :count) expect(response).to have_http_status(:forbidden) @@ -47,7 +47,7 @@ FactoryGirl.create(:classification_department_with_tags) api_basic_authorize(subcollection_action_identifier(:templates, :tags, :assign)) - post(api_template_tags_url(nil, template), :action => "assign", :category => "department", :name => "finance") + post(api_template_tags_url(nil, template), :params => { :action => "assign", :category => "department", :name => "finance" }) expected = { "results" => [ @@ -69,10 +69,14 @@ Classification.classify(template, "department", "finance") api_basic_authorize(subcollection_action_identifier(:templates, :tags, :unassign)) - post(api_template_tags_url(nil, template), - :action => "unassign", - :category => "department", - :name => "finance") + post( + api_template_tags_url(nil, template), + :params => { + :action => "unassign", + :category => "department", + :name => "finance" + } + ) expected = { "results" => [ diff --git a/spec/requests/tenant_quotas_spec.rb b/spec/requests/tenant_quotas_spec.rb index c08db7288b..26d551d644 100644 --- a/spec/requests/tenant_quotas_spec.rb +++ b/spec/requests/tenant_quotas_spec.rb @@ -49,7 +49,7 @@ ] } expect do - post "/api/tenants/#{tenant.id}/quotas/", :name => :cpu_allocated, :value => 1 + post "/api/tenants/#{tenant.id}/quotas/", :params => { :name => :cpu_allocated, :value => 1 } end.to change(TenantQuota, :count).by(1) expect(response.parsed_body).to include(expected) expect(response).to have_http_status(:ok) @@ -62,7 +62,7 @@ options = {:value => 5} - post "/api/tenants/#{tenant.id}/quotas/#{quota.id}", gen_request(:edit, options) + post "/api/tenants/#{tenant.id}/quotas/#{quota.id}", :params => gen_request(:edit, options) expect(response).to have_http_status(:ok) quota.reload @@ -76,7 +76,7 @@ options = {:value => 5} - put "/api/tenants/#{tenant.id}/quotas/#{quota.id}", options + put "/api/tenants/#{tenant.id}/quotas/#{quota.id}", :params => options expect(response).to have_http_status(:ok) quota.reload @@ -95,7 +95,7 @@ {"href" => "/api/tenants/#{tenant.id}/quotas/#{quota_2.id}", "value" => 4}, ] - post "/api/tenants/#{tenant.id}/quotas/", gen_request(:edit, options) + post "/api/tenants/#{tenant.id}/quotas/", :params => gen_request(:edit, options) expect(response).to have_http_status(:ok) expect_results_to_match_hash( @@ -113,7 +113,7 @@ quota = FactoryGirl.create(:tenant_quota, :tenant_id => tenant.id, :name => :cpu_allocated, :value => 1) expect do - post "/api/tenants/#{tenant.id}/quotas/#{quota.id}", gen_request(:delete) + post "/api/tenants/#{tenant.id}/quotas/#{quota.id}", :params => gen_request(:delete) end.to change(TenantQuota, :count).by(-1) expect(response).to have_http_status(:ok) @@ -143,7 +143,7 @@ ] expect do - post "/api/tenants/#{tenant.id}/quotas/", gen_request(:delete, options) + post "/api/tenants/#{tenant.id}/quotas/", :params => gen_request(:delete, options) end.to change(TenantQuota, :count).by(-2) expect(response).to have_http_status(:ok) @@ -155,7 +155,7 @@ api_basic_authorize expect do - post "/api/tenants/#{tenant.id}/quotas/", :name => :cpu_allocated, :value => 1 + post "/api/tenants/#{tenant.id}/quotas/", :params => { :name => :cpu_allocated, :value => 1 } end.not_to change(TenantQuota, :count) expect(response).to have_http_status(:forbidden) @@ -168,7 +168,7 @@ options = {:value => 5} - post "/api/tenants/#{tenant.id}/quotas/#{quota.id}", gen_request(:edit, options) + post "/api/tenants/#{tenant.id}/quotas/#{quota.id}", :params => gen_request(:edit, options) expect(response).to have_http_status(:forbidden) quota.reload @@ -182,7 +182,7 @@ options = {:value => 5} - put "/api/tenants/#{tenant.id}/quotas/#{quota.id}", options + put "/api/tenants/#{tenant.id}/quotas/#{quota.id}", :params => options expect(response).to have_http_status(:forbidden) quota.reload @@ -200,7 +200,7 @@ {"href" => "/api/tenants/#{tenant.id}/quotas/#{quota_2.id}"} ] - post "/api/tenants/#{tenant.id}/quotas/", gen_request(:edit, options) + post "/api/tenants/#{tenant.id}/quotas/", :params => gen_request(:edit, options) expect(response).to have_http_status(:forbidden) expect(quota_1.reload.value).to eq(1) @@ -213,7 +213,7 @@ quota = FactoryGirl.create(:tenant_quota, :tenant_id => tenant.id, :name => :cpu_allocated, :value => 1) expect do - post "/api/tenants/#{tenant.id}/quotas/#{quota.id}", gen_request(:delete) + post "/api/tenants/#{tenant.id}/quotas/#{quota.id}", :params => gen_request(:delete) end.not_to change(TenantQuota, :count) expect(response).to have_http_status(:forbidden) @@ -243,7 +243,7 @@ ] expect do - post "/api/tenants/#{tenant.id}/quotas/", gen_request(:delete, options) + post "/api/tenants/#{tenant.id}/quotas/", :params => gen_request(:delete, options) end.not_to change(TenantQuota, :count) expect(response).to have_http_status(:forbidden) diff --git a/spec/requests/tenants_spec.rb b/spec/requests/tenants_spec.rb index cdcde61463..1dc99e75a1 100644 --- a/spec/requests/tenants_spec.rb +++ b/spec/requests/tenants_spec.rb @@ -46,7 +46,7 @@ api_basic_authorize collection_action_identifier(:tenants, :create) expect do - post api_tenants_url, :parent => {:id => root_tenant.id} + post api_tenants_url, :params => { :parent => {:id => root_tenant.id} } end.to change(Tenant, :count).by(1) expect(response).to have_http_status(:ok) @@ -57,7 +57,7 @@ invalid_tenant = FactoryGirl.create(:tenant, :parent => root_tenant).destroy expect do - post api_tenants_url, :parent => {:id => invalid_tenant.id} + post api_tenants_url, :params => { :parent => {:id => invalid_tenant.id} } end.not_to change(Tenant, :count) expect(response).to have_http_status(:not_found) @@ -73,7 +73,7 @@ ) options = {:name => "New Tenant name", :description => "New Tenant description"} - post api_tenant_url(nil, tenant), gen_request(:edit, options) + post api_tenant_url(nil, tenant), :params => gen_request(:edit, options) expect(response).to have_http_status(:ok) tenant.reload @@ -91,7 +91,7 @@ ) options = {:name => "New Tenant name", :description => "New Tenant description"} - put api_tenant_url(nil, tenant), options + put api_tenant_url(nil, tenant), :params => options expect(response).to have_http_status(:ok) tenant.reload @@ -136,7 +136,7 @@ {"href" => api_tenant_url(nil, tenant_2), "name" => "Updated Test Tenant 2"} ] - post api_tenants_url, gen_request(:edit, options) + post api_tenants_url, :params => gen_request(:edit, options) expect(response).to have_http_status(:ok) expect_results_to_match_hash( @@ -152,7 +152,7 @@ api_basic_authorize action_identifier(:tenants, :delete) tenant = FactoryGirl.create(:tenant, :parent => root_tenant) - expect { post api_tenant_url(nil, tenant), gen_request(:delete) }.to change(Tenant, :count).by(-1) + expect { post api_tenant_url(nil, tenant), :params => gen_request(:delete) }.to change(Tenant, :count).by(-1) expect(response).to have_http_status(:ok) end @@ -174,7 +174,7 @@ ] expect do - post api_tenants_url, gen_request(:delete, options) + post api_tenants_url, :params => gen_request(:delete, options) end.to change(Tenant, :count).by(-2) expect(response).to have_http_status(:ok) end @@ -185,7 +185,7 @@ api_basic_authorize expect do - post api_tenants_url, :parent => {:id => root_tenant.id} + post api_tenants_url, :params => { :parent => {:id => root_tenant.id} } end.not_to change(Tenant, :count) expect(response).to have_http_status(:forbidden) @@ -201,7 +201,7 @@ ) options = {:name => "New Tenant name", :description => "New Tenant description"} - post api_tenant_url(nil, tenant), gen_request(:edit, options) + post api_tenant_url(nil, tenant), :params => gen_request(:edit, options) expect(response).to have_http_status(:forbidden) tenant.reload @@ -219,7 +219,7 @@ ) options = {:name => "New Tenant name", :description => "New Tenant description"} - put api_tenant_url(nil, tenant), options + put api_tenant_url(nil, tenant), :params => options expect(response).to have_http_status(:forbidden) tenant.reload @@ -244,7 +244,7 @@ {"href" => api_tenant_url(nil, tenant_2), "name" => "Updated Test Tenant 2"} ] - post api_tenants_url, gen_request(:edit, options) + post api_tenants_url, :params => gen_request(:edit, options) expect(response).to have_http_status(:forbidden) expect(tenant_1.reload.name).to eq("Test Tenant 1") @@ -255,7 +255,7 @@ api_basic_authorize tenant = FactoryGirl.create(:tenant, :parent => root_tenant) - expect { post api_tenant_url(nil, tenant), gen_request(:delete) }.not_to change(Tenant, :count) + expect { post api_tenant_url(nil, tenant), :params => gen_request(:delete) }.not_to change(Tenant, :count) expect(response).to have_http_status(:forbidden) end @@ -277,7 +277,7 @@ ] expect do - post api_tenants_url, gen_request(:delete, options) + post api_tenants_url, :params => gen_request(:delete, options) end.not_to change(Tenant, :count) expect(response).to have_http_status(:forbidden) end diff --git a/spec/requests/users_spec.rb b/spec/requests/users_spec.rb index 779c929f11..2569a5881b 100644 --- a/spec/requests/users_spec.rb +++ b/spec/requests/users_spec.rb @@ -30,7 +30,7 @@ api_basic_authorize action_identifier(:users, :edit) expect do - post api_user_url(nil, @user), gen_request(:edit, :password => "new_password") + post api_user_url(nil, @user), :params => gen_request(:edit, :password => "new_password") end.to change { @user.reload.password_digest } expect(response).to have_http_status(:ok) @@ -41,7 +41,7 @@ user = FactoryGirl.create(:user) expect do - post api_user_url(nil, user), gen_request(:edit, :password => "new_password") + post api_user_url(nil, user), :params => gen_request(:edit, :password => "new_password") end.to change { user.reload.password_digest } expect(response).to have_http_status(:ok) @@ -53,7 +53,7 @@ api_basic_authorize expect do - post api_user_url(nil, @user), gen_request(:edit, :password => "new_password") + post api_user_url(nil, @user), :params => gen_request(:edit, :password => "new_password") end.to change { @user.reload.password_digest } expect(response).to have_http_status(:ok) @@ -63,7 +63,7 @@ api_basic_authorize action_identifier(:users, :edit) expect do - post api_user_url(nil, @user), gen_request(:edit, :email => "tom@cartoons.com") + post api_user_url(nil, @user), :params => gen_request(:edit, :email => "tom@cartoons.com") end.to change { @user.reload.email } expect(response).to have_http_status(:ok) @@ -73,7 +73,7 @@ api_basic_authorize action_identifier(:users, :edit) expect do - post api_user_url(nil, @user), gen_request(:edit, :settings => {:cartoon => {:tom_jerry => 'y'}}) + post api_user_url(nil, @user), :params => gen_request(:edit, :settings => {:cartoon => {:tom_jerry => 'y'}}) end.to change { @user.reload.settings } expect(response).to have_http_status(:ok) @@ -83,7 +83,7 @@ api_basic_authorize expect do - post api_user_url(nil, @user), gen_request(:edit, :name => "updated_name") + post api_user_url(nil, @user), :params => gen_request(:edit, :name => "updated_name") end.not_to change { @user.reload.name } expect(response).to have_http_status(:bad_request) @@ -94,7 +94,7 @@ user = FactoryGirl.create(:user) expect do - post api_user_url(nil, user), gen_request(:edit, :password => "new_password") + post api_user_url(nil, user), :params => gen_request(:edit, :password => "new_password") end.not_to change { user.reload.password_digest } expect(response).to have_http_status(:forbidden) @@ -105,7 +105,7 @@ user = FactoryGirl.create(:user, :settings => {:locale => "en"}) expect do - post api_user_url(nil, user), gen_request(:edit, :settings => {:locale => "ja"}) + post api_user_url(nil, user), :params => gen_request(:edit, :settings => {:locale => "ja"}) end.not_to change { user.reload.settings } expect(response).to have_http_status(:forbidden) @@ -116,7 +116,7 @@ it "rejects creation without appropriate role" do api_basic_authorize - post(api_users_url, sample_user1) + post(api_users_url, :params => sample_user1) expect(response).to have_http_status(:forbidden) end @@ -124,7 +124,7 @@ it "rejects user creation with id specified" do api_basic_authorize collection_action_identifier(:users, :create) - post(api_users_url, "userid" => "userid1", "id" => 100) + post(api_users_url, :params => { "userid" => "userid1", "id" => 100 }) expect_bad_request(/id or href should not be specified/i) end @@ -132,7 +132,7 @@ it "rejects user creation with invalid group specified" do api_basic_authorize collection_action_identifier(:users, :create) - post(api_users_url, sample_user2.merge("group" => {"id" => 999_999})) + post(api_users_url, :params => sample_user2.merge("group" => {"id" => 999_999})) expect(response).to have_http_status(:not_found) end @@ -140,7 +140,7 @@ it "rejects user creation with missing attribute" do api_basic_authorize collection_action_identifier(:users, :create) - post(api_users_url, sample_user2.except(:userid)) + post(api_users_url, :params => sample_user2.except(:userid)) expect_bad_request(/Missing attribute/i) end @@ -148,7 +148,7 @@ it "supports single user creation" do api_basic_authorize collection_action_identifier(:users, :create) - post(api_users_url, sample_user1) + post(api_users_url, :params => sample_user1) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_attributes) @@ -160,7 +160,7 @@ it "supports single user creation via action" do api_basic_authorize collection_action_identifier(:users, :create) - post(api_users_url, gen_request(:create, sample_user1)) + post(api_users_url, :params => gen_request(:create, sample_user1)) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_attributes) @@ -172,7 +172,7 @@ it "supports multiple user creation" do api_basic_authorize collection_action_identifier(:users, :create) - post(api_users_url, gen_request(:create, [sample_user1, sample_user2])) + post(api_users_url, :params => gen_request(:create, [sample_user1, sample_user2])) expect(response).to have_http_status(:ok) expect_result_resources_to_include_keys("results", expected_attributes) @@ -201,7 +201,7 @@ ] }] } - post(api_users_url, request) + post(api_users_url, :params => request) expect(response).to have_http_status(:ok) expect(user1.reload.miq_groups).to match_array([group2, group3]) @@ -210,7 +210,7 @@ it "rejects user edits without appropriate role" do api_basic_authorize - post(api_users_url, gen_request(:edit, "name" => "updated name", "href" => api_user_url(nil, user1))) + post(api_users_url, :params => gen_request(:edit, "name" => "updated name", "href" => api_user_url(nil, user1))) expect(response).to have_http_status(:forbidden) end @@ -218,7 +218,7 @@ it "rejects user edits for invalid resources" do api_basic_authorize collection_action_identifier(:users, :edit) - post(api_user_url(nil, 999_999), gen_request(:edit, "name" => "updated name")) + post(api_user_url(nil, 999_999), :params => gen_request(:edit, "name" => "updated name")) expect(response).to have_http_status(:not_found) end @@ -226,7 +226,7 @@ it "supports single user edit" do api_basic_authorize collection_action_identifier(:users, :edit) - post(api_user_url(nil, user1), gen_request(:edit, "name" => "updated name")) + post(api_user_url(nil, user1), :params => gen_request(:edit, "name" => "updated name")) expect_single_resource_query("id" => user1.compressed_id, "name" => "updated name") expect(user1.reload.name).to eq("updated name") @@ -236,7 +236,7 @@ api_basic_authorize collection_action_identifier(:users, :edit) user1.miq_groups << group2 - post(api_user_url(nil, user1.id), gen_request(:edit, "current_group" => { "href" => api_group_url(nil, group2.compressed_id) })) + post(api_user_url(nil, user1.id), :params => gen_request(:edit, "current_group" => { "href" => api_group_url(nil, group2.compressed_id) })) expect(response).to have_http_status(:ok) expect(response.parsed_body["current_group_id"]).to eq(group2.compressed_id) @@ -245,9 +245,9 @@ it "supports single user edit of other attributes including group change" do api_basic_authorize collection_action_identifier(:users, :edit) - post(api_user_url(nil, user1), gen_request(:edit, - "email" => "user1@email.com", - "group" => {"description" => group2.description})) + post(api_user_url(nil, user1), :params => gen_request(:edit, + "email" => "user1@email.com", + "group" => {"description" => group2.description})) expect_single_resource_query("id" => user1.compressed_id, "email" => "user1@email.com", "current_group_id" => group2.compressed_id) expect(user1.reload.email).to eq("user1@email.com") @@ -257,9 +257,9 @@ it "supports multiple user edits" do api_basic_authorize collection_action_identifier(:users, :edit) - post(api_users_url, gen_request(:edit, - [{"href" => api_user_url(nil, user1), "first_name" => "John"}, - {"href" => api_user_url(nil, user2), "first_name" => "Jane"}])) + post(api_users_url, :params => gen_request(:edit, + [{"href" => api_user_url(nil, user1), "first_name" => "John"}, + {"href" => api_user_url(nil, user2), "first_name" => "Jane"}])) expect_results_to_match_hash("results", [{"id" => user1.compressed_id, "first_name" => "John"}, @@ -274,7 +274,7 @@ it "rejects user deletion, by post action, without appropriate role" do api_basic_authorize - post(api_users_url, gen_request(:delete, "href" => api_user_url(nil, 100))) + post(api_users_url, :params => gen_request(:delete, "href" => api_user_url(nil, 100))) expect(response).to have_http_status(:forbidden) end @@ -298,7 +298,7 @@ it "rejects user delete of requesting user via action" do api_basic_authorize collection_action_identifier(:users, :delete) - post(api_users_url, gen_request(:delete, "href" => api_user_url(nil, @user))) + post(api_users_url, :params => gen_request(:delete, "href" => api_user_url(nil, @user))) expect_bad_request("Cannot delete user of current request") end @@ -327,7 +327,7 @@ user1_id = user1.id user1_url = api_user_url(nil, user1_id) - post(user1_url, gen_request(:delete)) + post(user1_url, :params => gen_request(:delete)) expect_single_action_result(:success => true, :message => "deleting", :href => api_user_url(nil, user1.compressed_id)) expect(User.exists?(user1_id)).to be_falsey @@ -339,7 +339,7 @@ user1_id, user2_id = user1.id, user2.id user1_url, user2_url = api_user_url(nil, user1_id), api_user_url(nil, user2_id) - post(api_users_url, gen_request(:delete, [{"href" => user1_url}, {"href" => user2_url}])) + post(api_users_url, :params => gen_request(:delete, [{"href" => user1_url}, {"href" => user2_url}])) expect_multiple_action_result(2) expect_result_resources_to_include_hrefs("results", [api_user_url(nil, user1.compressed_id), api_user_url(nil, user2.compressed_id)]) @@ -366,7 +366,7 @@ FactoryGirl.create(:classification_department_with_tags) api_basic_authorize(subcollection_action_identifier(:users, :tags, :assign)) - post(api_user_tags_url(nil, user), :action => "assign", :category => "department", :name => "finance") + post(api_user_tags_url(nil, user), :params => { :action => "assign", :category => "department", :name => "finance" }) expected = { "results" => [ @@ -388,7 +388,7 @@ Classification.classify(user, "department", "finance") api_basic_authorize(subcollection_action_identifier(:users, :tags, :unassign)) - post(api_user_tags_url(nil, user), :action => "unassign", :category => "department", :name => "finance") + post(api_user_tags_url(nil, user), :params => { :action => "unassign", :category => "department", :name => "finance" }) expected = { "results" => [ diff --git a/spec/requests/vms_spec.rb b/spec/requests/vms_spec.rb index 105f5055d0..37eae90397 100644 --- a/spec/requests/vms_spec.rb +++ b/spec/requests/vms_spec.rb @@ -39,7 +39,7 @@ def update_raw_power_state(state, *vms) it 'cannot edit a VM without an appropriate role' do api_basic_authorize - post(api_vm_url(nil, vm), :action => 'edit') + post(api_vm_url(nil, vm), :params => { :action => 'edit' }) expect(response).to have_http_status(:forbidden) end @@ -52,12 +52,14 @@ def update_raw_power_state(state, *vms) post( api_vm_url(nil, vm), - :action => 'edit', - :description => 'bar', - :child_resources => children, - :custom_1 => 'foobar', - :custom_9 => 'fizzbuzz', - :parent_resource => { :href => api_vm_url(nil, vm_openstack2) } + :params => { + :action => 'edit', + :description => 'bar', + :child_resources => children, + :custom_1 => 'foobar', + :custom_9 => 'fizzbuzz', + :parent_resource => { :href => api_vm_url(nil, vm_openstack2) } + } ) expected = { @@ -74,7 +76,7 @@ def update_raw_power_state(state, *vms) it 'only allows edit of custom_1, description, parent, and children' do api_basic_authorize collection_action_identifier(:vms, :edit) - post(api_vm_url(nil, vm), :action => 'edit', :name => 'foo', :autostart => true, :power_state => 'off') + post(api_vm_url(nil, vm), :params => { :action => 'edit', :name => 'foo', :autostart => true, :power_state => 'off' }) expected = { 'error' => a_hash_including( @@ -89,7 +91,7 @@ def update_raw_power_state(state, *vms) it 'can edit multiple vms' do api_basic_authorize collection_action_identifier(:vms, :edit) - post(api_vms_url, :action => 'edit', :resources => [{ :id => vm.id, :description => 'foo' }, { :id => vm_openstack.id, :description => 'bar'}]) + post(api_vms_url, :params => { :action => 'edit', :resources => [{ :id => vm.id, :description => 'foo' }, { :id => vm_openstack.id, :description => 'bar'}] }) expected = { 'results' => [ @@ -104,7 +106,7 @@ def update_raw_power_state(state, *vms) it 'requires a valid child/parent relationship ' do api_basic_authorize collection_action_identifier(:vms, :edit) - post(api_vm_url(nil, vm), :action => 'edit', :parent_resource => { :href => api_user_url(nil, 10) }) + post(api_vm_url(nil, vm), :params => { :action => 'edit', :parent_resource => { :href => api_user_url(nil, 10) } }) expected = { 'error' => a_hash_including( @@ -167,7 +169,7 @@ def update_raw_power_state(state, *vms) acct1 acct2 - get vm_url, :expand => "accounts" + get vm_url, :params => { :expand => "accounts" } expect_single_resource_query("guid" => vm_guid) expect_result_resources_to_include_hrefs("accounts", @@ -226,7 +228,7 @@ def update_raw_power_state(state, *vms) sw1 sw2 - get api_vm_url(nil, vm), :expand => "software" + get api_vm_url(nil, vm), :params => { :expand => "software" } expect_single_resource_query("guid" => vm_guid) expect_result_resources_to_include_hrefs("software", @@ -239,7 +241,7 @@ def update_raw_power_state(state, *vms) it "starts an invalid vm" do api_basic_authorize action_identifier(:vms, :start) - post(invalid_vm_url, gen_request(:start)) + post(invalid_vm_url, :params => gen_request(:start)) expect(response).to have_http_status(:not_found) end @@ -247,7 +249,7 @@ def update_raw_power_state(state, *vms) it "starts an invalid vm without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:start)) + post(invalid_vm_url, :params => gen_request(:start)) expect(response).to have_http_status(:forbidden) end @@ -255,7 +257,7 @@ def update_raw_power_state(state, *vms) it "starts a powered on vm" do api_basic_authorize action_identifier(:vms, :start) - post(vm_url, gen_request(:start)) + post(vm_url, :params => gen_request(:start)) expect_single_action_result(:success => false, :message => "is powered on", :href => api_vm_url(nil, vm.compressed_id)) end @@ -264,7 +266,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :start) update_raw_power_state("poweredOff", vm) - post(vm_url, gen_request(:start)) + post(vm_url, :params => gen_request(:start)) expect_single_action_result(:success => true, :message => "starting", :href => api_vm_url(nil, vm.compressed_id), :task => true) end @@ -273,7 +275,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :start) update_raw_power_state("poweredOff", vm) - post(vm_url, gen_request(:start)) + post(vm_url, :params => gen_request(:start)) expect_single_action_result(:success => true, :message => "starting", :href => api_vm_url(nil, vm.compressed_id), :task => true) expect(MiqQueue.where(:class_name => vm.class.name, @@ -286,7 +288,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :start) update_raw_power_state("poweredOff", vm1, vm2) - post(api_vms_url, gen_request(:start, nil, vm1_url, vm2_url)) + post(api_vms_url, :params => gen_request(:start, nil, vm1_url, vm2_url)) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_vm_url(nil, vm1.compressed_id), api_vm_url(nil, vm2.compressed_id)]) @@ -297,7 +299,7 @@ def update_raw_power_state(state, *vms) it "stops an invalid vm" do api_basic_authorize action_identifier(:vms, :stop) - post(invalid_vm_url, gen_request(:stop)) + post(invalid_vm_url, :params => gen_request(:stop)) expect(response).to have_http_status(:not_found) end @@ -305,7 +307,7 @@ def update_raw_power_state(state, *vms) it "stops an invalid vm without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:stop)) + post(invalid_vm_url, :params => gen_request(:stop)) expect(response).to have_http_status(:forbidden) end @@ -314,7 +316,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :stop) update_raw_power_state("poweredOff", vm) - post(vm_url, gen_request(:stop)) + post(vm_url, :params => gen_request(:stop)) expect_single_action_result(:success => false, :message => "is not powered on", :href => api_vm_url(nil, vm.compressed_id)) end @@ -322,7 +324,7 @@ def update_raw_power_state(state, *vms) it "stops a vm" do api_basic_authorize action_identifier(:vms, :stop) - post(vm_url, gen_request(:stop)) + post(vm_url, :params => gen_request(:stop)) expect_single_action_result(:success => true, :message => "stopping", :href => api_vm_url(nil, vm.compressed_id), :task => true) end @@ -330,7 +332,7 @@ def update_raw_power_state(state, *vms) it "stops multiple vms" do api_basic_authorize action_identifier(:vms, :stop) - post(api_vms_url, gen_request(:stop, nil, vm1_url, vm2_url)) + post(api_vms_url, :params => gen_request(:stop, nil, vm1_url, vm2_url)) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_vm_url(nil, vm1.compressed_id), api_vm_url(nil, vm2.compressed_id)]) @@ -341,7 +343,7 @@ def update_raw_power_state(state, *vms) it "suspends an invalid vm" do api_basic_authorize action_identifier(:vms, :suspend) - post(invalid_vm_url, gen_request(:suspend)) + post(invalid_vm_url, :params => gen_request(:suspend)) expect(response).to have_http_status(:not_found) end @@ -349,7 +351,7 @@ def update_raw_power_state(state, *vms) it "suspends an invalid vm without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:suspend)) + post(invalid_vm_url, :params => gen_request(:suspend)) expect(response).to have_http_status(:forbidden) end @@ -358,7 +360,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :suspend) update_raw_power_state("poweredOff", vm) - post(vm_url, gen_request(:suspend)) + post(vm_url, :params => gen_request(:suspend)) expect_single_action_result(:success => false, :message => "is not powered on", :href => api_vm_url(nil, vm.compressed_id)) end @@ -367,7 +369,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :suspend) update_raw_power_state("suspended", vm) - post(vm_url, gen_request(:suspend)) + post(vm_url, :params => gen_request(:suspend)) expect_single_action_result(:success => false, :message => "is not powered on", :href => api_vm_url(nil, vm.compressed_id)) end @@ -375,7 +377,7 @@ def update_raw_power_state(state, *vms) it "suspends a vm" do api_basic_authorize action_identifier(:vms, :suspend) - post(vm_url, gen_request(:suspend)) + post(vm_url, :params => gen_request(:suspend)) expect_single_action_result(:success => true, :message => "suspending", :href => api_vm_url(nil, vm.compressed_id), :task => true) end @@ -383,7 +385,7 @@ def update_raw_power_state(state, *vms) it "suspends multiple vms" do api_basic_authorize action_identifier(:vms, :suspend) - post(api_vms_url, gen_request(:suspend, nil, vm1_url, vm2_url)) + post(api_vms_url, :params => gen_request(:suspend, nil, vm1_url, vm2_url)) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_vm_url(nil, vm1.compressed_id), api_vm_url(nil, vm2.compressed_id)]) @@ -394,7 +396,7 @@ def update_raw_power_state(state, *vms) it "pauses an invalid vm" do api_basic_authorize action_identifier(:vms, :pause) - post(invalid_vm_url, gen_request(:pause)) + post(invalid_vm_url, :params => gen_request(:pause)) expect(response).to have_http_status(:not_found) end @@ -402,7 +404,7 @@ def update_raw_power_state(state, *vms) it "pauses an invalid vm without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:pause)) + post(invalid_vm_url, :params => gen_request(:pause)) expect(response).to have_http_status(:forbidden) end @@ -411,7 +413,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :pause) update_raw_power_state("off", vm) - post(vm_url, gen_request(:pause)) + post(vm_url, :params => gen_request(:pause)) expect_single_action_result(:success => false, :message => "is not powered on", :href => api_vm_url(nil, vm.compressed_id)) end @@ -420,7 +422,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :pause) update_raw_power_state("paused", vm) - post(vm_url, gen_request(:pause)) + post(vm_url, :params => gen_request(:pause)) expect_single_action_result(:success => false, :message => "is not powered on", :href => api_vm_url(nil, vm.compressed_id)) end @@ -428,7 +430,7 @@ def update_raw_power_state(state, *vms) it "pauses a vm" do api_basic_authorize action_identifier(:vms, :pause) - post(vm_url, gen_request(:pause)) + post(vm_url, :params => gen_request(:pause)) expect_single_action_result(:success => true, :message => "pausing", :href => api_vm_url(nil, vm.compressed_id), :task => true) end @@ -436,7 +438,7 @@ def update_raw_power_state(state, *vms) it "pauses multiple vms" do api_basic_authorize action_identifier(:vms, :pause) - post(api_vms_url, gen_request(:pause, nil, vm1_url, vm2_url)) + post(api_vms_url, :params => gen_request(:pause, nil, vm1_url, vm2_url)) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_vm_url(nil, vm1.compressed_id), api_vm_url(nil, vm2.compressed_id)]) @@ -447,7 +449,7 @@ def update_raw_power_state(state, *vms) it "shelves an invalid vm" do api_basic_authorize action_identifier(:vms, :shelve) - post(invalid_vm_url, gen_request(:shelve)) + post(invalid_vm_url, :params => gen_request(:shelve)) expect(response).to have_http_status(:not_found) end @@ -455,7 +457,7 @@ def update_raw_power_state(state, *vms) it "shelves an invalid vm without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:shelve)) + post(invalid_vm_url, :params => gen_request(:shelve)) expect(response).to have_http_status(:forbidden) end @@ -464,7 +466,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :shelve) update_raw_power_state("SHUTOFF", vm_openstack) - post(vm_openstack_url, gen_request(:shelve)) + post(vm_openstack_url, :params => gen_request(:shelve)) expect_single_action_result(:success => true, :message => 'shelving', :href => api_vm_url(nil, vm_openstack.compressed_id)) end @@ -473,7 +475,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :shelve) update_raw_power_state("SUSPENDED", vm_openstack) - post(vm_openstack_url, gen_request(:shelve)) + post(vm_openstack_url, :params => gen_request(:shelve)) expect_single_action_result(:success => true, :message => 'shelving', :href => api_vm_url(nil, vm_openstack.compressed_id)) end @@ -482,7 +484,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :shelve) update_raw_power_state("PAUSED", vm_openstack) - post(vm_openstack_url, gen_request(:shelve)) + post(vm_openstack_url, :params => gen_request(:shelve)) expect_single_action_result(:success => true, :message => 'shelving', :href => api_vm_url(nil, vm_openstack.compressed_id)) end @@ -491,7 +493,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :shelve) update_raw_power_state("SHELVED", vm_openstack) - post(vm_openstack_url, gen_request(:shelve)) + post(vm_openstack_url, :params => gen_request(:shelve)) expect_single_action_result(:success => false, :message => "The VM can't be shelved, current state has to be powered on, off, suspended or paused", @@ -501,7 +503,7 @@ def update_raw_power_state(state, *vms) it "shelves a vm" do api_basic_authorize action_identifier(:vms, :shelve) - post(vm_openstack_url, gen_request(:shelve)) + post(vm_openstack_url, :params => gen_request(:shelve)) expect_single_action_result(:success => true, :message => "shelving", :href => api_vm_url(nil, vm_openstack.compressed_id), :task => true) end @@ -509,7 +511,7 @@ def update_raw_power_state(state, *vms) it "shelve for a VMWare vm is not supported" do api_basic_authorize action_identifier(:vms, :shelve) - post(vm_url, gen_request(:shelve)) + post(vm_url, :params => gen_request(:shelve)) expect_single_action_result(:success => false, :message => "Shelve Operation is not available for Vmware VM.", @@ -520,7 +522,7 @@ def update_raw_power_state(state, *vms) it "shelves multiple vms" do api_basic_authorize action_identifier(:vms, :shelve) - post(api_vms_url, gen_request(:shelve, nil, vm_openstack1_url, vm_openstack2_url)) + post(api_vms_url, :params => gen_request(:shelve, nil, vm_openstack1_url, vm_openstack2_url)) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_vm_url(nil, vm_openstack1.compressed_id), api_vm_url(nil, vm_openstack2.compressed_id)]) @@ -531,7 +533,7 @@ def update_raw_power_state(state, *vms) it "shelve_offloads an invalid vm" do api_basic_authorize action_identifier(:vms, :shelve_offload) - post(invalid_vm_url, gen_request(:shelve_offload)) + post(invalid_vm_url, :params => gen_request(:shelve_offload)) expect(response).to have_http_status(:not_found) end @@ -539,7 +541,7 @@ def update_raw_power_state(state, *vms) it "shelve_offloads an invalid vm without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:shelve_offload)) + post(invalid_vm_url, :params => gen_request(:shelve_offload)) expect(response).to have_http_status(:forbidden) end @@ -547,7 +549,7 @@ def update_raw_power_state(state, *vms) it "shelve_offloads a active vm" do api_basic_authorize action_identifier(:vms, :shelve_offload) - post(vm_openstack_url, gen_request(:shelve_offload)) + post(vm_openstack_url, :params => gen_request(:shelve_offload)) expect_single_action_result(:success => false, :message => "The VM can't be shelved offload, current state has to be shelved", @@ -558,7 +560,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :shelve_offload) update_raw_power_state("SHUTOFF", vm_openstack) - post(vm_openstack_url, gen_request(:shelve_offload)) + post(vm_openstack_url, :params => gen_request(:shelve_offload)) expect_single_action_result(:success => false, :message => "The VM can't be shelved offload, current state has to be shelved", @@ -569,7 +571,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :shelve_offload) update_raw_power_state("SUSPENDED", vm_openstack) - post(vm_openstack_url, gen_request(:shelve_offload)) + post(vm_openstack_url, :params => gen_request(:shelve_offload)) expect_single_action_result(:success => false, :message => "The VM can't be shelved offload, current state has to be shelved", @@ -580,7 +582,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :shelve_offload) update_raw_power_state("PAUSED", vm_openstack) - post(vm_openstack_url, gen_request(:shelve_offload)) + post(vm_openstack_url, :params => gen_request(:shelve_offload)) expect_single_action_result(:success => false, :message => "The VM can't be shelved offload, current state has to be shelved", @@ -591,7 +593,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :shelve_offload) update_raw_power_state("SHELVED_OFFLOADED", vm_openstack) - post(vm_openstack_url, gen_request(:shelve_offload)) + post(vm_openstack_url, :params => gen_request(:shelve_offload)) expect_single_action_result(:success => false, :message => "The VM can't be shelved offload, current state has to be shelved", @@ -602,7 +604,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :shelve_offload) update_raw_power_state("SHELVED", vm_openstack) - post(vm_openstack_url, gen_request(:shelve_offload)) + post(vm_openstack_url, :params => gen_request(:shelve_offload)) expect_single_action_result(:success => true, :message => "shelve-offloading", @@ -612,7 +614,7 @@ def update_raw_power_state(state, *vms) it "shelve_offload for a VMWare vm is not supported" do api_basic_authorize action_identifier(:vms, :shelve_offload) - post(vm_url, gen_request(:shelve_offload)) + post(vm_url, :params => gen_request(:shelve_offload)) expect_single_action_result(:success => false, :message => "Shelve Offload Operation is not available for Vmware VM.", @@ -626,7 +628,7 @@ def update_raw_power_state(state, *vms) update_raw_power_state("SHELVED", vm_openstack1) update_raw_power_state("SHELVED", vm_openstack2) - post(api_vms_url, gen_request(:shelve_offload, nil, vm_openstack1_url, vm_openstack2_url)) + post(api_vms_url, :params => gen_request(:shelve_offload, nil, vm_openstack1_url, vm_openstack2_url)) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_vm_url(nil, vm_openstack1.compressed_id), api_vm_url(nil, vm_openstack2.compressed_id)]) @@ -637,7 +639,7 @@ def update_raw_power_state(state, *vms) it "deletes an invalid vm" do api_basic_authorize action_identifier(:vms, :delete) - post(invalid_vm_url, gen_request(:delete)) + post(invalid_vm_url, :params => gen_request(:delete)) expect(response).to have_http_status(:not_found) end @@ -645,7 +647,7 @@ def update_raw_power_state(state, *vms) it "deletes a vm via a resource POST without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:delete)) + post(invalid_vm_url, :params => gen_request(:delete)) expect(response).to have_http_status(:forbidden) end @@ -661,7 +663,7 @@ def update_raw_power_state(state, *vms) it "deletes a vm via a resource POST" do api_basic_authorize action_identifier(:vms, :delete) - post(vm_url, gen_request(:delete)) + post(vm_url, :params => gen_request(:delete)) expect_single_action_result(:success => true, :message => "deleting", :href => api_vm_url(nil, vm.compressed_id), :task => true) end @@ -677,7 +679,7 @@ def update_raw_power_state(state, *vms) it "deletes multiple vms" do api_basic_authorize action_identifier(:vms, :delete) - post(api_vms_url, gen_request(:delete, nil, vm1_url, vm2_url)) + post(api_vms_url, :params => gen_request(:delete, nil, vm1_url, vm2_url)) expect_multiple_action_result(2, :task => true) end @@ -687,7 +689,7 @@ def update_raw_power_state(state, *vms) it "set_owner to an invalid vm" do api_basic_authorize action_identifier(:vms, :set_owner) - post(invalid_vm_url, gen_request(:set_owner, "owner" => "admin")) + post(invalid_vm_url, :params => gen_request(:set_owner, "owner" => "admin")) expect(response).to have_http_status(:not_found) end @@ -695,7 +697,7 @@ def update_raw_power_state(state, *vms) it "set_owner without appropriate action role" do api_basic_authorize - post(vm_url, gen_request(:set_owner, "owner" => "admin")) + post(vm_url, :params => gen_request(:set_owner, "owner" => "admin")) expect(response).to have_http_status(:forbidden) end @@ -703,7 +705,7 @@ def update_raw_power_state(state, *vms) it "set_owner with missing owner" do api_basic_authorize action_identifier(:vms, :set_owner) - post(vm_url, gen_request(:set_owner)) + post(vm_url, :params => gen_request(:set_owner)) expect_bad_request("Must specify an owner") end @@ -711,7 +713,7 @@ def update_raw_power_state(state, *vms) it "set_owner with invalid owner" do api_basic_authorize action_identifier(:vms, :set_owner) - post(vm_url, gen_request(:set_owner, "owner" => "bad_user")) + post(vm_url, :params => gen_request(:set_owner, "owner" => "bad_user")) expect_single_action_result(:success => false, :message => /.*/, :href => api_vm_url(nil, vm.compressed_id)) end @@ -719,7 +721,7 @@ def update_raw_power_state(state, *vms) it "set_owner to a vm" do api_basic_authorize action_identifier(:vms, :set_owner) - post(vm_url, gen_request(:set_owner, "owner" => api_config(:user))) + post(vm_url, :params => gen_request(:set_owner, "owner" => api_config(:user))) expect_single_action_result(:success => true, :message => "setting owner", :href => api_vm_url(nil, vm.compressed_id)) expect(vm.reload.evm_owner).to eq(@user) @@ -728,7 +730,7 @@ def update_raw_power_state(state, *vms) it "set_owner to multiple vms" do api_basic_authorize action_identifier(:vms, :set_owner) - post(api_vms_url, gen_request(:set_owner, {"owner" => api_config(:user)}, vm1_url, vm2_url)) + post(api_vms_url, :params => gen_request(:set_owner, {"owner" => api_config(:user)}, vm1_url, vm2_url)) expect_multiple_action_result(2) expect_result_resources_to_include_hrefs("results", [api_vm_url(nil, vm1.compressed_id), api_vm_url(nil, vm2.compressed_id)]) @@ -767,7 +769,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize vm.custom_attributes = [ca1, ca2] - get api_vm_custom_attributes_url(nil, vm), :expand => "resources" + get api_vm_custom_attributes_url(nil, vm), :params => { :expand => "resources" } expect_query_result(:custom_attributes, 2) expect_result_resources_to_include_data("resources", "name" => %w(name1 name2)) @@ -777,7 +779,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :read, :resource_actions, :get) vm.custom_attributes = [ca1, ca2] - get vm_url, :expand => "custom_attributes" + get vm_url, :params => { :expand => "custom_attributes" } expect_single_resource_query("guid" => vm_guid) expect_result_resources_to_include_data("custom_attributes", "name" => %w(name1 name2)) @@ -787,7 +789,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize vm.custom_attributes = [ca1] - post(api_vm_custom_attributes_url(nil, vm), gen_request(:delete, nil, vm_url)) + post(api_vm_custom_attributes_url(nil, vm), :params => gen_request(:delete, nil, vm_url)) expect(response).to have_http_status(:forbidden) end @@ -796,7 +798,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :edit) vm.custom_attributes = [ca1] - post(api_vm_custom_attributes_url(nil, vm), gen_request(:delete, nil, ca1_url)) + post(api_vm_custom_attributes_url(nil, vm), :params => gen_request(:delete, nil, ca1_url)) expect(response).to have_http_status(:ok) expect(vm.reload.custom_attributes).to be_empty @@ -805,7 +807,7 @@ def update_raw_power_state(state, *vms) it "add custom attribute to a vm without a name" do api_basic_authorize action_identifier(:vms, :edit) - post(api_vm_custom_attributes_url(nil, vm), gen_request(:add, "value" => "value1")) + post(api_vm_custom_attributes_url(nil, vm), :params => gen_request(:add, "value" => "value1")) expect_bad_request("Must specify a name") end @@ -813,8 +815,8 @@ def update_raw_power_state(state, *vms) it "add custom attributes to a vm" do api_basic_authorize action_identifier(:vms, :edit) - post(api_vm_custom_attributes_url(nil, vm), gen_request(:add, [{"name" => "name1", "value" => "value1"}, - {"name" => "name2", "value" => "value2"}])) + post(api_vm_custom_attributes_url(nil, vm), :params => gen_request(:add, [{"name" => "name1", "value" => "value1"}, + {"name" => "name2", "value" => "value2"}])) expect(response).to have_http_status(:ok) expect_result_resources_to_include_data("results", "name" => %w(name1 name2)) @@ -826,7 +828,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :edit) vm.custom_attributes = [ca1] - post(api_vm_custom_attributes_url(nil, vm), gen_request(:edit, "name" => "name1", "value" => "value one")) + post(api_vm_custom_attributes_url(nil, vm), :params => gen_request(:edit, "name" => "name1", "value" => "value one")) expect(response).to have_http_status(:ok) expect_result_resources_to_include_data("results", "value" => ["value one"]) @@ -837,7 +839,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :edit) vm.custom_attributes = [ca1] - post(api_vm_custom_attributes_url(nil, vm), gen_request(:edit, "href" => ca1_url, "value" => "new value1")) + post(api_vm_custom_attributes_url(nil, vm), :params => gen_request(:edit, "href" => ca1_url, "value" => "new value1")) expect(response).to have_http_status(:ok) expect_result_resources_to_include_data("results", "value" => ["new value1"]) @@ -848,8 +850,8 @@ def update_raw_power_state(state, *vms) api_basic_authorize action_identifier(:vms, :edit) vm.custom_attributes = [ca1, ca2] - post(api_vm_custom_attributes_url(nil, vm), gen_request(:edit, [{"name" => "name1", "value" => "new value1"}, - {"name" => "name2", "value" => "new value2"}])) + post(api_vm_custom_attributes_url(nil, vm), :params => gen_request(:edit, [{"name" => "name1", "value" => "new value1"}, + {"name" => "name2", "value" => "new value2"}])) expect(response).to have_http_status(:ok) expect_result_resources_to_include_data("results", "value" => ["new value1", "new value2"]) @@ -867,7 +869,7 @@ def update_raw_power_state(state, *vms) it "add_lifecycle_event to an invalid vm" do api_basic_authorize action_identifier(:vms, :add_lifecycle_event) - post(invalid_vm_url, gen_request(:add_lifecycle_event, :event => "event 1")) + post(invalid_vm_url, :params => gen_request(:add_lifecycle_event, :event => "event 1")) expect(response).to have_http_status(:not_found) end @@ -875,7 +877,7 @@ def update_raw_power_state(state, *vms) it "add_lifecycle_event without appropriate action role" do api_basic_authorize - post(vm_url, gen_request(:add_lifecycle_event, :event => "event 1")) + post(vm_url, :params => gen_request(:add_lifecycle_event, :event => "event 1")) expect(response).to have_http_status(:forbidden) end @@ -883,7 +885,7 @@ def update_raw_power_state(state, *vms) it "add_lifecycle_event to a vm" do api_basic_authorize action_identifier(:vms, :add_lifecycle_event) - post(vm_url, gen_request(:add_lifecycle_event, events[0])) + post(vm_url, :params => gen_request(:add_lifecycle_event, events[0])) expect_single_action_result(:success => true, :message => /adding lifecycle event/i, :href => api_vm_url(nil, vm.compressed_id)) expect(vm.lifecycle_events.size).to eq(1) @@ -893,8 +895,8 @@ def update_raw_power_state(state, *vms) it "add_lifecycle_event to multiple vms" do api_basic_authorize action_identifier(:vms, :add_lifecycle_event) - post(api_vms_url, gen_request(:add_lifecycle_event, - events.collect { |e| {:href => vm_url}.merge(e) })) + post(api_vms_url, :params => gen_request(:add_lifecycle_event, + events.collect { |e| {:href => vm_url}.merge(e) })) expect_multiple_action_result(3) expect(vm.lifecycle_events.size).to eq(events.size) @@ -906,7 +908,7 @@ def update_raw_power_state(state, *vms) it "scans an invalid vm" do api_basic_authorize action_identifier(:vms, :scan) - post(invalid_vm_url, gen_request(:scan)) + post(invalid_vm_url, :params => gen_request(:scan)) expect(response).to have_http_status(:not_found) end @@ -914,7 +916,7 @@ def update_raw_power_state(state, *vms) it "scans an invalid Vm without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:scan)) + post(invalid_vm_url, :params => gen_request(:scan)) expect(response).to have_http_status(:forbidden) end @@ -922,7 +924,7 @@ def update_raw_power_state(state, *vms) it "scan a Vm" do api_basic_authorize action_identifier(:vms, :scan) - post(vm_url, gen_request(:scan)) + post(vm_url, :params => gen_request(:scan)) expect_single_action_result(:success => true, :message => "scanning", :href => api_vm_url(nil, vm.compressed_id), :task => true) end @@ -930,7 +932,7 @@ def update_raw_power_state(state, *vms) it "scan multiple Vms" do api_basic_authorize action_identifier(:vms, :scan) - post(api_vms_url, gen_request(:scan, nil, vm1_url, vm2_url)) + post(api_vms_url, :params => gen_request(:scan, nil, vm1_url, vm2_url)) expect_multiple_action_result(2, :task => true) expect_result_resources_to_include_hrefs("results", [api_vm_url(nil, vm1.compressed_id), api_vm_url(nil, vm2.compressed_id)]) @@ -941,7 +943,7 @@ def update_raw_power_state(state, *vms) it "to an invalid vm" do api_basic_authorize action_identifier(:vms, :add_event) - post(invalid_vm_url, gen_request(:add_event)) + post(invalid_vm_url, :params => gen_request(:add_event)) expect(response).to have_http_status(:not_found) end @@ -949,7 +951,7 @@ def update_raw_power_state(state, *vms) it "to an invalid vm without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:add_event)) + post(invalid_vm_url, :params => gen_request(:add_event)) expect(response).to have_http_status(:forbidden) end @@ -957,7 +959,7 @@ def update_raw_power_state(state, *vms) it "to a single Vm" do api_basic_authorize collection_action_identifier(:vms, :add_event) - post(vm_url, gen_request(:add_event, :event_type => "special", :event_message => "message")) + post(vm_url, :params => gen_request(:add_event, :event_type => "special", :event_message => "message")) expect_single_action_result(:success => true, :message => /adding event/i, :href => api_vm_url(nil, vm.compressed_id)) end @@ -965,10 +967,14 @@ def update_raw_power_state(state, *vms) it "to multiple Vms" do api_basic_authorize collection_action_identifier(:vms, :add_event) - post(api_vms_url, - gen_request(:add_event, - [{"href" => vm1_url, "event_type" => "etype1", "event_message" => "emsg1"}, - {"href" => vm2_url, "event_type" => "etype2", "event_message" => "emsg2"}])) + post( + api_vms_url, + :params => gen_request( + :add_event, + [{"href" => vm1_url, "event_type" => "etype1", "event_message" => "emsg1"}, + {"href" => vm2_url, "event_type" => "etype2", "event_message" => "emsg2"}] + ) + ) expected = { "results" => a_collection_containing_exactly( @@ -993,7 +999,7 @@ def update_raw_power_state(state, *vms) it "to an invalid vm" do api_basic_authorize action_identifier(:vms, :retire) - post(invalid_vm_url, gen_request(:retire)) + post(invalid_vm_url, :params => gen_request(:retire)) expect(response).to have_http_status(:not_found) end @@ -1001,7 +1007,7 @@ def update_raw_power_state(state, *vms) it "to an invalid vm without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:retire)) + post(invalid_vm_url, :params => gen_request(:retire)) expect(response).to have_http_status(:forbidden) end @@ -1009,7 +1015,7 @@ def update_raw_power_state(state, *vms) it "to a single Vm" do api_basic_authorize action_identifier(:vms, :retire) - post(vm_url, gen_request(:retire)) + post(vm_url, :params => gen_request(:retire)) expect_single_action_result(:success => true, :message => /#{vm.id}.* retiring/i, :href => api_vm_url(nil, vm.compressed_id)) end @@ -1017,7 +1023,7 @@ def update_raw_power_state(state, *vms) it "to multiple Vms" do api_basic_authorize collection_action_identifier(:vms, :retire) - post(api_vms_url, gen_request(:retire, [{"href" => vm1_url}, {"href" => vm2_url}])) + post(api_vms_url, :params => gen_request(:retire, [{"href" => vm1_url}, {"href" => vm2_url}])) expected = { "results" => a_collection_containing_exactly( @@ -1040,7 +1046,7 @@ def update_raw_power_state(state, *vms) it "in the future" do api_basic_authorize action_identifier(:vms, :retire) date = 2.weeks.from_now - post(vm_url, gen_request(:retire, :date => date.iso8601)) + post(vm_url, :params => gen_request(:retire, :date => date.iso8601)) expect_single_action_result(:success => true, :message => /#{vm.id}.* retiring/i, :href => api_vm_url(nil, vm.compressed_id)) end @@ -1050,7 +1056,7 @@ def update_raw_power_state(state, *vms) it "to an invalid vm" do api_basic_authorize action_identifier(:vms, :reset) - post(invalid_vm_url, gen_request(:reset)) + post(invalid_vm_url, :params => gen_request(:reset)) expect(response).to have_http_status(:not_found) end @@ -1058,7 +1064,7 @@ def update_raw_power_state(state, *vms) it "to an invalid vm without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:reset)) + post(invalid_vm_url, :params => gen_request(:reset)) expect(response).to have_http_status(:forbidden) end @@ -1066,7 +1072,7 @@ def update_raw_power_state(state, *vms) it "to a single Vm" do api_basic_authorize action_identifier(:vms, :reset) - post(vm_url, gen_request(:reset)) + post(vm_url, :params => gen_request(:reset)) expect_single_action_result(:success => true, :message => /#{vm.id}.* resetting/i, :href => api_vm_url(nil, vm.compressed_id)) end @@ -1074,7 +1080,7 @@ def update_raw_power_state(state, *vms) it "to multiple Vms" do api_basic_authorize collection_action_identifier(:vms, :reset) - post(api_vms_url, gen_request(:reset, [{"href" => vm1_url}, {"href" => vm2_url}])) + post(api_vms_url, :params => gen_request(:reset, [{"href" => vm1_url}, {"href" => vm2_url}])) expected = { "results" => a_collection_containing_exactly( @@ -1099,7 +1105,7 @@ def update_raw_power_state(state, *vms) it "to an invalid vm" do api_basic_authorize action_identifier(:vms, :shutdown_guest) - post(invalid_vm_url, gen_request(:shutdown_guest)) + post(invalid_vm_url, :params => gen_request(:shutdown_guest)) expect(response).to have_http_status(:not_found) end @@ -1107,7 +1113,7 @@ def update_raw_power_state(state, *vms) it "to an invalid vm without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:shutdown_guest)) + post(invalid_vm_url, :params => gen_request(:shutdown_guest)) expect(response).to have_http_status(:forbidden) end @@ -1115,7 +1121,7 @@ def update_raw_power_state(state, *vms) it "to a single Vm" do api_basic_authorize action_identifier(:vms, :shutdown_guest) - post(vm_url, gen_request(:shutdown_guest)) + post(vm_url, :params => gen_request(:shutdown_guest)) expect_single_action_result(:success => true, :message => /#{vm.id}.* shutting down/i, :href => api_vm_url(nil, vm.compressed_id)) end @@ -1123,7 +1129,7 @@ def update_raw_power_state(state, *vms) it "to multiple Vms" do api_basic_authorize collection_action_identifier(:vms, :shutdown_guest) - post(api_vms_url, gen_request(:shutdown_guest, [{"href" => vm1_url}, {"href" => vm2_url}])) + post(api_vms_url, :params => gen_request(:shutdown_guest, [{"href" => vm1_url}, {"href" => vm2_url}])) expected = { "results" => a_collection_containing_exactly( @@ -1148,7 +1154,7 @@ def update_raw_power_state(state, *vms) it "to an invalid vm" do api_basic_authorize action_identifier(:vms, :refresh) - post(invalid_vm_url, gen_request(:refresh)) + post(invalid_vm_url, :params => gen_request(:refresh)) expect(response).to have_http_status(:not_found) end @@ -1156,7 +1162,7 @@ def update_raw_power_state(state, *vms) it "to an invalid vm without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:refresh)) + post(invalid_vm_url, :params => gen_request(:refresh)) expect(response).to have_http_status(:forbidden) end @@ -1164,7 +1170,7 @@ def update_raw_power_state(state, *vms) it "to a single Vm" do api_basic_authorize action_identifier(:vms, :refresh) - post(vm_url, gen_request(:refresh)) + post(vm_url, :params => gen_request(:refresh)) expect_single_action_result(:success => true, :message => /#{vm.id}.* refreshing/i, :href => api_vm_url(nil, vm.compressed_id)) end @@ -1172,7 +1178,7 @@ def update_raw_power_state(state, *vms) it "to multiple Vms" do api_basic_authorize collection_action_identifier(:vms, :refresh) - post(api_vms_url, gen_request(:refresh, [{"href" => vm1_url}, {"href" => vm2_url}])) + post(api_vms_url, :params => gen_request(:refresh, [{"href" => vm1_url}, {"href" => vm2_url}])) expected = { "results" => a_collection_containing_exactly( @@ -1197,7 +1203,7 @@ def update_raw_power_state(state, *vms) it "to an invalid vm" do api_basic_authorize action_identifier(:vms, :reboot_guest) - post(invalid_vm_url, gen_request(:reboot_guest)) + post(invalid_vm_url, :params => gen_request(:reboot_guest)) expect(response).to have_http_status(:not_found) end @@ -1205,7 +1211,7 @@ def update_raw_power_state(state, *vms) it "to an invalid vm without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:reboot_guest)) + post(invalid_vm_url, :params => gen_request(:reboot_guest)) expect(response).to have_http_status(:forbidden) end @@ -1213,7 +1219,7 @@ def update_raw_power_state(state, *vms) it "to a single Vm" do api_basic_authorize action_identifier(:vms, :reboot_guest) - post(vm_url, gen_request(:reboot_guest)) + post(vm_url, :params => gen_request(:reboot_guest)) expect_single_action_result(:success => true, :message => /#{vm.id}.* rebooting/i, :href => api_vm_url(nil, vm.compressed_id)) end @@ -1221,7 +1227,7 @@ def update_raw_power_state(state, *vms) it "to multiple Vms" do api_basic_authorize collection_action_identifier(:vms, :reboot_guest) - post(api_vms_url, gen_request(:reboot_guest, [{"href" => vm1_url}, {"href" => vm2_url}])) + post(api_vms_url, :params => gen_request(:reboot_guest, [{"href" => vm1_url}, {"href" => vm2_url}])) expected = { "results" => a_collection_containing_exactly( @@ -1246,7 +1252,7 @@ def update_raw_power_state(state, *vms) it "to an invalid vm" do api_basic_authorize action_identifier(:vms, :request_console) - post(invalid_vm_url, gen_request(:request_console)) + post(invalid_vm_url, :params => gen_request(:request_console)) expect(response).to have_http_status(:not_found) end @@ -1254,7 +1260,7 @@ def update_raw_power_state(state, *vms) it "to an invalid vm without appropriate role" do api_basic_authorize - post(invalid_vm_url, gen_request(:request_console)) + post(invalid_vm_url, :params => gen_request(:request_console)) expect(response).to have_http_status(:forbidden) end @@ -1262,7 +1268,7 @@ def update_raw_power_state(state, *vms) it "to a single Vm" do api_basic_authorize action_identifier(:vms, :request_console) - post(vm_url, gen_request(:request_console)) + post(vm_url, :params => gen_request(:request_console)) expect_single_action_result(:success => true, :message => /#{vm.id}.* requesting console/i, :href => api_vm_url(nil, vm.compressed_id)) end @@ -1306,7 +1312,7 @@ def update_raw_power_state(state, *vms) it "query all tags of a Vm and verify tag category and names" do api_basic_authorize - get api_vm_tags_url(nil, vm2), :expand => "resources" + get api_vm_tags_url(nil, vm2), :params => { :expand => "resources" } expect_query_result(:tags, 2, Tag.count) expect_result_resources_to_include_data("resources", "name" => [tag1[:path], tag2[:path]]) @@ -1318,7 +1324,7 @@ def update_raw_power_state(state, *vms) vm1 vm2 - get api_vms_url, :expand => "resources", :filter => ["tags.name='#{tag2[:path]}'"] + get api_vms_url, :params => { :expand => "resources", :filter => ["tags.name='#{tag2[:path]}'"] } expect_query_result(:vms, 1, 2) expect_result_resources_to_include_hrefs("resources", [api_vm_url(nil, vm2.compressed_id)]) @@ -1327,7 +1333,7 @@ def update_raw_power_state(state, *vms) it "assigns a tag to a Vm without appropriate role" do api_basic_authorize - post(api_vm_tags_url(nil, vm1), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_vm_tags_url(nil, vm1), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -1335,7 +1341,7 @@ def update_raw_power_state(state, *vms) it "assigns a tag to a Vm" do api_basic_authorize subcollection_action_identifier(:vms, :tags, :assign) - post(api_vm_tags_url(nil, vm1), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_vm_tags_url(nil, vm1), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result( [{:success => true, :href => api_vm_url(nil, vm1.compressed_id), :tag_category => tag1[:category], :tag_name => tag1[:name]}] @@ -1345,7 +1351,7 @@ def update_raw_power_state(state, *vms) it "assigns a tag to a Vm by name path" do api_basic_authorize subcollection_action_identifier(:vms, :tags, :assign) - post(api_vm_tags_url(nil, vm1), gen_request(:assign, :name => tag1[:path])) + post(api_vm_tags_url(nil, vm1), :params => gen_request(:assign, :name => tag1[:path])) expect_tagging_result( [{:success => true, :href => api_vm_url(nil, vm1.compressed_id), :tag_category => tag1[:category], :tag_name => tag1[:name]}] @@ -1355,7 +1361,7 @@ def update_raw_power_state(state, *vms) it "assigns a tag to a Vm by href" do api_basic_authorize subcollection_action_identifier(:vms, :tags, :assign) - post(api_vm_tags_url(nil, vm1), gen_request(:assign, :href => api_tag_url(nil, Tag.find_by(:name => tag1[:path])))) + post(api_vm_tags_url(nil, vm1), :params => gen_request(:assign, :href => api_tag_url(nil, Tag.find_by(:name => tag1[:path])))) expect_tagging_result( [{:success => true, :href => api_vm_url(nil, vm1.compressed_id), :tag_category => tag1[:category], :tag_name => tag1[:name]}] @@ -1365,7 +1371,7 @@ def update_raw_power_state(state, *vms) it "assigns an invalid tag by href to a Vm" do api_basic_authorize subcollection_action_identifier(:vms, :tags, :assign) - post(api_vm_tags_url(nil, vm1), gen_request(:assign, :href => invalid_tag_url)) + post(api_vm_tags_url(nil, vm1), :params => gen_request(:assign, :href => invalid_tag_url)) expect(response).to have_http_status(:not_found) end @@ -1373,7 +1379,7 @@ def update_raw_power_state(state, *vms) it "assigns an invalid tag to a Vm" do api_basic_authorize subcollection_action_identifier(:vms, :tags, :assign) - post(api_vm_tags_url(nil, vm1), gen_request(:assign, :name => "/managed/bad_category/bad_name")) + post(api_vm_tags_url(nil, vm1), :params => gen_request(:assign, :name => "/managed/bad_category/bad_name")) expect_tagging_result( [{:success => false, :href => api_vm_url(nil, vm1.compressed_id), :tag_category => "bad_category", :tag_name => "bad_name"}] @@ -1383,7 +1389,7 @@ def update_raw_power_state(state, *vms) it "assigns multiple tags to a Vm" do api_basic_authorize subcollection_action_identifier(:vms, :tags, :assign) - post(api_vm_tags_url(nil, vm1), gen_request(:assign, [{:name => tag1[:path]}, {:name => tag2[:path]}])) + post(api_vm_tags_url(nil, vm1), :params => gen_request(:assign, [{:name => tag1[:path]}, {:name => tag2[:path]}])) expect_tagging_result( [{:success => true, :href => api_vm_url(nil, vm1.compressed_id), :tag_category => tag1[:category], :tag_name => tag1[:name]}, @@ -1395,7 +1401,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize subcollection_action_identifier(:vms, :tags, :assign) tag = Tag.find_by(:name => tag2[:path]) - post(api_vm_tags_url(nil, vm1), gen_request(:assign, [{:name => tag1[:path]}, {:href => api_tag_url(nil, tag)}])) + post(api_vm_tags_url(nil, vm1), :params => gen_request(:assign, [{:name => tag1[:path]}, {:href => api_tag_url(nil, tag)}])) expect_tagging_result( [{:success => true, :href => api_vm_url(nil, vm1.compressed_id), :tag_category => tag1[:category], :tag_name => tag1[:name]}, @@ -1406,7 +1412,7 @@ def update_raw_power_state(state, *vms) it "unassigns a tag from a Vm without appropriate role" do api_basic_authorize - post(api_vm_tags_url(nil, vm1), gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) + post(api_vm_tags_url(nil, vm1), :params => gen_request(:assign, :category => tag1[:category], :name => tag1[:name])) expect(response).to have_http_status(:forbidden) end @@ -1414,7 +1420,7 @@ def update_raw_power_state(state, *vms) it "unassigns a tag from a Vm" do api_basic_authorize subcollection_action_identifier(:vms, :tags, :unassign) - post(api_vm_tags_url(nil, vm2), gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) + post(api_vm_tags_url(nil, vm2), :params => gen_request(:unassign, :category => tag1[:category], :name => tag1[:name])) expect_tagging_result( [{:success => true, :href => api_vm_url(nil, vm2.compressed_id), :tag_category => tag1[:category], :tag_name => tag1[:name]}] @@ -1427,7 +1433,7 @@ def update_raw_power_state(state, *vms) api_basic_authorize subcollection_action_identifier(:vms, :tags, :unassign) tag = Tag.find_by(:name => tag2[:path]) - post(api_vm_tags_url(nil, vm2), gen_request(:unassign, [{:name => tag1[:path]}, {:href => api_tag_url(nil, tag)}])) + post(api_vm_tags_url(nil, vm2), :params => gen_request(:unassign, [{:name => tag1[:path]}, {:href => api_tag_url(nil, tag)}])) expect_tagging_result( [{:success => true, :href => api_vm_url(nil, vm2.compressed_id), :tag_category => tag1[:category], :tag_name => tag1[:name]}, @@ -1465,7 +1471,7 @@ def update_raw_power_state(state, *vms) ) api_basic_authorize(action_identifier(:vms, :read, :resource_actions, :get)) - get(api_vm_url(nil, vm), :attributes => "custom_actions") + get(api_vm_url(nil, vm), :params => { :attributes => "custom_actions" }) expected = { "custom_actions" => a_hash_including( @@ -1490,7 +1496,7 @@ def update_raw_power_state(state, *vms) ) api_basic_authorize(action_identifier(:vms, :read, :resource_actions, :get)) - get(api_vm_url(nil, vm), :attributes => "custom_action_buttons") + get(api_vm_url(nil, vm), :params => { :attributes => "custom_action_buttons" }) expected = { "custom_action_buttons" => a_collection_containing_exactly( @@ -1515,7 +1521,7 @@ def update_raw_power_state(state, *vms) ) api_basic_authorize - post(api_vm_url(nil, vm), :action => "test button", :button_key1 => "foo") + post(api_vm_url(nil, vm), :params => { :action => "test button", :button_key1 => "foo" }) expected = { "success" => true, @@ -1533,7 +1539,7 @@ def update_raw_power_state(state, *vms) it "does not allow setting an miq_server without an appropriate role" do api_basic_authorize - post(api_vm_url(nil, vm), :action => 'set_miq_server') + post(api_vm_url(nil, vm), :params => { :action => 'set_miq_server' }) expect(response).to have_http_status(:forbidden) end @@ -1541,7 +1547,7 @@ def update_raw_power_state(state, *vms) it "sets an miq server" do api_basic_authorize action_identifier(:vms, :set_miq_server) - post(api_vm_url(nil, vm), :action => 'set_miq_server', :miq_server => { :href => api_server_url(nil, server)}) + post(api_vm_url(nil, vm), :params => { :action => 'set_miq_server', :miq_server => { :href => api_server_url(nil, server)} }) expected = { 'success' => true, @@ -1555,11 +1561,16 @@ def update_raw_power_state(state, *vms) it "can set multiple miq servers" do api_basic_authorize collection_action_identifier(:vms, :set_miq_server) - post(api_vms_url, :action => 'set_miq_server', - :resources => [ - { :id => vm.id, :miq_server => { :href => api_server_url(nil, server) } }, - { :id => vm1.id, :miq_server => { :id => server2.id }} - ]) + post( + api_vms_url, + :params => { + :action => 'set_miq_server', + :resources => [ + { :id => vm.id, :miq_server => { :href => api_server_url(nil, server) } }, + { :id => vm1.id, :miq_server => { :id => server2.id }} + ] + } + ) expected = { 'results' => [ @@ -1576,13 +1587,13 @@ def update_raw_power_state(state, *vms) it "raises an error unless a valid miq_server reference is specified" do api_basic_authorize action_identifier(:vms, :set_miq_server) - post(api_vm_url(nil, vm), :action => 'set_miq_server', :miq_server => { :href => api_vm_url(nil, 1) }) + post(api_vm_url(nil, vm), :params => { :action => 'set_miq_server', :miq_server => { :href => api_vm_url(nil, 1) } }) expected = { 'success' => false, 'message' => 'Failed to set miq_server - Must specify a valid miq_server href or id' } expect(response.parsed_body).to eq(expected) expect(response).to have_http_status(:ok) - post(api_vm_url(nil, vm), :action => 'set_miq_server', :miq_server => { :id => nil }) + post(api_vm_url(nil, vm), :params => { :action => 'set_miq_server', :miq_server => { :id => nil } }) expect(response.parsed_body).to eq(expected) expect(response).to have_http_status(:ok) end @@ -1591,7 +1602,7 @@ def update_raw_power_state(state, *vms) vm.miq_server = server api_basic_authorize action_identifier(:vms, :set_miq_server) - post(api_vm_url(nil, vm), :action => 'set_miq_server', :miq_server => {}) + post(api_vm_url(nil, vm), :params => { :action => 'set_miq_server', :miq_server => {} }) expected = {'success' => true, 'message' => "Removed miq_server for VM id:#{vm.id} name:'#{vm.name}'"} expect(response.parsed_body).to eq(expected) @@ -1611,7 +1622,7 @@ def update_raw_power_state(state, *vms) it 'returns the metric rollups for the vm' do api_basic_authorize subcollection_action_identifier(:vms, :metric_rollups, :read, :get) - get(url, :capture_interval => 'hourly', :start_date => Time.zone.today.to_s) + get(url, :params => { :capture_interval => 'hourly', :start_date => Time.zone.today.to_s }) expected = { 'count' => 5, @@ -1626,7 +1637,7 @@ def update_raw_power_state(state, *vms) it 'will not return metric rollups without an appropriate role' do api_basic_authorize - get(url, :capture_interval => 'hourly', :start_date => Time.zone.today.to_s) + get(url, :params => { :capture_interval => 'hourly', :start_date => Time.zone.today.to_s }) expect(response).to have_http_status(:forbidden) end