add emails method to GgpKey
This commit is contained in:
parent
fbf1fd1a20
commit
7b7cd6f69d
3 changed files with 20 additions and 0 deletions
|
@ -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
|
||||
|
|
7
spec/factories/gpg_keys.rb
Normal file
7
spec/factories/gpg_keys.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue