summaryrefslogtreecommitdiff
path: root/spec/classes
diff options
context:
space:
mode:
authorLouis-Philippe VĂ©ronneau <pollito@riseup.net>2018-03-06 17:29:54 +0000
committerLouis-Philippe VĂ©ronneau <pollito@riseup.net>2018-03-06 17:29:54 +0000
commit7c40929d8a2a9438ccd883e9d856d526b852da8c (patch)
treed8529a383482db6cd716c16074e6b798c1069e7b /spec/classes
parent228ae4a53999dbc49fa7c4d2883468dde10f19fb (diff)
parent6ebebe3ab04e8ba3d4b651e49012646046642160 (diff)
Merge branch 'immerda-merge' into 'master'
Immerda merge Closes #2 See merge request shared-puppet-modules-group/tor!19
Diffstat (limited to 'spec/classes')
-rw-r--r--spec/classes/base_spec.rb44
-rw-r--r--spec/classes/daemon_spec.rb31
-rw-r--r--spec/classes/init_spec.rb27
-rw-r--r--spec/classes/onionbalance_spec.rb60
4 files changed, 162 insertions, 0 deletions
diff --git a/spec/classes/base_spec.rb b/spec/classes/base_spec.rb
new file mode 100644
index 0000000..7f288ec
--- /dev/null
+++ b/spec/classes/base_spec.rb
@@ -0,0 +1,44 @@
+require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper'))
+
+describe 'tor::base', :type => 'class' do
+ let(:default_facts) {
+ {
+ :osfamily => 'RedHat',
+ :operatingsystem => 'CentOS',
+ }
+ }
+ let(:facts){ default_facts }
+ let(:pre_condition){'include ::tor
+ Exec{path => "/bin"}' }
+ describe 'with standard' do
+ it { is_expected.to compile.with_all_deps }
+
+ it { is_expected.to contain_package('tor').with_ensure('installed') }
+ it { is_expected.to_not contain_package('tor-geoipdb').with_ensure('installed') }
+ it { is_expected.to contain_service('tor').with(
+ :ensure => 'running',
+ :enable => 'true',
+ :hasrestart => 'true',
+ :hasstatus => 'true',
+ :require => 'Package[tor]',
+ ) }
+ context 'on Debian' do
+ let(:facts) {
+ {
+ :osfamily => 'Debian',
+ :operatingsystem => 'Debian',
+ }
+ }
+ it { is_expected.to compile.with_all_deps }
+ it { is_expected.to contain_package('tor').with_ensure('installed') }
+ it { is_expected.to contain_package('tor-geoipdb').with_ensure('installed') }
+ it { is_expected.to contain_service('tor').with(
+ :ensure => 'running',
+ :enable => 'true',
+ :hasrestart => 'true',
+ :hasstatus => 'true',
+ :require => 'Package[tor]',
+ ) }
+ end
+ end
+end
diff --git a/spec/classes/daemon_spec.rb b/spec/classes/daemon_spec.rb
new file mode 100644
index 0000000..db5291d
--- /dev/null
+++ b/spec/classes/daemon_spec.rb
@@ -0,0 +1,31 @@
+require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper'))
+
+describe 'tor::daemon', :type => 'class' do
+ let(:default_facts) {
+ {
+ :osfamily => 'RedHat',
+ :operatingsystem => 'CentOS',
+ }
+ }
+ let(:facts){ default_facts }
+ let(:pre_condition){'Exec{path => "/bin"}' }
+ describe 'with standard' do
+ it { is_expected.to compile.with_all_deps }
+
+ it { is_expected.to contain_class('tor') }
+ it { is_expected.to contain_class('tor::daemon::base') }
+ it { is_expected.to_not contain_class('tor::munin') }
+ context 'on Debian' do
+ let(:facts) {
+ {
+ :osfamily => 'Debian',
+ :operatingsystem => 'Debian',
+ }
+ }
+ it { is_expected.to compile.with_all_deps }
+ it { is_expected.to contain_class('tor') }
+ it { is_expected.to contain_class('tor::daemon::base') }
+ it { is_expected.to_not contain_class('tor::munin') }
+ end
+ end
+end
diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb
new file mode 100644
index 0000000..be4f30b
--- /dev/null
+++ b/spec/classes/init_spec.rb
@@ -0,0 +1,27 @@
+require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper'))
+
+describe 'tor', :type => 'class' do
+ let(:default_facts) {
+ {
+ :osfamily => 'RedHat',
+ :operatingsystem => 'CentOS',
+ }
+ }
+ let(:facts){ default_facts }
+ let(:pre_condition){'Exec{path => "/bin"}' }
+ describe 'with standard' do
+ it { is_expected.to compile.with_all_deps }
+
+ it { is_expected.to contain_class('tor::base') }
+ context 'on Debian' do
+ let(:facts) {
+ {
+ :osfamily => 'Debian',
+ :operatingsystem => 'Debian',
+ }
+ }
+ it { is_expected.to compile.with_all_deps }
+ it { is_expected.to contain_class('tor::base') }
+ end
+ end
+end
diff --git a/spec/classes/onionbalance_spec.rb b/spec/classes/onionbalance_spec.rb
new file mode 100644
index 0000000..ff9bb27
--- /dev/null
+++ b/spec/classes/onionbalance_spec.rb
@@ -0,0 +1,60 @@
+require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper'))
+
+describe 'tor::onionbalance', :type => 'class' do
+ let(:default_facts) {
+ {
+ :osfamily => 'RedHat',
+ :operatingsystem => 'CentOS',
+ }
+ }
+ let(:facts){ default_facts }
+ let(:pre_condition){'Exec{path => "/bin"}' }
+ let(:params){
+ {
+ :services => {
+ 'keyname_of_service1' => {
+ 'name1' => 'onionservice_addr_3',
+ 'name2' => 'onionservice_addr_2',
+ '_key_content' => 'content_of_key_of_onionbalanced_service1',
+ },
+ },
+ }
+ }
+ describe 'with standard' do
+ it { is_expected.to compile.with_all_deps }
+
+ it { is_expected.to contain_package('python2-onionbalance').with(
+ :ensure => 'installed',
+ ) }
+ it { is_expected.to contain_service('tor@onionbalance').with(
+ :ensure => 'running',
+ :enable => true,
+ ) }
+ it { is_expected.to contain_service('onionbalance').with(
+ :ensure => 'running',
+ :enable => true,
+ :subscribe => 'Service[tor@onionbalance]',
+ ) }
+ context 'on Debian' do
+ let(:facts) {
+ {
+ :osfamily => 'Debian',
+ :operatingsystem => 'Debian',
+ }
+ }
+ it { is_expected.to compile.with_all_deps }
+ it { is_expected.to contain_package('onionbalance').with(
+ :ensure => 'installed',
+ ) }
+ it { is_expected.to contain_service('tor@onionbalance').with(
+ :ensure => 'running',
+ :enable => true,
+ ) }
+ it { is_expected.to contain_service('onionbalance').with(
+ :ensure => 'running',
+ :enable => true,
+ :subscribe => 'Service[tor@onionbalance]',
+ ) }
+ end
+ end
+end