Files
puppet-nova/spec/unit/provider/nova_security_group/openstack_spec.rb
Mohammed Naser 0f8c04df8e Switch nova_security_group to openstack provider
The current nova provider for nova_security_group is broken at the
moment.  Due to the fact that the commands are getting deprecated,
the warnings are confusing the text parsing and result in repeated
creation of security groups.

This patch resolves this issue by switching it to the new openstack
provider.  It also adds the instances and prefetch methods which
will allow `puppet resource` CLI usage.

Change-Id: Ibdd930d9b89a1e9ac6d47a5cbf2d7903b145971e
2017-07-26 11:49:23 -04:00

49 lines
1.3 KiB
Ruby

require 'puppet'
require 'spec_helper'
require 'puppet/provider/nova_flavor/openstack'
provider_class = Puppet::Type.type(:nova_security_group).provider(:openstack)
describe provider_class do
describe 'managing security groups' do
let(:secgroup_attrs) do
{
:name => "scg0",
:description => "Security Group",
}
end
let :resource do
Puppet::Type::Nova_security_group.new(secgroup_attrs)
end
let(:provider) do
provider_class.new(resource)
end
describe "#create" do
it 'should create security group' do
provider.class.stubs(:openstack)
.with('security group', 'list', ['--all'])
.returns('"ID", "Name", "Description", "Project"')
provider.class.stubs(:openstack)
.with('security group', 'create', ['scg0', '--description', 'Security Group'])
.returns('id="f630dd92-3ff7-49bc-b012-b211451aa419"
name="scg0"
description="Security Group"')
end
end
describe '#destroy' do
it 'removes flavor' do
provider_class.expects(:openstack)
.with('security group', 'delete', 'scg0')
provider.instance_variable_set(:@property_hash, secgroup_attrs)
provider.destroy
expect(provider.exists?).to be_falsey
end
end
end
end