@@ -333,32 +333,33 @@ class Wibble; end
333333 end
334334
335335 describe '#wrap_sensitive(name, connection_info)' do
336- context 'when the connection info contains a `Sensitive` type' do
337- let ( :schema ) do
338- {
339- name : 'sensitive_transport' ,
340- desc : 'a secret' ,
341- connection_info : {
342- secret : {
343- type : 'String' ,
344- desc : 'A secret to protect.' ,
345- sensitive : true ,
346- } ,
336+ let ( :schema ) do
337+ {
338+ name : 'sensitive_transport' ,
339+ desc : 'a secret' ,
340+ connection_info : {
341+ secret : {
342+ type : 'String' ,
343+ desc : 'A secret to protect.' ,
344+ sensitive : true ,
347345 } ,
348- }
349- end
350- let ( :schema_def ) { instance_double ( 'Puppet::ResourceApi::TransportSchemaDef' , 'schema_def' ) }
346+ } ,
347+ }
348+ end
349+ let ( :schema_def ) { instance_double ( 'Puppet::ResourceApi::TransportSchemaDef' , 'schema_def' ) }
350+
351+ before ( :each ) do
352+ allow ( Puppet ::ResourceApi ::TransportSchemaDef ) . to receive ( :new ) . with ( schema ) . and_return ( schema_def )
353+ described_class . register ( schema )
354+ end
355+
356+ context 'when the connection info contains a `Sensitive` type' do
351357 let ( :connection_info ) do
352358 {
353359 secret : 'sup3r_secret_str1ng' ,
354360 }
355361 end
356362
357- before ( :each ) do
358- allow ( Puppet ::ResourceApi ::TransportSchemaDef ) . to receive ( :new ) . with ( schema ) . and_return ( schema_def )
359- described_class . register ( schema )
360- end
361-
362363 it 'wraps the value in a PSensitiveType' do
363364 allow ( schema_def ) . to receive ( :definition ) . and_return ( schema )
364365
@@ -367,5 +368,16 @@ class Wibble; end
367368 expect ( conn_info [ :secret ] . unwrap ) . to eq ( 'sup3r_secret_str1ng' )
368369 end
369370 end
371+
372+ context 'when the connection info does not contain a `Sensitive` type' do
373+ let ( :connection_info ) { { } }
374+
375+ it 'wraps the value in a PSensitiveType' do
376+ allow ( schema_def ) . to receive ( :definition ) . and_return ( schema )
377+
378+ conn_info = described_class . send :wrap_sensitive , 'sensitive_transport' , connection_info
379+ expect ( conn_info [ :secret ] ) . to be_nil
380+ end
381+ end
370382 end
371383end
0 commit comments