diff --git a/lib/puppet/functions/eyaml_tools/decrypt.rb b/lib/puppet/functions/eyaml_tools/decrypt.rb index 8e8e6ab..46b38ab 100644 --- a/lib/puppet/functions/eyaml_tools/decrypt.rb +++ b/lib/puppet/functions/eyaml_tools/decrypt.rb @@ -10,7 +10,7 @@ def decrypt(enc_data) EyamlTools.ensure_config parser = Hiera::Backend::Eyaml::Parser::ParserFactory.encrypted_parser - tokens = parser.parse(enc_data) + tokens = parser.parse(enc_data.gsub(/\s/,'')) # strip whitespace from ENC[] token decrypted = tokens.map{ |token| case token.class.name when /::EncToken$/ diff --git a/spec/functions/decrypt_spec.rb b/spec/functions/decrypt_spec.rb index adfa54d..edef2bf 100644 --- a/spec/functions/decrypt_spec.rb +++ b/spec/functions/decrypt_spec.rb @@ -1,6 +1,11 @@ require 'spec_helper' -FOO_ENC = 'ENC[PKCS7,MIIBeQYJKoZIhvcNAQcDoIIBajCCAWYCAQAxggEhMIIBHQIBADAFMAACAQEwDQYJKoZIhvcNAQEBBQAEggEAkHeLWY+nDYcVJcK4e0ASbCO/DgBFXoU4G02J+QqOJpkAQg3CX6KhxzuQyNwLwvqElFdICfxHIXSgO6Pw76taDW8PrTBR5Lmv38Z5mC0aIL9hwOTRlvyyx4fkLM4CFBGVbpVSzFmJ6PEgvaosG2hYjKiColIgcLG4JISRHnPOsveDHaDs3AqpRr4TRJIV2v4skYieJM6cWJ93s+maOUCNDunWXrcQQpIYahj8WrYmqmf4sE1bpqtNqTMicCtGV32IccIieB1Sqzlw6YOtu6/e6NDmUzxNqXRcbIGIXNfrLM/nOpmXepRJ9MhlnGwYQ6C+0CPbNKrfwymSVirgUMpGKDA8BgkqhkiG9w0BBwEwHQYJYIZIAWUDBAEqBBA9Wfkfu+oGYAx2XZGmRdQqgBBcolP8SXZ0l+tPHKg6a3H7]' +# The normal parser can't handle whitepace or newlines but we strip them out so that you can +# add newlines if preferred +FOO_ENC = "ENC[PKCS7,MIIBeQYJKoZIhvcNAQcDoIIBajCCAWYCAQAxggEhMIIBHQIBADAFMAACAQEwDQYJKoZIhvcNAQE +BBQAEggEAkHeLWY+nDYcVJcK4e0ASbCO/DgBFXoU4G02J+QqOJpkAQg3CX6KhxzuQyNwLwvqElFdICfxHIXSgO6Pw76taDW8P +rTBR5Lmv38Z5mC0aIL9hwOTRlvyyx4fkLM4CFBGVbpVSzFmJ6PEgvaosG2hYjKiColIgcLG4JISRHnPOsveDHaDs3AqpRr4TRJIV2v4skYieJM6cWJ93s+maO +UCNDunWXrcQQpIYahj8WrYmqmf4sE1bpqtNqTMicCtGV32IccIieB1Sqzlw6YOtu6/e6NDmUzxNqXRcbIGIXNfrLM/nOpmXepRJ9MhlnGwYQ6C+0CPbNKrfwymSVirgUMpGKDA8BgkqhkiG9w0BBwEwHQYJYIZIAWUDBAEqBBA9Wfkfu+oGYAx2XZGmRdQqgBBcolP8SXZ0l+tPHKg6a3H7]" describe 'eyaml_tools::decrypt' do it { is_expected.to run.with_params(FOO_ENC).and_return('foo') }