@@ -218,16 +218,16 @@ class { 'apache':
218218 end
219219
220220 describe file ( "#{ $vhost_dir} /25-example.com.conf" ) do
221- it { is_expected . to contain '<VirtualHost 127.0.0.1:80 ::1:80>' }
221+ it { is_expected . to contain '<VirtualHost 127.0.0.1:80 [ ::1] :80>' }
222222 it { is_expected . to contain "ServerName example.com" }
223223 end
224224
225225 describe file ( $ports_file) do
226226 it { is_expected . to be_file }
227227 it { is_expected . to contain 'Listen 127.0.0.1:80' }
228- it { is_expected . to contain 'Listen ::1:80' }
228+ it { is_expected . to contain 'Listen [ ::1] :80' }
229229 it { is_expected . not_to contain 'NameVirtualHost 127.0.0.1:80' }
230- it { is_expected . not_to contain 'NameVirtualHost ::1:80' }
230+ it { is_expected . not_to contain 'NameVirtualHost [ ::1] :80' }
231231 end
232232
233233 it 'should answer to ipv4.example.com' do
@@ -243,6 +243,50 @@ class { 'apache':
243243 end
244244 end
245245
246+ context 'new vhost with IPv6 address on port 80' do
247+ it 'should configure one apache vhost with an ipv6 address' do
248+ pp = <<-EOS
249+ class { 'apache':
250+ default_vhost => false,
251+ }
252+ apache::vhost { 'example.com':
253+ port => '80',
254+ ip => '::1',
255+ ip_based => true,
256+ docroot => '/var/www/html',
257+ }
258+ host { 'ipv6.example.com': ip => '::1', }
259+ file { '/var/www/html/index.html':
260+ ensure => file,
261+ content => "Hello from vhost\\ n",
262+ }
263+ EOS
264+ apply_manifest ( pp , :catch_failures => true )
265+ end
266+
267+ describe service ( $service_name) do
268+ it { is_expected . to be_enabled }
269+ it { is_expected . to be_running }
270+ end
271+
272+ describe file ( "#{ $vhost_dir} /25-example.com.conf" ) do
273+ it { is_expected . to contain '<VirtualHost [::1]:80>' }
274+ it { is_expected . to contain "ServerName example.com" }
275+ end
276+
277+ describe file ( $ports_file) do
278+ it { is_expected . to be_file }
279+ it { is_expected . to contain 'Listen [::1]:80' }
280+ it { is_expected . not_to contain 'NameVirtualHost [::1]:80' }
281+ end
282+
283+ it 'should answer to ipv6.example.com' do
284+ shell ( "/usr/bin/curl ipv6.example.com:80" , { :acceptable_exit_codes => 0 } ) do |r |
285+ expect ( r . stdout ) . to eq ( "Hello from vhost\n " )
286+ end
287+ end
288+ end
289+
246290 context 'apache_directories' do
247291 describe 'readme example, adapted' do
248292 it 'should configure a vhost with Files' do
0 commit comments