Skip to content

Commit

Permalink
Remove all _verify related references in specs
Browse files Browse the repository at this point in the history
  • Loading branch information
AparnaKarve committed May 22, 2017
1 parent 6e77d8f commit 065451f
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 156 deletions.
34 changes: 12 additions & 22 deletions spec/controllers/ems_cloud_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@
"zone" => zone.name,
"default_userid" => "foo",
"default_password" => "[FILTERED]",
"default_verify" => "[FILTERED]",
"metrics_userid" => "",
"metrics_password" => "[FILTERED]",
"metrics_verify" => "[FILTERED]",
"amqp_userid" => "",
"amqp_password" => "[FILTERED]",
"amqp_verify" => "[FILTERED]",
"ssh_keypair_userid" => "",
"ssh_keypair_password" => "[FILTERED]"
}
Expand All @@ -59,7 +56,6 @@
"zone" => zone.name,
"default_userid" => "foo",
"default_password" => "[FILTERED]",
"default_verify" => "[FILTERED]"
}
end.to change { Authentication.count }.by(1)

Expand All @@ -78,7 +74,6 @@
"default_port" => "5000",
"default_userid" => "bar",
"default_password" => "[FILTERED]",
"default_verify" => "[FILTERED]"
}
end.not_to change { Authentication.count }

Expand All @@ -100,7 +95,6 @@
"zone" => "default",
"default_userid" => "foo",
"default_password" => "[FILTERED]",
"default_verify" => "[FILTERED]"
}

expect(response.status).to eq(200)
Expand All @@ -116,7 +110,6 @@
"zone" => "default",
"default_userid" => "foo",
"default_password" => "[FILTERED]",
"default_verify" => "[FILTERED]"
}

expect(response.status).to eq(200)
Expand All @@ -131,7 +124,6 @@
"zone" => zone.name,
"default_userid" => "foo",
"default_password" => "[FILTERED]",
"default_verify" => "[FILTERED]"
}

expect(response.status).to eq(200)
Expand All @@ -158,7 +150,6 @@
"zone" => zone.name,
"default_userid" => "foo",
"default_password" => "[FILTERED]",
"default_verify" => "[FILTERED]"
}

expect(response.status).to eq(200)
Expand All @@ -169,17 +160,18 @@
end

let(:openstack_form_params) do
{"button" => "add",
"default_hostname" => "host_openstack",
"name" => "foo_openstack",
"emstype" => "openstack",
"tenant_mapping_enabled" => "on",
"provider_region" => "",
"default_port" => "5000",
"zone" => zone.name,
"default_userid" => "foo",
"default_password" => "[FILTERED]",
"default_verify" => "[FILTERED]"}
{
"button" => "add",
"default_hostname" => "host_openstack",
"name" => "foo_openstack",
"emstype" => "openstack",
"tenant_mapping_enabled" => "on",
"provider_region" => "",
"default_port" => "5000",
"zone" => zone.name,
"default_userid" => "foo",
"default_password" => "[FILTERED]",
}
end

it "creates openstack cloud manager with attributes from form" do
Expand Down Expand Up @@ -218,7 +210,6 @@
"zone" => zone.name,
"default_userid" => "foo",
"default_password" => "[FILTERED]",
"default_verify" => "[FILTERED]"
}

expect(response.status).to eq(200)
Expand Down Expand Up @@ -248,7 +239,6 @@
"zone" => zone.name,
"default_userid" => "foo",
"default_password" => "[FILTERED]",
"default_verify" => "[FILTERED]"
}

expect(response.status).to eq(200)
Expand Down
102 changes: 0 additions & 102 deletions spec/controllers/ems_common_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,6 @@

describe EmsCloudController do
context "::EmsCommon" do
context "#get_form_vars" do
it "check if the default port for openstack/openstack_infra/rhevm is set" do
controller.instance_variable_set(:@edit, :new => {})
controller.instance_variable_set(:@_params, :server_emstype => "openstack")
controller.send(:get_form_vars)
expect(assigns(:edit)[:new][:port]).to eq(5000)

controller.instance_variable_set(:@_params, :server_emstype => "openstack_infra")
controller.send(:get_form_vars)
expect(assigns(:edit)[:new][:port]).to eq(5000)

controller.instance_variable_set(:@_params, :server_emstype => "ec2")
controller.send(:get_form_vars)
expect(assigns(:edit)[:new][:port]).to be_nil
end
end

context "#get_form_vars" do
it "check if provider_region gets reset when provider type is changed on add screen" do
controller.instance_variable_set(:@edit, :new => {})
controller.instance_variable_set(:@_params, :server_emstype => "ec2")
controller.instance_variable_set(:@_params, :provider_region => "some_region")

controller.send(:get_form_vars)
expect(assigns(:edit)[:new][:provider_region]).to eq("some_region")

