BigW Consortium Gitlab

Commit 7b7cd6f6 by Alexis Reigel

add emails method to GgpKey

parent fbf1fd1a
......@@ -21,6 +21,11 @@ class GpgKey < ActiveRecord::Base
write_attribute(:key, value)
end
def emails
raw_key = GPGME::Key.get(fingerprint)
raw_key.uids.map(&:email)
end
private
def extract_fingerprint
......
require_relative '../support/gpg_helpers'
FactoryGirl.define do
factory :gpg_key do
key GpgHelpers.public_key
end
end
......@@ -38,4 +38,12 @@ describe GpgKey do
expect(described_class.new(key: " #{key} ").key).to eq(key)
end
end
describe '#emails' do
it 'returns the emails from the gpg key' do
gpg_key = create :gpg_key
expect(gpg_key.emails).to match_array %w(mail@koffeinfrei.org lex@panter.ch)
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment