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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-11-14 18:07:32 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-11-14 18:07:32 +0300
commitcda3f6ca486cd392ce523157ee08692e106fc85d (patch)
tree8921da94b2a59c8eed9ef9e26893a4b0ee26a9af /spec
parent27d427e538fa9c7cb6ca39637660a63f24d7f2d8 (diff)
Add latest changes from gitlab-org/gitlab@16-6-stable-ee
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/auth/saml/config_spec.rb35
-rw-r--r--spec/lib/gitlab/omniauth_initializer_spec.rb117
2 files changed, 1 insertions, 151 deletions
diff --git a/spec/lib/gitlab/auth/saml/config_spec.rb b/spec/lib/gitlab/auth/saml/config_spec.rb
index c19171bb6f8..2ecc26f9b96 100644
--- a/spec/lib/gitlab/auth/saml/config_spec.rb
+++ b/spec/lib/gitlab/auth/saml/config_spec.rb
@@ -19,41 +19,6 @@ RSpec.describe Gitlab::Auth::Saml::Config do
end
end
- describe '.default_attribute_statements' do
- it 'includes upstream defaults, nickname and Microsoft values' do
- expect(described_class.default_attribute_statements).to match_array(
- {
- nickname: %w[username nickname],
- name: [
- 'name',
- 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name',
- 'http://schemas.microsoft.com/ws/2008/06/identity/claims/name'
- ],
- email: [
- 'email',
- 'mail',
- 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress',
- 'http://schemas.microsoft.com/ws/2008/06/identity/claims/emailaddress'
- ],
- first_name: [
- 'first_name',
- 'firstname',
- 'firstName',
- 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname',
- 'http://schemas.microsoft.com/ws/2008/06/identity/claims/givenname'
- ],
- last_name: [
- 'last_name',
- 'lastname',
- 'lastName',
- 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname',
- 'http://schemas.microsoft.com/ws/2008/06/identity/claims/surname'
- ]
- }
- )
- end
- end
-
describe '#external_groups' do
let(:config_1) { described_class.new('saml1') }
diff --git a/spec/lib/gitlab/omniauth_initializer_spec.rb b/spec/lib/gitlab/omniauth_initializer_spec.rb
index e12c0f4e78b..9b46b8eccc8 100644
--- a/spec/lib/gitlab/omniauth_initializer_spec.rb
+++ b/spec/lib/gitlab/omniauth_initializer_spec.rb
@@ -2,9 +2,7 @@
require 'spec_helper'
-RSpec.describe Gitlab::OmniauthInitializer, feature_category: :system_access do
- include LoginHelpers
-
+RSpec.describe Gitlab::OmniauthInitializer do
let(:devise_config) { class_double(Devise) }
subject(:initializer) { described_class.new(devise_config) }
@@ -226,119 +224,6 @@ RSpec.describe Gitlab::OmniauthInitializer, feature_category: :system_access do
subject.execute([shibboleth_config])
end
- context 'when SAML providers are configured' do
- it 'configures default args for a single SAML provider' do
- stub_omniauth_config(providers: [{ name: 'saml', args: { idp_sso_service_url: 'https://saml.example.com' } }])
-
- expect(devise_config).to receive(:omniauth).with(
- :saml,
- {
- idp_sso_service_url: 'https://saml.example.com',
- attribute_statements: ::Gitlab::Auth::Saml::Config.default_attribute_statements
- }
- )
-
- initializer.execute(Gitlab.config.omniauth.providers)
- end
-
- context 'when configuration provides matching keys' do
- before do
- stub_omniauth_config(
- providers: [
- {
- name: 'saml',
- args: { idp_sso_service_url: 'https://saml.example.com', attribute_statements: { email: ['custom_attr'] } }
- }
- ]
- )
- end
-
- it 'merges arguments with user configuration preference' do
- expect(devise_config).to receive(:omniauth).with(
- :saml,
- {
- idp_sso_service_url: 'https://saml.example.com',
- attribute_statements: ::Gitlab::Auth::Saml::Config.default_attribute_statements
- .merge({ email: ['custom_attr'] })
- }
- )
-
- initializer.execute(Gitlab.config.omniauth.providers)
- end
-
- it 'merges arguments with defaults preference when invert_omniauth_args_merging is not enabled' do
- stub_feature_flags(invert_omniauth_args_merging: false)
-
- expect(devise_config).to receive(:omniauth).with(
- :saml,
- {
- idp_sso_service_url: 'https://saml.example.com',
- attribute_statements: ::Gitlab::Auth::Saml::Config.default_attribute_statements
- }
- )
-
- initializer.execute(Gitlab.config.omniauth.providers)
- end
- end
-
- it 'configures defaults args for multiple SAML providers' do
- stub_omniauth_config(
- providers: [
- { name: 'saml', args: { idp_sso_service_url: 'https://saml.example.com' } },
- {
- name: 'saml2',
- args: { strategy_class: 'OmniAuth::Strategies::SAML', idp_sso_service_url: 'https://saml2.example.com' }
- }
- ]
- )
-
- expect(devise_config).to receive(:omniauth).with(
- :saml,
- {
- idp_sso_service_url: 'https://saml.example.com',
- attribute_statements: ::Gitlab::Auth::Saml::Config.default_attribute_statements
- }
- )
- expect(devise_config).to receive(:omniauth).with(
- :saml2,
- {
- idp_sso_service_url: 'https://saml2.example.com',
- strategy_class: OmniAuth::Strategies::SAML,
- attribute_statements: ::Gitlab::Auth::Saml::Config.default_attribute_statements
- }
- )
-
- initializer.execute(Gitlab.config.omniauth.providers)
- end
-
- it 'merges arguments with user configuration preference for custom SAML provider' do
- stub_omniauth_config(
- providers: [
- {
- name: 'custom_saml',
- args: {
- strategy_class: 'OmniAuth::Strategies::SAML',
- idp_sso_service_url: 'https://saml2.example.com',
- attribute_statements: { email: ['custom_attr'] }
- }
- }
- ]
- )
-
- expect(devise_config).to receive(:omniauth).with(
- :custom_saml,
- {
- idp_sso_service_url: 'https://saml2.example.com',
- strategy_class: OmniAuth::Strategies::SAML,
- attribute_statements: ::Gitlab::Auth::Saml::Config.default_attribute_statements
- .merge({ email: ['custom_attr'] })
- }
- )
-
- initializer.execute(Gitlab.config.omniauth.providers)
- end
- end
-
it 'configures defaults for google_oauth2' do
google_config = {
'name' => 'google_oauth2',