|
| 1 | +require 'spec_helper' |
| 2 | +describe 'repose::filter::container' do |
| 3 | + context 'on RedHat' do |
| 4 | + let :facts do |
| 5 | + { |
| 6 | + :osfamily => 'RedHat', |
| 7 | + :operationsystemrelease => '6', |
| 8 | + } |
| 9 | + end |
| 10 | + |
| 11 | + context 'with defaults for all parameters' do |
| 12 | + it { |
| 13 | + expect { |
| 14 | + should compile |
| 15 | + }.to raise_error(Puppet::Error, /app_name is a required parameter/) |
| 16 | + } |
| 17 | + end |
| 18 | + |
| 19 | + context 'with defaults with app_name' do |
| 20 | + let(:params) { { |
| 21 | + :app_name => 'app' |
| 22 | + } } |
| 23 | + it { |
| 24 | + should contain_file('/etc/repose/log4j.properties'). |
| 25 | + with_content(/log4j\.rootLogger=WARN/). |
| 26 | + with_content(/log4j\.appender\.defaultFile\.File=\/var\/log\/repose\/app\.log/) |
| 27 | + should contain_file('/etc/repose/container.cfg.xml') |
| 28 | + } |
| 29 | + end |
| 30 | + |
| 31 | + context 'configure logging' do |
| 32 | + let(:params) { { |
| 33 | + :app_name => 'app', |
| 34 | + :log_dir => '/mypath', |
| 35 | + :log_level => 'DEBUG', |
| 36 | + :syslog_server => 'syslog.example.com', |
| 37 | + :syslog_port => 515, |
| 38 | + :syslog_protocol => 'tcp' |
| 39 | + } } |
| 40 | + it { |
| 41 | + should contain_file('/etc/repose/log4j.properties'). |
| 42 | + with_content(/log4j\.appender\.defaultFile\.File=\/mypath\/app\.log/). |
| 43 | + with_content(/log4j\.rootLogger=DEBUG, syslog, defaultFile/). |
| 44 | + with_content(/log4j.logger.http=INFO, httpSyslog/). |
| 45 | + with_content(/syslog.syslogHost=syslog.example.com/). |
| 46 | + with_content(/syslog.port=515/). |
| 47 | + with_content(/syslog.protocol=tcp/). |
| 48 | + with_content(/httpSyslog.syslogHost=syslog.example.com/). |
| 49 | + with_content(/httpSyslog.port=515/). |
| 50 | + with_content(/httpSyslog.protocol=tcp/) |
| 51 | + should contain_file('/etc/repose/container.cfg.xml') |
| 52 | + } |
| 53 | + end |
| 54 | + |
| 55 | + context 'configure container' do |
| 56 | + let(:params) { { |
| 57 | + :app_name => 'app', |
| 58 | + :via => 'my app', |
| 59 | + :deployment_directory => '/deployment_dir', |
| 60 | + :deployment_directory_auto_clean => 'false', |
| 61 | + :artifact_directory => '/artifact_dir', |
| 62 | + :artifact_directory_check_interval => '10000', |
| 63 | + :logging_configuration => 'mylog4j.properties', |
| 64 | + :ssl_enabled => true, |
| 65 | + :ssl_keystore_filename => 'keystore.name', |
| 66 | + :ssl_keystore_password => 'mypassword', |
| 67 | + :ssl_key_password => 'keypassword', |
| 68 | + :content_body_read_limit => '10240000', |
| 69 | + :jmx_reset_time => '3600000', |
| 70 | + :client_request_logging => 'false', |
| 71 | + :http_port => '10000', |
| 72 | + :https_port => '10001', |
| 73 | + :connection_timeout => '40000', |
| 74 | + :read_timeout => '1000', |
| 75 | + :proxy_thread_pool => 'my-pool' |
| 76 | + } } |
| 77 | + it { |
| 78 | + should contain_file('/etc/repose/mylog4j.properties') |
| 79 | + should contain_file('/etc/repose/container.cfg.xml'). |
| 80 | + with_content(/http-port="10000"/). |
| 81 | + with_content(/https-port="10001"/). |
| 82 | + with_content(/via="my app"/). |
| 83 | + with_content(/content-body-read-limit="10240000"/). |
| 84 | + with_content(/connection-timeout="40000"/). |
| 85 | + with_content(/read-timeout="1000"/). |
| 86 | + with_content(/proxy-thread-pool="my-pool"/). |
| 87 | + with_content(/client-request-logging="false"/). |
| 88 | + with_content(/jmx-reset-time="3600000"/). |
| 89 | + with_content(/<deployment-directory auto-clean=\"false\">\/deployment_dir<\/deployment-directory>/). |
| 90 | + with_content(/<artifact-directory check-interval="10000">\/artifact_dir<\/artifact-directory>/). |
| 91 | + with_content(/<logging-configuration href="mylog4j.properties"\/>/). |
| 92 | + with_content(/<ssl-configuration>/). |
| 93 | + with_content(/<keystore-filename>keystore.name<\/keystore-filename>/). |
| 94 | + with_content(/<keystore-password>mypassword<\/keystore-password>/). |
| 95 | + with_content(/<key-password>keypassword<\/key-password>/). |
| 96 | + with_content(/<\/ssl-configuration>/) |
| 97 | + } |
| 98 | + end |
| 99 | + |
| 100 | + end |
| 101 | +end |
0 commit comments