Skip to content

Commit

Permalink
Merge pull request #34 from voxpupuli/modulesync
Browse files Browse the repository at this point in the history
modulesync 5.0.0
  • Loading branch information
bastelfreak authored Oct 31, 2021
2 parents 2be7dd6 + ede1cfe commit c1ce989
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

modulesync_config_version: '4.2.0'
modulesync_config_version: '5.0.1'
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"

group :test do
gem 'voxpupuli-test', '~> 2.5', :require => false
gem 'voxpupuli-test', '~> 4.0', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'puppet_metadata', '~> 1.0', :require => false
Expand All @@ -22,7 +22,7 @@ end

group :release do
gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5'
gem 'voxpupuli-release', '>= 1.0.2', :require => false
gem 'voxpupuli-release', '>= 1.2.0', :require => false
gem 'puppet-strings', '>= 2.2', :require => false
end

Expand Down
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,4 @@ begin

rescue LoadError
end

# vim: syntax=ruby
2 changes: 2 additions & 0 deletions lib/facter/wireguard_pubkeys.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Facter.add(:wireguard_pubkeys) do
confine do
File.directory?('/etc/wireguard/')
Expand Down
4 changes: 3 additions & 1 deletion spec/classes/wireguard_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'wireguard' do
Expand All @@ -6,7 +8,7 @@
end

on_supported_os.each do |os, facts|
context "on #{os} " do
context "on #{os}" do
let :facts do
facts
end
Expand Down
15 changes: 13 additions & 2 deletions spec/defines/interface_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'wireguard::interface', type: :define do
let(:title) { 'as1234' }

on_supported_os.each do |os, facts|
context "on #{os} " do
context "on #{os}" do
let :facts do
facts
end

context 'with all defaults it wont work' do
it { is_expected.not_to compile }
end

context 'with required params (public_key) and without firewall rules' do
let :params do
{
Expand Down Expand Up @@ -40,6 +43,7 @@
it { is_expected.to contain_file("/etc/systemd/network/#{title}.network").without_content(%r{MTUBytes}) }
it { is_expected.not_to contain_ferm__rule("allow_wg_#{title}") }
end

context 'with required params (peers) and without firewall rules' do
let :params do
{
Expand Down Expand Up @@ -80,6 +84,7 @@
it { is_expected.to contain_file("/etc/systemd/network/#{title}.network").with_content(expected_network_content) }
it { is_expected.not_to contain_ferm__rule("allow_wg_#{title}") }
end

context 'with required params and with firewall rules' do
# we need to set configfile/configdirectory because the ferm module doesn't provide defaults for all OSes we test against
let :pre_condition do
Expand Down Expand Up @@ -112,6 +117,7 @@ class {"systemd":
it { is_expected.to contain_file("/etc/systemd/network/#{title}.network").without_content(%r{Address}) }
it { is_expected.to contain_ferm__rule("allow_wg_#{title}") }
end

context 'with required params and without firewall rules and with configured addresses' do
let :params do
{
Expand All @@ -132,12 +138,13 @@ class {"systemd":
it { is_expected.to contain_file("/etc/wireguard/#{title}") }
it { is_expected.to contain_systemd__network("#{title}.netdev") }
it { is_expected.to contain_systemd__network("#{title}.network") }
it { is_expected.to contain_file("/etc/systemd/network/#{title}.network").with_content(%r{[Address]}) }
it { is_expected.to contain_file("/etc/systemd/network/#{title}.network").with_content(%r{[Address]}) } # rubocop:disable Lint/DuplicateRegexpCharacterClassElement
it { is_expected.to contain_file("/etc/systemd/network/#{title}.network").with_content(%r{Address=192.168.218.87/32}) }
it { is_expected.to contain_file("/etc/systemd/network/#{title}.network").with_content(%r{Peer=172.20.53.97/32}) }
it { is_expected.to contain_file("/etc/systemd/network/#{title}.network").with_content(%r{Address=fe80::ade1/64}) }
it { is_expected.not_to contain_ferm__rule("allow_wg_#{title}") }
end

context 'with empty destintion_addresses' do
let :pre_condition do
'class{"ferm":
Expand All @@ -160,6 +167,7 @@ class {"systemd":
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_ferm__rule("allow_wg_#{title}").without_daddr }
end

context 'with description' do
let :params do
{
Expand All @@ -176,6 +184,7 @@ class {"systemd":
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file("/etc/systemd/network/#{title}.netdev").with_content(%r{Description=bla}) }
end

context 'with MTU' do
let :params do
{
Expand All @@ -192,6 +201,7 @@ class {"systemd":
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file("/etc/systemd/network/#{title}.netdev").with_content(%r{MTUBytes=9000}) }
end

context 'with too high MTU' do
let :params do
{
Expand All @@ -207,6 +217,7 @@ class {"systemd":

it { is_expected.not_to compile.with_all_deps }
end

context 'with MTU as string' do
let :params do
{
Expand Down
10 changes: 5 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# frozen_string_literal: true

# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

# puppetlabs_spec_helper will set up coverage if the env variable is set.
# We want to do this if lib exists and it hasn't been explicitly set.
ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__))
ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__))

require 'voxpupuli/test/spec_helper'

if File.exist?(File.join(__dir__, 'default_module_facts.yml'))
facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml')))
if facts
facts.each do |name, value|
add_custom_fact name.to_sym, value
end
facts&.each do |name, value|
add_custom_fact name.to_sym, value
end
end

0 comments on commit c1ce989

Please sign in to comment.