Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CAT-1382] : Fixing CI failure due to rubocop #380

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,6 @@ RSpec/EmptyExampleGroup:
RSpec/ExampleLength:
Max: 37

# Offense count: 1
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Include: **/*_spec*rb*, **/spec/**/*
RSpec/FilePath:
Exclude:
- 'spec/acceptance/iis_virtual_directory_spec_test.rb'

# Offense count: 1
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Expand Down Expand Up @@ -140,6 +133,7 @@ RSpec/NoExpectationExample:
- 'spec/unit/puppet/provider/iis_virtual_directory/webadministration_spec.rb'
- 'spec/unit/puppet/type/iis_site_spec.rb'
- 'spec/unit/puppet/type/iis_virtual_directory_spec.rb'
- 'spec/acceptance/iis_virtual_directory_test_spec.rb'

# Offense count: 4
RSpec/StubbedMock:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

describe 'iis_virtual_directory', :suite_b do
site_name = SecureRandom.hex(10)
before(:all) do
before(:context) do
# Remove 'Default Web Site' to start from a clean slate
remove_all_sites
create_site(site_name, true)
end

after(:all) do
after(:context) do
remove_all_sites
end

Expand Down Expand Up @@ -55,7 +55,7 @@
iis_idempotent_apply('create iis virtual dir', manifest)

after(:all) do
remove_vdir(virt_dir_name)
remove_vdir(virt_dir_name, site_name)
end

it 'iis_virtual_directory should be present' do
Expand All @@ -74,56 +74,53 @@
end

context 'with a password wrapped in Sensitive()' do
if installed_puppet_version.to_i < 5
skip 'is skipped due to version being lower than puppet 5'
else
virt_dir_name = SecureRandom.hex(10).to_s
manifest = <<-HERE
file{ 'c:/foo':
ensure => 'directory'
}->
iis_virtual_directory { '#{virt_dir_name}':
ensure => 'present',
sitename => '#{site_name}',
physicalpath => 'c:\\foo',
user_name => 'user',
password => Sensitive('#@\\'454sdf'),
}
HERE
virt_dir_name = SecureRandom.hex(10).to_s
manifest = <<-HERE
file{ 'c:/foo':
ensure => 'directory'
}->
iis_virtual_directory { '#{virt_dir_name}':
ensure => 'present',
sitename => '#{site_name}',
physicalpath => 'c:\\foo',
user_name => 'user',
password => Sensitive('#@\\'454sdf'),
}
HERE

iis_idempotent_apply('create iis virtual dir', manifest)

it 'all parameters are configured' do
resource_data = resource('iis_virtual_directory', virt_dir_name)
[
'ensure', 'present',
'user_name', 'user',
'password', '#@\\\'454sdf'
].each_slice(2) do |key, value|
puppet_resource_should_show(key, value, resource_data)
end
end
iis_idempotent_apply('create iis virtual dir', manifest)

it 'remove virt dir name' do
remove_vdir(virt_dir_name)
it 'all parameters are configured' do
resource_data = resource('iis_virtual_directory', virt_dir_name)
[
'ensure', 'present',
'user_name', 'user',
'password', '#@\\\'454sdf'
].each_slice(2) do |key, value|
puppet_resource_should_show(key, value, resource_data)
end
end

it 'remove virt dir name' do
remove_vdir(virt_dir_name, site_name)
end
end

context 'can remove virtual directory' do
context 'when virtual directory is removed' do
virt_dir_name = SecureRandom.hex(10).to_s
before(:all) do
create_path('c:/foo')
create_vdir(virt_dir_name, 'foo', 'c:/foo')
create_vdir(virt_dir_name, site_name, 'c:/foo')
end

manifest = <<-HERE
iis_virtual_directory { '#{virt_dir_name}':
sitename => '#{site_name}',
ensure => 'absent'
}
HERE

iis_idempotent_apply('create iis virtual dir', manifest)
iis_idempotent_apply('remove iis virtual dir', manifest)

after(:all) do
remove_vdir(virt_dir_name)
Expand All @@ -134,37 +131,8 @@
end
end

context 'name allows slashes' do
virt_dir_name = SecureRandom.hex(10).to_s
before(:all) do
create_path('c:\inetpub\test_site')
create_path('c:\inetpub\test_vdir')
create_path('c:\inetpub\deeper')
create_site(site_name, true)
end

manifest = <<-HERE
iis_virtual_directory{ "test_vdir":
ensure => 'present',
sitename => "#{site_name}",
physicalpath => 'c:\\inetpub\\test_vdir',
}->
iis_virtual_directory { 'test_vdir\deeper':
name => 'test_vdir\deeper',
ensure => 'present',
sitename => '#{site_name}',
physicalpath => 'c:\\inetpub\\deeper',
}
HERE
iis_idempotent_apply('create iis virtual dir', manifest)

after(:all) do
remove_vdir(virt_dir_name)
end
end

context 'with invalid' do
context 'physicalpath parameter defined' do
context 'when physicalpath parameter is defined' do
virt_dir_name = SecureRandom.hex(10).to_s
manifest = <<-HERE
iis_virtual_directory { '#{virt_dir_name}':
Expand All @@ -184,7 +152,7 @@
end
end

context 'physicalpath parameter not defined' do
context 'when physicalpath parameter is not defined' do
virt_dir_name = SecureRandom.hex(10).to_s
manifest = <<-HERE
iis_virtual_directory { '#{virt_dir_name}':
Expand Down