Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
AriaXLi committed Oct 22, 2024
1 parent c8975ba commit 550af99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/functions/regsubst.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def inner_regsubst(target, re, replacement, op)
target.map do |item|
inner_regsubst(item, re, replacement, op)
end
elsif target.respond_to?(:unwrap)
elsif target.is_a?(Puppet::Pops::Types::PSensitiveType::Sensitive)
# this is a Sensitive
target = target.unwrap
target = target.respond_to?(op) ? target.send(op, re, replacement) : target.map { |e| e.send(op, re, replacement) }
Expand Down
8 changes: 6 additions & 2 deletions spec/unit/functions/regsubst_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ def regsubst(*args)

context 'when using a Target of Type sensitive String' do
it 'should process it' do
expect(regsubst(Puppet::Pops::Types::PSensitiveType::Sensitive.new('very secret'), 'very', 'top')).to be_a(Puppet::Pops::Types::PSensitiveType::Sensitive)
result = regsubst(Puppet::Pops::Types::PSensitiveType::Sensitive.new('very secret'), 'very', 'top')
expect(result).to be_a(Puppet::Pops::Types::PSensitiveType::Sensitive)
expect(result.unwrap).to eq("top secret")
end
end

Expand All @@ -123,7 +125,9 @@ def regsubst(*args)
my_array = ['very down', Puppet::Pops::Types::PSensitiveType::Sensitive.new('very secret')]
expect(regsubst(my_array, 'very', 'top')).to be_a(Array)
expect(regsubst(my_array, 'very', 'top')[0]).to eq('top down')
expect(regsubst(my_array, 'very', 'top')[1]).to be_a(Puppet::Pops::Types::PSensitiveType::Sensitive)
result = regsubst(my_array, 'very', 'top')[1]
expect(result).to be_a(Puppet::Pops::Types::PSensitiveType::Sensitive)
expect(result.unwrap).to eq('top secret')
end
end
end

0 comments on commit 550af99

Please sign in to comment.