Sha256: 041550688e4d0d41e7ecd069923d6baa8ee9e15341821c0fd8a6c8f6cd658794

Contents?: true

Size: 1.05 KB

Versions: 136

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

require 'puppet_spec/compiler'
require 'matchers/resource'

describe 'the unwrap function' do
  include PuppetSpec::Compiler
  include Matchers::Resource

  it 'unwraps a sensitive value' do
    code = <<-CODE
      $sensitive = Sensitive.new("12345")
      notice("unwrapped value is ${sensitive.unwrap}")
    CODE
    expect(eval_and_collect_notices(code)).to eq(['unwrapped value is 12345'])
  end

  it 'just returns a non-sensitive value' do
    code = <<-CODE
      $non_sensitive = "12345"
      notice("value is still ${non_sensitive.unwrap}")
    CODE
    expect(eval_and_collect_notices(code)).to eq(['value is still 12345'])
  end

  it 'unwraps a sensitive value when given a code block' do
    code = <<-CODE
      $sensitive = Sensitive.new("12345")
      $split = $sensitive.unwrap |$unwrapped| {
        notice("unwrapped value is $unwrapped")
        $unwrapped.split(/3/)
      }
      notice("split is $split")
    CODE
    expect(eval_and_collect_notices(code)).to eq(['unwrapped value is 12345', 'split is [12, 45]'])
  end
end

Version data entries

136 entries across 136 versions & 1 rubygems

Version Path
puppet-8.3.0 spec/unit/functions/unwrap_spec.rb
puppet-8.3.0-x86-mingw32 spec/unit/functions/unwrap_spec.rb
puppet-8.3.0-x64-mingw32 spec/unit/functions/unwrap_spec.rb
puppet-8.3.0-universal-darwin spec/unit/functions/unwrap_spec.rb
puppet-8.4.0 spec/unit/functions/unwrap_spec.rb
puppet-8.4.0-x86-mingw32 spec/unit/functions/unwrap_spec.rb
puppet-8.4.0-x64-mingw32 spec/unit/functions/unwrap_spec.rb
puppet-8.4.0-universal-darwin spec/unit/functions/unwrap_spec.rb
puppet-7.28.0 spec/unit/functions/unwrap_spec.rb
puppet-7.28.0-x86-mingw32 spec/unit/functions/unwrap_spec.rb
puppet-7.28.0-x64-mingw32 spec/unit/functions/unwrap_spec.rb
puppet-7.28.0-universal-darwin spec/unit/functions/unwrap_spec.rb
puppet-8.3.1 spec/unit/functions/unwrap_spec.rb
puppet-8.3.1-x86-mingw32 spec/unit/functions/unwrap_spec.rb
puppet-8.3.1-x64-mingw32 spec/unit/functions/unwrap_spec.rb
puppet-8.3.1-universal-darwin spec/unit/functions/unwrap_spec.rb
puppet-7.27.0 spec/unit/functions/unwrap_spec.rb
puppet-7.27.0-x86-mingw32 spec/unit/functions/unwrap_spec.rb
puppet-7.27.0-x64-mingw32 spec/unit/functions/unwrap_spec.rb
puppet-7.27.0-universal-darwin spec/unit/functions/unwrap_spec.rb