File: notify_spec.rb

package info (click to toggle)
puppet 5.5.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 21,316 kB
  • sloc: ruby: 254,925; sh: 1,608; xml: 219; makefile: 153; sql: 103
file content (46 lines) | stat: -rw-r--r-- 1,303 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'spec_helper'
require 'puppet_spec/compiler'

describe Puppet::Type.type(:notify) do
  include PuppetSpec::Compiler

  it "logs the title at notice level" do
    apply_compiled_manifest(<<-MANIFEST)
      notify { 'hi': }
    MANIFEST

    expect(@logs).to include(an_object_having_attributes(level: :notice, message: 'hi'))
  end

  it "logs the message property" do
    apply_compiled_manifest(<<-MANIFEST)
      notify { 'title':
        message => 'hello'
      }
    MANIFEST

    expect(@logs).to include(an_object_having_attributes(level: :notice, message: "defined 'message' as 'hello'"))
  end

  it "redacts sensitive message properties" do
    apply_compiled_manifest(<<-MANIFEST)
      $message = Sensitive('secret')
      notify { 'notify1':
        message => $message
      }
    MANIFEST

    expect(@logs).to include(an_object_having_attributes(level: :notice, message: 'changed [redacted] to [redacted]'))
  end

  it "redacts sensitive interpolated message properties" do
    apply_compiled_manifest(<<-MANIFEST)
      $message = Sensitive('secret')
      notify { 'notify2':
        message => "${message}"
      }
    MANIFEST

    expect(@logs).to include(an_object_having_attributes(level: :notice, message: "defined 'message' as 'Sensitive [value redacted]'"))
  end
end