summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/gpg_spec.rb
blob: 55f34e0cf99a236cfc2465b3fbea3fb296680f4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'rails_helper'

describe Gitlab::Gpg do
  describe '.fingerprints_from_key' do
    it 'returns the fingerprint' do
      expect(
        described_class.fingerprints_from_key(GpgHelpers::User1.public_key)
      ).to eq [GpgHelpers::User1.fingerprint]
    end

    it 'returns an empty array when the key is invalid' do
      expect(
        described_class.fingerprints_from_key('bogus')
      ).to eq []
    end
  end

  describe '.primary_keyids_from_key' do
    it 'returns the keyid' do
      expect(
        described_class.primary_keyids_from_key(GpgHelpers::User1.public_key)
      ).to eq [GpgHelpers::User1.primary_keyid]
    end

    it 'returns an empty array when the key is invalid' do
      expect(
        described_class.primary_keyids_from_key('bogus')
      ).to eq []
    end
  end

  describe '.emails_from_key' do
    it 'returns the emails' do
      expect(
        described_class.emails_from_key(GpgHelpers::User1.public_key)
      ).to eq GpgHelpers::User1.emails
    end

    it 'returns an empty array when the key is invalid' do
      expect(
        described_class.emails_from_key('bogus')
      ).to eq []
    end
  end
end