class Object
Public Instance Methods
analyse_decrypt_output(stdout_str, stderr_str, status)
click to toggle source
# File lib/rspec/pgp_matchers/be_a_pgp_encrypted_message.rb, line 56 def analyse_decrypt_output(stdout_str, stderr_str, status) { well_formed_pgp_data: (status.exitstatus != 2), recipients: detect_recipients(stderr_str), signature: detect_signers(stderr_str).first, cleartext: stdout_str, } end
analyse_verify_output(_stdout_str, stderr_str, status)
click to toggle source
# File lib/rspec/pgp_matchers/be_a_valid_pgp_signature_of.rb, line 50 def analyse_verify_output(_stdout_str, stderr_str, status) { well_formed_pgp_data: (status.exitstatus != 2), signature: detect_signers(stderr_str).first, } end
match_constraints(cleartext:, recipients:, signature:, **_ignored)
click to toggle source
# File lib/rspec/pgp_matchers/be_a_pgp_encrypted_message.rb, line 65 def match_constraints(cleartext:, recipients:, signature:, **_ignored) [ (expected_cleartext && match_cleartext(cleartext)), (expected_recipients && match_recipients(recipients)), (expected_signer && match_signature(signature)), ].detect { |x| x } end
msg_mismatch(text)
click to toggle source
# File lib/rspec/pgp_matchers/be_a_pgp_encrypted_message.rb, line 73 def msg_mismatch(text) "expected given Open PGP message to contain following " + "text:\n#{expected_cleartext}\nbut was:\n#{text}" end
msg_no_pgg_data(file_text)
click to toggle source
# File lib/rspec/pgp_matchers/be_a_pgp_encrypted_message.rb, line 78 def msg_no_pgg_data(file_text) "expected given text to be a valid Open PGP encrypted message, " + "but it contains no PGP data, just:\n#{file_text}" end
msg_wrong_recipients(recipients)
click to toggle source
# File lib/rspec/pgp_matchers/be_a_pgp_encrypted_message.rb, line 83 def msg_wrong_recipients(recipients) expected_recipients_list = expected_recipients.inspect recipients_list = recipients.inspect "expected given Open PGP message to be encrypted for following " + "recipients: #{expected_recipients_list}, but was for: #{recipients_list}" end
msg_wrong_signer(actual_signer)
click to toggle source
# File lib/rspec/pgp_matchers/be_a_pgp_encrypted_message.rb, line 91 def msg_wrong_signer(actual_signer) "expected singature to be signed by #{expected_signer}, " + "but was actually signed by #{actual_signer}" end
validate_encrypted_message(encrypted_string)
click to toggle source
Returns nil
if signature is valid, or an error message otherwise.
# File lib/rspec/pgp_matchers/be_a_pgp_encrypted_message.rb, line 45 def validate_encrypted_message(encrypted_string) cmd_output = run_decrypt(encrypted_string) cmd_result = analyse_decrypt_output(*cmd_output) if cmd_result[:well_formed_pgp_data] match_constraints(**cmd_result) else msg_no_pgg_data(encrypted_string) end end
verify_signature(cleartext, signature_string)
click to toggle source
Returns nil
if first signature is valid, or an error message otherwise.
# File lib/rspec/pgp_matchers/be_a_valid_pgp_signature_of.rb, line 39 def verify_signature(cleartext, signature_string) cmd_output = run_verify(cleartext, signature_string) cmd_result = analyse_verify_output(*cmd_output) if cmd_result[:well_formed_pgp_data] match_constraints(**cmd_result) else msg_no_pgg_data(signature_string) end end