Files
cookbook-openstack-common/spec/default-redhat_spec.rb
Imtiaz Chowdhury 987e0e1338 Making gpgcheck configurable for RDO repo
Currently, gpgcheck flag is not configurable and is always enabled by
default. For certain use cases, for example, using these cookbooks in
production where internet access is restricted, we need to disable
gpgcheck.

This commit makes the gpgcheck configurable so that users can override
it if needed.

Change-Id: I10620f2d5adc240fda6273680638d0429260b9cc
Related-Bug: #1417119
2015-02-02 06:43:18 -08:00

71 lines
2.1 KiB
Ruby

# encoding: UTF-8
require_relative 'spec_helper'
describe 'openstack-common::default' do
describe 'rhel-rdo' do
let(:runner) { ChefSpec::Runner.new(REDHAT_OPTS) }
let(:node) { runner.node }
let(:chef_run) do
node.set['openstack']['release'] = 'testrelease'
runner.converge(described_recipe)
end
context 'enabling RDO with gpgcheck enabled' do
before do
node.set['openstack']['yum']['rdo_enabled'] = true
end
it 'adds RDO yum repository' do
# Using cookbook(yum) LWRP custom matcher
# https://github.com/sethvargo/chefspec#packaging-custom-matchers
expect(chef_run).to add_yum_repository('RDO-testrelease')
.with(gpgcheck: true)
end
it 'includes yum-epel recipe' do
expect(chef_run).to include_recipe('yum-epel')
end
end
context 'enabling RDO with gpgcheck disabled' do
before do
node.set['openstack']['yum']['rdo_enabled'] = true
node.set['openstack']['yum']['gpgcheck'] = false
end
it 'adds RDO yum repository' do
expect(chef_run).to add_yum_repository('RDO-testrelease')
.with(gpgcheck: false)
end
it 'includes yum-epel recipe' do
expect(chef_run).to include_recipe('yum-epel')
end
end
context 'disabling RDO' do
before do
node.set['openstack']['yum']['rdo_enabled'] = false
end
it 'removes RDO yum repository' do
allow(FileTest).to receive(:exist?).with('/etc/yum.repos.d/RDO-testrelease.repo').and_return(true)
# Using cookbook(yum) LWRP custom matcher
# https://github.com/sethvargo/chefspec#packaging-custom-matchers
expect(chef_run).to remove_yum_repository('RDO-testrelease')
end
it 'does nothing when RDO yum repository does not exist' do
repo = chef_run.find_resource('yum_repository', 'RDO-testrelease')
expect(repo.performed_actions).to be_empty
end
it 'does not include yum-epel recipe' do
expect(chef_run).to_not include_recipe('yum-epel')
end
end
end
end