summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/defines/openvpn_server_spec.rb48
1 files changed, 24 insertions, 24 deletions
diff --git a/spec/defines/openvpn_server_spec.rb b/spec/defines/openvpn_server_spec.rb
index b48c738..f9c4780 100644
--- a/spec/defines/openvpn_server_spec.rb
+++ b/spec/defines/openvpn_server_spec.rb
@@ -1,9 +1,9 @@
require 'spec_helper'
-
+
describe 'openvpn::server', :type => :define do
-
+
let(:title) { 'test_server' }
-
+
context "creating a server with the minimum parameters" do
let(:params) { {
'country' => 'CO',
@@ -13,13 +13,13 @@ describe 'openvpn::server', :type => :define do
'email' => 'testemail@example.org'
} }
- let (:facts) { {
- :ipaddress_eth0 => '1.2.3.4',
+ let (:facts) { {
+ :ipaddress_eth0 => '1.2.3.4',
:network_eth0 => '1.2.3.0',
:netmask_eth0 => '255.255.255.0',
- :concat_basedir => '/var/lib/puppet/concat'
+ :concat_basedir => '/var/lib/puppet/concat'
} }
-
+
# Files associated with a server config
it { should contain_file('/etc/openvpn/test_server').with('ensure' => 'directory')}
it { should contain_file('/etc/openvpn/test_server/client-configs').with('ensure' => 'directory')}
@@ -30,7 +30,7 @@ describe 'openvpn::server', :type => :define do
'ensure' => 'link',
'target' => '/etc/openvpn/test_server/easy-rsa/keys'
)}
-
+
# Execs to working with certificates
it { should contain_exec('copy easy-rsa to openvpn config folder test_server').with(
'command' => '/bin/cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0 /etc/openvpn/test_server/easy-rsa'
@@ -38,7 +38,7 @@ describe 'openvpn::server', :type => :define do
it { should contain_exec('generate dh param test_server') }
it { should contain_exec('initca test_server') }
it { should contain_exec('generate server cert test_server') }
-
+
# VPN server config file itself
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^mode\s+server$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^client\-config\-dir\s+\/etc\/openvpn\/test_server\/client\-configs$/) }
@@ -56,7 +56,7 @@ describe 'openvpn::server', :type => :define do
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^dev\s+tun0$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^local\s+1\.2\.3\.4$/) }
end
-
+
context "creating a server setting all parameters" do
let(:params) { {
'country' => 'CO',
@@ -78,13 +78,13 @@ describe 'openvpn::server', :type => :define do
'push' => [ 'dhcp-option DNS 172.31.0.30', 'route 172.31.0.0 255.255.0.0' ]
} }
- let (:facts) { {
- :ipaddress_eth0 => '1.2.3.4',
+ let (:facts) { {
+ :ipaddress_eth0 => '1.2.3.4',
:network_eth0 => '1.2.3.0',
:netmask_eth0 => '255.255.255.0',
- :concat_basedir => '/var/lib/puppet/concat'
+ :concat_basedir => '/var/lib/puppet/concat'
} }
-
+
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^mode\s+server$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^client\-config\-dir\s+\/etc\/openvpn\/test_server\/client\-configs$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^ca\s+\/etc\/openvpn\/test_server\/keys\/ca.crt$/) }
@@ -113,21 +113,21 @@ describe 'openvpn::server', :type => :define do
'organization' => 'example.org',
'email' => 'testemail@example.org'
} }
-
+
let(:facts) { { :osfamily => 'RedHat', :concat_basedir => '/var/lib/puppet/concat' } }
-
+
it { should contain_file('/etc/openvpn/test_server/easy-rsa/openssl.cnf').with(
'ensure' => 'link',
'target' => '/etc/openvpn/test_server/easy-rsa/openssl-1.0.0.cnf'
)}
-
+
it { should contain_exec('copy easy-rsa to openvpn config folder test_server').with(
'command' => '/bin/cp -r /usr/share/doc/openvpn-2.2.2/easy-rsa/2.0 /etc/openvpn/test_server/easy-rsa'
)}
-
+
end
-
- context "when Debian based machine" do
+
+ context "when Debian based machine" do
let(:params) { {
'country' => 'CO',
'province' => 'ST',
@@ -135,18 +135,18 @@ describe 'openvpn::server', :type => :define do
'organization' => 'example.org',
'email' => 'testemail@example.org'
} }
-
+
let(:facts) { { :osfamily => 'Debian', :concat_basedir => '/var/lib/puppet/concat' } }
it { should contain_file('/etc/openvpn/test_server/easy-rsa/openssl.cnf').with(
'ensure' => 'link',
'target' => '/etc/openvpn/test_server/easy-rsa/openssl-1.0.0.cnf'
)}
-
+
it { should contain_exec('copy easy-rsa to openvpn config folder test_server').with(
'command' => '/bin/cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0 /etc/openvpn/test_server/easy-rsa'
)}
-
+
# Configure to start vpn session
it { should contain_concat__fragment('openvpn.default.autostart.test_server').with(
'content' => "AUTOSTART=\"$AUTOSTART test_server\"\n",
@@ -154,5 +154,5 @@ describe 'openvpn::server', :type => :define do
)}
end
-
+
end