Welcome to mirror list, hosted at ThFree Co, Russian Federation.

beyond_identity_spec.rb « integrations « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 29d428b5a03cf68e915ccfbc65c12bee1529a1ea (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Integrations::BeyondIdentity, feature_category: :integrations do
  subject(:integration) { create(:beyond_identity_integration) }

  describe 'validations' do
    context 'when inactive' do
      before do
        integration.active = false
      end

      it { is_expected.not_to validate_presence_of(:token) }
    end

    context 'when active' do
      it { is_expected.to validate_presence_of(:token) }
    end
  end

  describe 'attributes' do
    it 'configures attributes' do
      is_expected.not_to be_inheritable
      expect(integration.supported_events).to be_blank
      expect(integration.to_param).to eq('beyond_identity')
      expect(integration.title).to eq('Beyond Identity')

      expect(integration.description).to eq(
        'Verify that GPG keys are authorized by Beyond Identity Authenticator.'
      )

      expect(integration.help).to include(
        'Verify that GPG keys are authorized by Beyond Identity Authenticator.'
      )
    end
  end

  describe '.api_fields' do
    it 'returns api fields' do
      expect(described_class.api_fields).to eq([{
        required: true,
        name: :token,
        type: String,
        desc: 'API Token. User must have access to `git-commit-signing` endpoint.'
      }])
    end
  end

  describe '#execute' do
    it 'performs a request to beyond identity service' do
      params = { key_id: 'key-id', committer_email: 'email' }
      response = 'response'

      expect_next_instance_of(::Gitlab::BeyondIdentity::Client) do |instance|
        expect(instance).to receive(:execute).with(params).and_return(response)
      end

      expect(integration.execute(params)).to eq(response)
    end
  end
end