File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
spec/unit/puppet/provider/iis_application_pool Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -382,6 +382,14 @@ module uses the token to impersonate the built-in account. When
382382 files, this uses AppCmd.exe. This encrypts the password automatically
383383 before it is written to the XML configuration files. This provides
384384 better password security than storing unencrypted passwords."
385+
386+ def should_to_s ( _value )
387+ '[redacted sensitive information]'
388+ end
389+
390+ def is_to_s ( _value ) # rubocop:disable Naming/PredicateName
391+ '[redacted sensitive information]'
392+ end
385393 end
386394
387395 newproperty ( :orphan_action_exe , parent : PuppetX ::PuppetLabs ::IIS ::Property ::String ) do
Original file line number Diff line number Diff line change 3333 expect ( provider_class . new ) . to respond_to ( method )
3434 end
3535 end
36+
37+ describe '#update' do
38+ let ( :resource ) do
39+ Puppet ::Type . type ( :iis_application_pool ) . new (
40+ name : 'iis_application_pool' ,
41+ password : 'Sup3r$ecret!' ,
42+ )
43+ end
44+ let ( :provider ) { described_class . new ( resource ) }
45+
46+ it 'passes the password directly in the PowerShell command' do
47+ expect ( described_class ) . to receive ( :run )
48+ . with ( a_string_including ( 'processModel.password' , 'Sup3r$ecret!' ) )
49+ . and_return ( { exitcode : 0 , errormessage : '' } )
50+
51+ provider . update
52+ end
53+
54+ it 'redacts password in Puppet logs' do
55+ prop = resource . property ( :password )
56+ expect ( prop . should_to_s ( 'Sup3r$ecret!' ) ) . to eq ( '[redacted sensitive information]' )
57+ expect ( prop . is_to_s ( 'Sup3r$ecret!' ) ) . to eq ( '[redacted sensitive information]' )
58+ end
59+ end
3660end
You can’t perform that action at this time.
0 commit comments