Skip to content

Commit

Permalink
Allow whitespace in encrypted form
Browse files Browse the repository at this point in the history
  • Loading branch information
halfninja committed Sep 1, 2016
1 parent e3e0e8b commit 3cfc0f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/functions/eyaml_tools/decrypt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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$/
Expand Down
7 changes: 6 additions & 1 deletion spec/functions/decrypt_spec.rb
Original file line number Diff line number Diff line change
@@ -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') }
Expand Down

0 comments on commit 3cfc0f0

Please sign in to comment.