summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Lambert <jlambert@eml.cc>2013-01-11 07:08:56 -0700
committerJustin Lambert <jlambert@eml.cc>2013-01-11 07:08:56 -0700
commit2dce9ca4c11ffeb43aaafe7551d3fa098fad75c4 (patch)
tree5a8873cde7fa6e92b05e2af04dae732942124c16
parent48bbd0cd422d57b4f6278d3b64e53aaf5de787cf (diff)
spec tests catching up with code. got commit happy before
-rw-r--r--manifests/config.pp3
-rw-r--r--spec/classes/openvpn_config_spec.rb15
-rw-r--r--spec/classes/openvpn_init_spec.rb11
-rw-r--r--spec/classes/openvpn_install_spec.rb11
-rw-r--r--spec/classes/openvpn_service_spec.rb13
-rw-r--r--spec/defines/openvpn_client_spec.rb105
-rw-r--r--spec/defines/openvpn_server_spec.rb13
7 files changed, 56 insertions, 115 deletions
diff --git a/manifests/config.pp b/manifests/config.pp
index a316cc9..5767d8f 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -14,9 +14,10 @@
# * Justin Lambert <mailto:jlambert@letsevenup.com>
#
class openvpn::config {
- include concat::setup
if $::osfamily == 'Debian' {
+ include concat::setup
+
concat {
'/etc/default/openvpn':
owner => root,
diff --git a/spec/classes/openvpn_config_spec.rb b/spec/classes/openvpn_config_spec.rb
new file mode 100644
index 0000000..bbb63a7
--- /dev/null
+++ b/spec/classes/openvpn_config_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe 'openvpn::config', :type => :class do
+
+ it { should create_class('openvpn::config') }
+
+ context "on Debian based machines" do
+ let (:facts) { { :osfamily => 'Debian', :concat_basedir => '/var/lib/puppet/concat' } }
+
+ it { should contain_class('concat::setup') }
+ it { should contain_concat('/etc/default/openvpn') }
+ it { should contain_concat__fragment('openvpn.default.header') }
+ end
+
+end
diff --git a/spec/classes/openvpn_init_spec.rb b/spec/classes/openvpn_init_spec.rb
index cdfdea1..45dcc9b 100644
--- a/spec/classes/openvpn_init_spec.rb
+++ b/spec/classes/openvpn_init_spec.rb
@@ -5,16 +5,5 @@ describe 'openvpn', :type => :class do
let (:facts) { { :concat_basedir => '/var/lib/puppet/concat' } }
it { should create_class('openvpn') }
- it { should contain_class('concat::setup') }
- it { should contain_package('openvpn') }
- it { should contain_service('openvpn').with(
- 'ensure' => 'running',
- 'enable' => true
- ) }
-
- it { should contain_file('/etc/openvpn').with('ensure' => 'directory') }
- it { should contain_file('/etc/openvpn/keys').with('ensure' => 'directory') }
-
- it { should contain_concat__fragment('openvpn.default.header') }
end
diff --git a/spec/classes/openvpn_install_spec.rb b/spec/classes/openvpn_install_spec.rb
new file mode 100644
index 0000000..cdb3135
--- /dev/null
+++ b/spec/classes/openvpn_install_spec.rb
@@ -0,0 +1,11 @@
+require 'spec_helper'
+
+describe 'openvpn::install', :type => :class do
+
+ it { should create_class('openvpn::install') }
+ it { should contain_package('openvpn') }
+
+ it { should contain_file('/etc/openvpn').with('ensure' => 'directory') }
+ it { should contain_file('/etc/openvpn/keys').with('ensure' => 'directory') }
+
+end
diff --git a/spec/classes/openvpn_service_spec.rb b/spec/classes/openvpn_service_spec.rb
new file mode 100644
index 0000000..f427e7f
--- /dev/null
+++ b/spec/classes/openvpn_service_spec.rb
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+describe 'openvpn::service', :type => :class do
+
+ let (:facts) { { :concat_basedir => '/var/lib/puppet/concat' } }
+
+ it { should create_class('openvpn::service') }
+ it { should contain_service('openvpn').with(
+ 'ensure' => 'running',
+ 'enable' => true
+ ) }
+
+end
diff --git a/spec/defines/openvpn_client_spec.rb b/spec/defines/openvpn_client_spec.rb
index 143b76f..a4b580e 100644
--- a/spec/defines/openvpn_client_spec.rb
+++ b/spec/defines/openvpn_client_spec.rb
@@ -4,6 +4,15 @@ describe 'openvpn::client', :type => :define do
let(:title) { 'test_client' }
let(:params) { { 'server' => 'test_server' } }
let(:facts) { { :fqdn => 'somehost', :concat_basedir => '/var/lib/puppet/concat' } }
+ let(:pre_condition) do
+ 'openvpn::server { "test_server":
+ country => "CO",
+ province => "ST",
+ city => "Some City",
+ organization => "example.org",
+ email => "testemail@example.org"
+ }'
+ end
it { should contain_exec('generate certificate for test_client in context of test_server') }
@@ -53,7 +62,6 @@ describe 'openvpn::client', :type => :define do
'mute' => 10,
'mute_replay_warnings' => false,
'nobind' => false,
- 'ns_cert_type' => 'client',
'persist_key' => false,
'persist_tun' => false,
'port' => '123',
@@ -73,103 +81,8 @@ describe 'openvpn::client', :type => :define do
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^remote\s+somewhere\s+123$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^comp-something$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^resolv-retry\s+2m$/)}
- it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^ns\-cert\-type\s+client$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^verb\s+1$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^mute\s+10$/)}
end
-
-
-
-
-# it { should contain_openvpn__option('ca test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'ca',
-# 'value' => 'keys/ca.crt'
-# )}
-# it { should contain_openvpn__option('cert test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'cert',
-# 'value' => 'keys/test_client.crt'
-# )}
-# it { should contain_openvpn__option('key test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'key',
-# 'value' => 'keys/test_client.key'
-# )}
-# it { should contain_openvpn__option('client test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'client'
-# )}
-# it { should contain_openvpn__option('dev test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'dev',
-# 'value' => 'tun'
-# )}
-# it { should contain_openvpn__option('proto test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'proto',
-# 'value' => 'tcp'
-# )}
-# it { should contain_openvpn__option('remote test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'remote',
-# 'value' => 'somehost 1194'
-# )}
-# it { should contain_openvpn__option('resolv-retry test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'resolv-retry',
-# 'value' => 'infinite'
-# )}
-# it { should contain_openvpn__option('nobind test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'nobind'
-# )}
-# it { should contain_openvpn__option('persist-key test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'persist-key'
-# )}
-# it { should contain_openvpn__option('persist-tun test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'persist-tun'
-# )}
-# it { should contain_openvpn__option('mute-replay-warnings test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'mute-replay-warnings'
-# )}
-# it { should contain_openvpn__option('ns-cert-type test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'ns-cert-type',
-# 'value' => 'server'
-# )}
-# it { should contain_openvpn__option('comp-lzo test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'comp-lzo'
-# )}
-# it { should contain_openvpn__option('verb test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'verb',
-# 'value' => '3'
-# )}
-# it { should contain_openvpn__option('mute test_server with test_client').with(
-# 'server' => 'test_server',
-# 'client' => 'test_client',
-# 'key' => 'mute',
-# 'value' => '20'
-# )}
end
diff --git a/spec/defines/openvpn_server_spec.rb b/spec/defines/openvpn_server_spec.rb
index 85dadf2..b48c738 100644
--- a/spec/defines/openvpn_server_spec.rb
+++ b/spec/defines/openvpn_server_spec.rb
@@ -38,12 +38,6 @@ 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') }
-
- # Configure to start vpn session
- it { should contain_concat__fragment('openvpn.default.autostart.test_server').with(
- 'content' => "AUTOSTART=\"$AUTOSTART test_server\"\n",
- 'target' => '/etc/default/openvpn'
- )}
# VPN server config file itself
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^mode\s+server$/) }
@@ -61,7 +55,6 @@ describe 'openvpn::server', :type => :define do
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^status\s+test_server\/openvpn\-status\.log$/) }
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$/) }
- it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^server\s+1\.2\.3\.0\s+255\.255\.255\.0$/) }
end
context "creating a server setting all parameters" do
@@ -153,6 +146,12 @@ describe 'openvpn::server', :type => :define do
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",
+ 'target' => '/etc/default/openvpn'
+ )}
end