diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb index e021a7ba..2cec5e6e 100644 --- a/spec/acceptance/basic_spec.rb +++ b/spec/acceptance/basic_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper_acceptance' describe 'basic installation' do - certdir = '/etc/pulpcore-certs' - it_behaves_like 'an idempotent resource' do let(:manifest) do <<-PUPPET @@ -11,70 +9,7 @@ end end - describe user('pulp') do - it { is_expected.to exist } - its(:uid) { is_expected.to be < 1000 } - end - - describe group('pulp') do - it { is_expected.to exist } - its(:gid) { is_expected.to be < 1000 } - end - - describe service('httpd') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end - - describe service('pulpcore-api') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end - - describe service('pulpcore-content') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end - - describe service('pulpcore-resource-manager') do - it { is_expected.not_to be_enabled } - it { is_expected.not_to be_running } - end - - describe service('pulpcore-worker@1') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end - - describe port(80) do - it { is_expected.to be_listening } - end - - describe port(443) do - it { is_expected.to be_listening } - end - - describe curl_command("https://#{host_inventory['fqdn']}/pulp/api/v3/status/", cacert: "#{certdir}/ca-cert.pem") do - its(:response_code) { is_expected.to eq(200) } - its(:exit_status) { is_expected.to eq 0 } - end - - describe command("PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager dumpdata auth.User") do - its(:stdout) { is_expected.to match(/auth\.user/) } - its(:exit_status) { is_expected.to eq 0 } - end - - describe curl_command("https://#{host_inventory['fqdn']}/pulp/api/v3/", cacert: "#{certdir}/ca-cert.pem") do - its(:response_code) { is_expected.to eq(403) } - its(:exit_status) { is_expected.to eq 0 } - end - - describe curl_command("https://#{host_inventory['fqdn']}/pulp/api/v3/", - cacert: "#{certdir}/ca-cert.pem", key: "#{certdir}/client-key.pem", cert: "#{certdir}/client-cert.pem") do - its(:response_code) { is_expected.to eq(200) } - its(:body) { is_expected.to contain('artifacts') } - its(:exit_status) { is_expected.to eq 0 } - end + include_examples 'the default pulpcore application' describe command("PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager diffsettings") do its(:exit_status) { is_expected.to eq 0 } @@ -82,8 +17,6 @@ end describe 'with content cache enabled' do - certdir = '/etc/pulpcore-certs' - it_behaves_like 'an idempotent resource' do let(:manifest) do <<-PUPPET @@ -94,23 +27,7 @@ class { 'pulpcore': end end - describe service('httpd') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end - - describe service('pulpcore-content') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end - - describe port(80) do - it { is_expected.to be_listening } - end - - describe port(443) do - it { is_expected.to be_listening } - end + include_examples 'the default pulpcore application' describe port(6379) do it { is_expected.to be_listening } @@ -125,9 +42,4 @@ class { 'pulpcore': it { is_expected.to be_running } it { is_expected.to be_enabled } end - - describe curl_command("https://#{host_inventory['fqdn']}/pulp/api/v3/status/", cacert: "#{certdir}/ca-cert.pem") do - its(:response_code) { is_expected.to eq(200) } - its(:exit_status) { is_expected.to eq 0 } - end end diff --git a/spec/acceptance/plugins_spec.rb b/spec/acceptance/plugins_spec.rb index 4be63907..7d046ca4 100644 --- a/spec/acceptance/plugins_spec.rb +++ b/spec/acceptance/plugins_spec.rb @@ -19,38 +19,10 @@ end end + include_examples 'the default pulpcore application' + describe file('/etc/pulp/settings.py') do it { is_expected.to be_file } its(:content) { is_expected.to match(/^TOKEN_AUTH_DISABLED=True$/) } end - - describe service('httpd') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end - - describe service('pulpcore-api') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end - - describe service('pulpcore-content') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end - - describe service('pulpcore-resource-manager') do - it { is_expected.not_to be_enabled } - it { is_expected.not_to be_running } - end - - describe port(80) do - it { is_expected.to be_listening } - end - - describe curl_command("https://#{host_inventory['fqdn']}/pulp/api/v3/status/", cacert: '/etc/pulpcore-certs/ca-cert.pem') do - its(:response_code) { is_expected.to eq(200) } - its(:exit_status) { is_expected.to eq 0 } - end - end diff --git a/spec/acceptance/use_pulp2_content_route_spec.rb b/spec/acceptance/use_pulp2_content_route_spec.rb index 4e539b19..6d39ade3 100644 --- a/spec/acceptance/use_pulp2_content_route_spec.rb +++ b/spec/acceptance/use_pulp2_content_route_spec.rb @@ -18,37 +18,10 @@ class { 'pulpcore::plugin::rpm': end end + include_examples 'the default pulpcore application' + describe file('/etc/pulp/settings.py') do it { is_expected.to be_file } its(:content) { is_expected.to match(/^TOKEN_AUTH_DISABLED=True$/) } end - - describe service('httpd') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end - - describe service('pulpcore-api') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end - - describe service('pulpcore-content') do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end - - describe service('pulpcore-resource-manager') do - it { is_expected.not_to be_enabled } - it { is_expected.not_to be_running } - end - - describe port(80) do - it { is_expected.to be_listening } - end - - describe curl_command("https://#{host_inventory['fqdn']}/pulp/api/v3/status/", cacert: '/etc/pulpcore-certs/ca-cert.pem') do - its(:response_code) { is_expected.to eq(200) } - its(:exit_status) { is_expected.to eq 0 } - end end diff --git a/spec/support/acceptance/examples.rb b/spec/support/acceptance/examples.rb new file mode 100644 index 00000000..c45a2588 --- /dev/null +++ b/spec/support/acceptance/examples.rb @@ -0,0 +1,69 @@ +shared_examples 'the default pulpcore application' do + certdir = '/etc/pulpcore-certs' + + describe user('pulp') do + it { is_expected.to exist } + its(:uid) { is_expected.to be < 1000 } + end + + describe group('pulp') do + it { is_expected.to exist } + its(:gid) { is_expected.to be < 1000 } + end + + describe service('httpd') do + it { is_expected.to be_enabled } + it { is_expected.to be_running } + end + + describe service('pulpcore-api') do + it { is_expected.to be_enabled } + it { is_expected.to be_running } + end + + describe service('pulpcore-content') do + it { is_expected.to be_enabled } + it { is_expected.to be_running } + end + + describe service('pulpcore-resource-manager') do + it { is_expected.not_to be_enabled } + it { is_expected.not_to be_running } + end + + describe service('pulpcore-worker@1') do + it { is_expected.to be_enabled } + it { is_expected.to be_running } + end + + describe port(80) do + it { is_expected.to be_listening } + end + + describe port(443) do + it { is_expected.to be_listening } + end + + describe curl_command("https://#{host_inventory['fqdn']}/pulp/api/v3/status/", cacert: "#{certdir}/ca-cert.pem") do + its(:response_code) { is_expected.to eq(200) } + its(:exit_status) { is_expected.to eq 0 } + end + + describe command("PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager dumpdata auth.User") do + its(:stdout) { is_expected.to match(/auth\.user/) } + its(:exit_status) { is_expected.to eq 0 } + end + + describe curl_command("https://#{host_inventory['fqdn']}/pulp/api/v3/", cacert: "#{certdir}/ca-cert.pem") do + # Requires authentication: https://github.com/pulp/pulpcore/issues/2340 + its(:response_code) { is_expected.to eq(403) } + its(:exit_status) { is_expected.to eq 0 } + end + + describe curl_command("https://#{host_inventory['fqdn']}/pulp/api/v3/", + cacert: "#{certdir}/ca-cert.pem", key: "#{certdir}/client-key.pem", cert: "#{certdir}/client-cert.pem") do + its(:response_code) { is_expected.to eq(200) } + its(:body) { is_expected.to contain('artifacts') } + its(:exit_status) { is_expected.to eq 0 } + end +end