Fuel Library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cobbler_apache_spec.rb 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. require "spec_helper"
  2. describe "cobbler::apache" do
  3. shared_examples_for "cobbler configuration" do
  4. context "with default params" do
  5. let(:aliases) do
  6. if Puppet.version.to_f >= 4.0
  7. [
  8. {
  9. "alias" => "/cobbler/boot",
  10. "path" => "/var/lib/tftpboot",
  11. }
  12. ]
  13. else
  14. [
  15. ["alias", "/cobbler/boot"],
  16. ["path", "/var/lib/tftpboot"],
  17. ]
  18. end
  19. end
  20. let(:directories) do
  21. if Puppet.version.to_f >= 4.0
  22. [
  23. {
  24. "path" => "/var/lib/tftpboot",
  25. "options" => ["Indexes", "FollowSymLinks"],
  26. },
  27. ]
  28. else
  29. [
  30. ["path", "/var/lib/tftpboot"],
  31. ["options", ["Indexes", "FollowSymLinks"]],
  32. ]
  33. end
  34. end
  35. let(:ssl_rewrites) do
  36. if Puppet.version.to_f >= 4.0
  37. [
  38. {
  39. "comment" => "Redirect root path to SSL Nailgun",
  40. "rewrite_rule" => ["^/$ https://%{HTTP_HOST}:8443%{REQUEST_URI} [R=301,L]"],
  41. },
  42. ]
  43. else
  44. [
  45. ["comment", "Redirect root path to SSL Nailgun"],
  46. ["rewrite_rule", ["^/$ https://%{HTTP_HOST}:8443%{REQUEST_URI} [R=301,L]"]]
  47. ]
  48. end
  49. end
  50. it "ensures httpd confdir for ports-configs" do
  51. is_expected.to contain_file('/etc/httpd/conf.ports.d/').with(
  52. :ensure => 'directory',
  53. )
  54. end
  55. it "configures 'apache' class" do
  56. is_expected.to contain_class("apache").with(
  57. :server_signature => "Off",
  58. :trace_enable => "Off",
  59. :purge_configs => false,
  60. :purge_vhost_dir => false,
  61. :default_vhost => false,
  62. :conf_template => 'fuel/httpd.conf.erb',
  63. :ports_file => '/etc/httpd/conf.ports.d/cobbler.conf',
  64. )
  65. end
  66. it "creates 'cobbler non-ssl' vhost" do
  67. is_expected.to contain_apache__vhost("cobbler non-ssl").with(
  68. :servername => "_default_",
  69. :port => 80,
  70. :docroot => "/var/www/html",
  71. :aliases => aliases,
  72. :rewrites => [
  73. {
  74. "comment" => "Redirect root path to SSL Nailgun",
  75. "rewrite_cond" => ["%{HTTPS} off"],
  76. "rewrite_rule" => ["^/$ https://%{HTTP_HOST}:8443%{REQUEST_URI} [R=301,L]"]
  77. },
  78. {
  79. "comment" => "Redirect other non-cobbler path to Nailgun",
  80. "rewrite_cond" => ["%{HTTPS} off", "%{REQUEST_URI} !^/(cblr|cobbler)"],
  81. "rewrite_rule" => ["(.*) http://%{HTTP_HOST}:8000%{REQUEST_URI} [R=301,L]"]
  82. },
  83. ],
  84. :directories => directories,
  85. )
  86. end
  87. it "creates 'cobbler ssl' vhost" do
  88. is_expected.to contain_apache__vhost("cobbler ssl").with(
  89. :servername => "_default_",
  90. :port => 443,
  91. :docroot => "/var/www/html",
  92. :ssl => true,
  93. :ssl_cert => "/var/lib/fuel/keys/master/cobbler/cobbler.crt",
  94. :ssl_key => "/var/lib/fuel/keys/master/cobbler/cobbler.key",
  95. :rewrites => ssl_rewrites,
  96. :ssl_cipher => "ALL:!ADH:!EXPORT:!SSLv2:!MEDIUM:!LOW:+HIGH",
  97. :setenvif => ["User-Agent \".*MSIE.*\" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0"],
  98. )
  99. end
  100. end
  101. end
  102. on_supported_os(supported_os: supported_os).each do |os, facts|
  103. context "on #{os}" do
  104. let(:facts) { facts }
  105. it_configures "cobbler configuration"
  106. end
  107. end
  108. end