From 9f225bb669c52351edfe6f340e845e43764b15be Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Tue, 6 Aug 2024 09:14:44 +0200 Subject: [PATCH] Regression test for conditions with regex chars --- .../provider/sshd_config_match/augeas_spec.rb | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/spec/unit/puppet/provider/sshd_config_match/augeas_spec.rb b/spec/unit/puppet/provider/sshd_config_match/augeas_spec.rb index 7fd4dee..6ee1982 100644 --- a/spec/unit/puppet/provider/sshd_config_match/augeas_spec.rb +++ b/spec/unit/puppet/provider/sshd_config_match/augeas_spec.rb @@ -42,6 +42,38 @@ end end + context 'with condition containing regex chars' do + let(:tmptarget) { aug_fixture('empty') } + let(:target) { tmptarget.path } + + it 'creates simple new entry' do + apply!(Puppet::Type.type(:sshd_config_match).new( + name: 'Host *', + target: target, + ensure: :present, + provider: 'augeas' + )) + + aug_open(target, 'Sshd.lns') do |aug| + expect(aug.get('Match/Condition/Host')).to eq('*') + end + end + + it 'creates new comment before entry' do + apply!(Puppet::Type.type(:sshd_config_match).new( + name: 'Host *', + target: target, + ensure: :present, + comment: 'manage host *', + provider: 'augeas' + )) + + aug_open(target, 'Sshd.lns') do |aug| + expect(aug.get('Match[Condition/Host]/Settings/#comment')).to eq('Host *: manage host *') + end + end + end + context 'with full file' do let(:tmptarget) { aug_fixture('full') } let(:target) { tmptarget.path }