controller.instance_variable_set(:@_params, :server_emstype => "openstack")
controller.send(:get_form_vars)
expect(assigns(:edit)[:new][:provider_region]).to be_nil
end
end

context "#new" do
before do
stub_user(:features => :all)
Expand All @@ -53,60 +21,6 @@
end
end

context "#set_record_vars" do
context "strip leading/trailing whitespace from hostname/ipaddress" do
after :each do
stub_user(:features => :all)
controller.instance_variable_set(:@edit, :new => {:name => 'EMS 1',
:emstype => @type,
:hostname => ' 10.10.10.10 ',
:port => '5000'},
:key => 'ems_edit__new')
session[:edit] = assigns(:edit)
controller.send(:set_record_vars, @ems)
expect(@ems.hostname).to eq('10.10.10.10')
end

it "when adding cloud EMS" do
@type = 'openstack'
@ems = ManageIQ::Providers::Openstack::CloudManager.new
end

it "when adding infra EMS" do
@type = 'rhevm'
@ems = ManageIQ::Providers::Redhat::InfraManager.new
end
end
end

context "#update_button_validate" do
context "when authentication_check" do
let(:mocked_ems_cloud) { double(EmsCloud) }
before(:each) do
controller.instance_variable_set(:@_params, :id => "42", :type => "amqp")
expect(controller).to receive(:find_record_with_rbac).with(EmsCloud, "42").and_return(mocked_ems_cloud)
expect(controller).to receive(:set_record_vars).with(mocked_ems_cloud, :validate).and_return(mocked_ems_cloud)
end

it "successful flash message (unchanged)" do
allow(controller).to receive_messages(:edit_changed? => false)
expect(mocked_ems_cloud).to receive(:authentication_check).with("amqp", :save => true).and_return([true, ""])
expect(controller).to receive(:add_flash).with(_("Credential validation was successful"))
expect(controller).to receive(:render_flash)
controller.send(:update_button_validate)
end

it "unsuccessful flash message (changed)" do
allow(controller).to receive_messages(:edit_changed? => true)
expect(mocked_ems_cloud).to receive(:authentication_check)
.with("amqp", :save => false).and_return([false, "Invalid"])
expect(controller).to receive(:add_flash).with(_("Credential validation was not successful: Invalid"), :error)
expect(controller).to receive(:render_flash)
controller.send(:update_button_validate)
end
end
end

context "#button" do
before(:each) do
stub_user(:features => :all)
Expand Down Expand Up @@ -346,22 +260,6 @@ def test_setting_few_fields
link = controller.send(:show_link, ems, :display => "vms")
expect(link).to eq("/ems_infra/#{ems.id}?display=vms")
end

context "#restore_password" do
it "populates the password from the ems record if params[:restore_password] exists" do
infra_ems = EmsInfra.new
allow(infra_ems).to receive(:authentication_password).and_return("default_password")
edit = {:ems_id => infra_ems.id, :new => {}}
controller.instance_variable_set(:@edit, edit)
controller.instance_variable_set(:@ems, infra_ems)
controller.instance_variable_set(:@_params,
:restore_password => true,
:default_password => "[FILTERED]",
:default_verify => "[FILTERED]")
controller.send(:restore_password)
expect(assigns(:edit)[:new][:default_password]).to eq(infra_ems.authentication_password)
end
end
end
include_examples '#download_summary_pdf', :ems_openstack_infra
end
2 changes: 0 additions & 2 deletions spec/controllers/ems_container_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
"default_api_port" => "5000",
"default_userid" => "",
"default_password" => "",
"default_verify" => "",
"provider_region" => "",
"metrics_selection" => "hawkular_disabled"
}
Expand All @@ -95,7 +94,6 @@
"default_api_port" => "5000",
"default_userid" => "",
"default_password" => "",
"default_verify" => "",
"provider_region" => "",
"metrics_selection" => "hawkular_enabled",
"hawkular_security_protocol" => "ssl-without-validation",
Expand Down
3 changes: 0 additions & 3 deletions spec/controllers/ems_datawarehouse_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"default_api_port" => "443",
"default_userid" => "",
"default_password" => "VERY_SECRET",
"default_verify" => "VERY_SECRET",
}
end.to change { ManageIQ::Providers::Hawkular::DatawarehouseManager.count }.by(1)
end
Expand All @@ -70,7 +69,6 @@
"default_hostname" => "lotsofdata.com",
"default_userid" => "",
"default_password" => "VERY_SECRET",
"default_verify" => "VERY_SECRET"
}
end.to change { Authentication.count }.by(1)

Expand All @@ -88,7 +86,6 @@
"default_hostname" => "host_hawkular_updated",
"default_userid" => "",
"default_password" => "MUCH_WOW",
"default_verify" => "MUCH_WOW"
}
end.not_to change { Authentication.count }

Expand Down
Loading

0 comments on commit 065451f

Please sign in to comment.