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

config_spec.rb « saml « auth « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2ecc26f9b9641dd8582308ea3f20b23f908f86c1 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Auth::Saml::Config do
  include LoginHelpers

  describe '.enabled?' do
    subject { described_class.enabled? }

    it { is_expected.to eq(false) }

    context 'when SAML is enabled' do
      before do
        stub_basic_saml_config
      end

      it { is_expected.to eq(true) }
    end
  end

  describe '#external_groups' do
    let(:config_1) { described_class.new('saml1') }

    let(:config_2) { described_class.new('saml2') }

    before do
      saml1_config = ActiveSupport::InheritableOptions.new(name: 'saml1', label: 'saml1', args: {
        'strategy_class' => 'OmniAuth::Strategies::SAML'
      })

      saml2_config = ActiveSupport::InheritableOptions.new(name: 'saml2',
        external_groups: ['FreeLancers'],
        label: 'saml2',
        args: {
          'strategy_class' => 'OmniAuth::Strategies::SAML'
        })

      stub_omniauth_setting(enabled: true, auto_link_saml_user: true, providers: [saml1_config, saml2_config])
    end

    it "lists groups" do
      expect(config_1.external_groups).to be_nil
      expect(config_2.external_groups).to be_eql(['FreeLancers'])
    end
  end
end