|
1 | 1 | describe EmsCloudController do
|
2 | 2 | let!(:server) { EvmSpecHelper.local_miq_server(:zone => zone) }
|
3 | 3 | let(:zone) { FactoryBot.build(:zone) }
|
| 4 | + |
4 | 5 | describe "#create" do
|
5 | 6 | before do
|
6 | 7 | allow(controller).to receive(:check_privileges).and_return(true)
|
|
264 | 265 | end
|
265 | 266 | end
|
266 | 267 |
|
267 |
| - context "#build_credentials only contains credentials that it supports and has a username for in params" do |
| 268 | + describe "#build_credentials only contains credentials that it supports and has a username for in params" do |
268 | 269 | let(:mocked_ems) { double(ManageIQ::Providers::Openstack::CloudManager) }
|
269 | 270 | let(:default_creds) { {:userid => "default_userid", :password => "default_password"} }
|
270 | 271 | let(:amqp_creds) { {:userid => "amqp_userid", :password => "amqp_password"} }
|
|
294 | 295 | end
|
295 | 296 | end
|
296 | 297 |
|
297 |
| - context "#update_ems_button_validate" do |
| 298 | + describe "#update_ems_button_validate" do |
298 | 299 | let(:mocked_ems) { FactoryBot.create(:ems_openstack) }
|
299 | 300 |
|
300 | 301 | it "calls authentication_check with save = false" do
|
|
308 | 309 | end
|
309 | 310 | end
|
310 | 311 |
|
311 |
| - context "#create_ems_button_validate" do |
| 312 | + describe "#create_ems_button_validate" do |
312 | 313 | let(:mocked_params) { {:controller => mocked_class_controller, :cred_type => "default"} }
|
| 314 | + |
313 | 315 | before do
|
314 | 316 | allow(controller).to receive(:render)
|
315 | 317 | controller.params = mocked_params
|
|
668 | 670 |
|
669 | 671 | describe "#sync_users" do
|
670 | 672 | let(:ems) { FactoryBot.create(:ems_openstack_with_authentication) }
|
671 |
| - before do |
672 |
| - stub_user(:features => :all) |
673 |
| - end |
| 673 | + |
| 674 | + before { stub_user(:features => :all) } |
674 | 675 |
|
675 | 676 | it "redirects when request is successful" do
|
676 | 677 | expect(controller).to receive(:find_record_with_rbac).and_return(ems)
|
@@ -717,6 +718,7 @@ def verify_password_and_confirm(password, verify)
|
717 | 718 |
|
718 | 719 | context "'Set Default' button rendering in listnav" do
|
719 | 720 | render_views
|
| 721 | + |
720 | 722 | before do
|
721 | 723 | stub_user(:features => :all)
|
722 | 724 | EvmSpecHelper.create_guid_miq_server_zone
|
@@ -783,4 +785,38 @@ def verify_password_and_confirm(password, verify)
|
783 | 785 |
|
784 | 786 | include_examples 'hiding tenant column for non admin user', :name => "Name", :emstype_description => "Type"
|
785 | 787 | end
|
| 788 | + |
| 789 | + describe '#button' do |
| 790 | + context 'Check Compliance of Last Known Configuration on Instances' do |
| 791 | + let(:vm_instance) { FactoryBot.create(:vm_or_template) } |
| 792 | + let(:ems) { FactoryBot.create(:ems_openstack) } |
| 793 | + |
| 794 | + before do |
| 795 | + allow(controller).to receive(:assert_privileges) |
| 796 | + allow(controller).to receive(:performed?).and_return(true) |
| 797 | + allow(controller).to receive(:render) |
| 798 | + controller.instance_variable_set(:@display, 'instances') |
| 799 | + controller.params = {:miq_grid_checks => vm_instance.id.to_s, :pressed => 'instance_check_compliance', :id => ems.id.to_s, :controller => 'ems_cloud'} |
| 800 | + end |
| 801 | + |
| 802 | + it 'does not initiate Check Compliance because of missing Compliance policies' do |
| 803 | + controller.send(:button) |
| 804 | + expect(controller.instance_variable_get(:@flash_array)).to eq([{:message => 'No Compliance Policies assigned to one or more of the selected items', :level => :error}]) |
| 805 | + end |
| 806 | + |
| 807 | + context 'VM Compliance policy set' do |
| 808 | + let(:policy) { FactoryBot.create(:miq_policy, :mode => 'compliance', :towhat => 'Vm', :active => true) } |
| 809 | + |
| 810 | + before do |
| 811 | + vm_instance.add_policy(policy) |
| 812 | + allow(MiqPolicy).to receive(:policy_for_event?).and_return(true) |
| 813 | + end |
| 814 | + |
| 815 | + it 'initiates Check Compliance action' do |
| 816 | + controller.send(:button) |
| 817 | + expect(controller.instance_variable_get(:@flash_array)).to eq([{:message => 'Check Compliance initiated for 1 VM and Instance from the ManageIQ Database', :level => :success}]) |
| 818 | + end |
| 819 | + end |
| 820 | + end |
| 821 | + end |
786 | 822 | end
|
0 commit comments