Newer
Older
puppet-interfaces / spec / defines / iface_spec.rb
  1. require 'spec_helper'
  2.  
  3. describe 'interfaces::iface' do
  4. let(:title) { 'lo' }
  5. let(:params) { { :family => 'inet', :method => 'loopback', :auto => 1 } }
  6.  
  7. it {
  8. should_not contain_interfaces__allow('lo').with_subsystem('hotplug')
  9. should contain_interfaces__auto('lo')
  10. should contain_concat__fragment('interfaces::iface_lo').with_target('/etc/network/interfaces')
  11. should contain_concat__fragment('interfaces::iface_lo').with_content("iface lo inet loopback\n\t\n\n")
  12. }
  13. end
  14.  
  15. describe 'interfaces::iface' do
  16. let(:title) { 'eth0' }
  17. let(:params) { { :family => 'inet', :method => 'dhcp' } }
  18.  
  19. it {
  20. should_not contain_interfaces__auto('eth0')
  21. should_not contain_interfaces__allow('eth0').with_subsystem('hotplug')
  22. should contain_concat__fragment('interfaces::iface_eth0').with_target('/etc/network/interfaces')
  23. should contain_concat__fragment('interfaces::iface_eth0').with_content("iface eth0 inet dhcp\n\t\n\n")
  24. }
  25. end
  26.  
  27. describe 'interfaces::iface' do
  28. let(:title) { 'eth0' }
  29. let(:params) { { :family => 'inet', :method => 'dhcp', :auto => 1, :allow_hotplug => 1 } }
  30.  
  31. it {
  32. should contain_interfaces__auto('eth0')
  33. should contain_interfaces__allow('eth0').with_subsystem('hotplug')
  34. should contain_concat__fragment('interfaces::iface_eth0').with_target('/etc/network/interfaces')
  35. should contain_concat__fragment('interfaces::iface_eth0').with_content("iface eth0 inet dhcp\n\t\n\n")
  36. }
  37. end
  38.  
  39. describe 'interfaces::iface' do
  40. let(:title) { 'eth0' }
  41. let(:params) { { :family => 'inet', :method => 'dhcp', :auto => 1 } }
  42.  
  43. it {
  44. should contain_interfaces__auto('eth0')
  45. should_not contain_interfaces__allow('eth0').with_subsystem('hotplug')
  46. should contain_concat__fragment('interfaces::iface_eth0').with_target('/etc/network/interfaces')
  47. should contain_concat__fragment('interfaces::iface_eth0').with_content("iface eth0 inet dhcp\n\t\n\n")
  48. }
  49. end
  50.  
  51. describe 'interfaces::iface' do
  52. let(:title) { 'eth0' }
  53. let(:params) { { :family => 'inet', :method => 'static', :options => ['address 192.0.2.1','netmask 255.255.255.0','gateway 192.0.2.2'], :auto => 1, :allow_hotplug => 1 } }
  54.  
  55. it {
  56. should contain_interfaces__auto('eth0')
  57. should contain_interfaces__allow('eth0').with_subsystem('hotplug')
  58. should contain_concat__fragment('interfaces::iface_eth0').with_target('/etc/network/interfaces')
  59. should contain_concat__fragment('interfaces::iface_eth0').with_content("iface eth0 inet static\n\taddress 192.0.2.1\n\tnetmask 255.255.255.0\n\tgateway 192.0.2.2\n\n")
  60. }
  61. end
  62.  
  63. describe 'interfaces::iface' do
  64. let(:title) { 'eth0.123' }
  65. let(:params) { { :family => 'inet', :method => 'dhcp', :options => ['vlan_raw_device eth0'], :auto => 1 } }
  66.  
  67. it {
  68. should contain_interfaces__auto('eth0.123')
  69. should_not contain_interfaces__allow('eth0.123').with_subsystem('hotplug')
  70. should contain_concat__fragment('interfaces::iface_eth0.123').with_target('/etc/network/interfaces')
  71. should contain_concat__fragment('interfaces::iface_eth0.123').with_content("iface eth0.123 inet dhcp\n\tvlan_raw_device eth0\n\n")
  72. }
  73. end
  74.  
  75. describe 'interfaces::iface' do
  76. let(:title) { 'eth0' }
  77. let(:params) { { :family => 'inet6', :method => 'static', :options => ['address 2001:db8::1','netmask 64'] } }
  78.  
  79. it {
  80. should_not contain_interfaces__auto('eth0')
  81. should_not contain_interfaces__allow('eth0').with_subsystem('hotplug')
  82. should contain_concat__fragment('interfaces::iface_eth0').with_target('/etc/network/interfaces')
  83. should contain_concat__fragment('interfaces::iface_eth0').with_content("iface eth0 inet6 static\n\taddress 2001:db8::1\n\tnetmask 64\n\n")
  84. }
  85. end
  86.  
  87. describe 'interfaces::iface' do
  88. let(:title) { 'eth0v6' }
  89. let(:params) { { :ifname => 'eth0', :family => 'inet6', :method => 'static', :options => ['address 2001:db8::1','netmask 64'], :auto => 1, :allow_hotplug => 1 } }
  90.  
  91. it {
  92. should contain_interfaces__auto('eth0')
  93. should contain_interfaces__allow('eth0').with_subsystem('hotplug')
  94. should contain_concat__fragment('interfaces::iface_eth0v6').with_target('/etc/network/interfaces')
  95. should contain_concat__fragment('interfaces::iface_eth0v6').with_content("iface eth0 inet6 static\n\taddress 2001:db8::1\n\tnetmask 64\n\n")
  96. }
  97. end
  98.  
  99. describe 'interfaces::iface' do
  100. let(:title) { 'eth0' }
  101. let(:params) { { :ifname => 'eth0', :family => 'foobar', :method => 'foobar' } }
  102.  
  103. it {
  104. expect {
  105. should contain_concat__fragment('interfaces::iface_eth0').with_target('/etc/network/interfaces')
  106. }.to raise_error(Puppet::Error, /family parameter must be one of inet, inet6 or ipx/)
  107. }
  108. end
  109.  
  110. describe 'interfaces::iface' do
  111. let(:title) { 'eth0' }
  112. let(:params) { { :ifname => 'eth0', :family => 'inet6', :method => 'foobar' } }
  113.  
  114. it {
  115. expect {
  116. should contain_concat__fragment('interfaces::iface_eth0').with_target('/etc/network/interfaces')
  117. }.to raise_error(Puppet::Error, /method parameter must be one of loopback, static, manual or v4tunnel for family inet6/)
  118. }
  119. end
  120.  
  121. describe 'interfaces::iface' do
  122. let(:title) { 'eth0' }
  123. let(:params) { { :ifname => 'eth0', :family => 'ipx', :method => 'foobar' } }
  124.  
  125. it {
  126. expect {
  127. should contain_concat__fragment('interfaces::iface_eth0').with_target('/etc/network/interfaces')
  128. }.to raise_error(Puppet::Error, /method parameter must be static or dynamic for family ipx/)
  129. }
  130. end
  131.  
  132. describe 'interfaces::iface' do
  133. let(:title) { 'eth0' }
  134. let(:params) { { :ifname => 'eth0', :family => 'inet', :method => 'foobar' } }
  135.  
  136. it {
  137. expect {
  138. should contain_concat__fragment('interfaces::iface_eth0').with_target('/etc/network/interfaces')
  139. }.to raise_error(Puppet::Error, /method parameter must be one of loopback, static, manual, dhcp, bootp, ppp or wvdial for family inet/)
  140. }
  141. end