Sha256: a9ada5adb5af6c44fcee34dc1a31222c9347bf2863f93c1a08230e8fe59f9f91
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
# (c) Copyright 2018 Ribose Inc. # require "open3" require "tempfile" module RSpec module PGPMatchers module GPGMatcherHelper extend Forwardable def_delegators :"RSpec::PGPMatchers::GPGRunner", :run_verify, :run_decrypt def detect_signers(stderr_str) rx = /(?<ok>Good|BAD) signature from .*\<(?<email>[^>]+)\>/ stderr_str.to_enum(:scan, rx).map do { email: $~["email"], ok: ($~["ok"] == "Good"), } end end def detect_recipients(stderr_str) rx = /encrypted with .*\n.*\<(?<email>[^>]+)\>/ stderr_str.to_enum(:scan, rx).map do $~["email"] end end def match_cleartext(cleartext) if cleartext != expected_cleartext msg_mismatch(cleartext) end end def match_recipients(recipients) if expected_recipients.sort != recipients.sort msg_wrong_recipients(recipients) end end # Checks if signature is valid. If `expected_signer` is not `nil`, then # it additionally checks if the signature was issued by expected signer. def match_signature(signature) if !signature[:ok] msg_mismatch(text) elsif expected_signer && signature[:email] != expected_signer msg_wrong_signer(signature[:email]) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rspec-pgp_matchers-0.1.2 | lib/rspec/pgp_matchers/gpg_matcher_helper.rb |
rspec-pgp_matchers-0.1.1 | lib/rspec/pgp_matchers/gpg_matcher_helper.rb |