diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/lib/gitlab/auth/o_auth/user_spec.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/lib/gitlab/auth/o_auth/user_spec.rb')
-rw-r--r-- | spec/lib/gitlab/auth/o_auth/user_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/lib/gitlab/auth/o_auth/user_spec.rb b/spec/lib/gitlab/auth/o_auth/user_spec.rb index 6cb9085c3ad..5f5e7f211f8 100644 --- a/spec/lib/gitlab/auth/o_auth/user_spec.rb +++ b/spec/lib/gitlab/auth/o_auth/user_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Gitlab::Auth::OAuth::User do include LdapHelpers + include TermsHelper let(:oauth_user) { described_class.new(auth_hash) } let(:oauth_user_2) { described_class.new(auth_hash_2) } @@ -144,6 +145,49 @@ RSpec.describe Gitlab::Auth::OAuth::User do expect(gl_user).to be_password_automatically_set end + context 'terms of service' do + context 'when terms are enforced' do + before do + enforce_terms + end + + context 'when feature flag update_oauth_registration_flow is enabled' do + before do + stub_feature_flags(update_oauth_registration_flow: true) + end + + it 'creates the user with accepted terms' do + oauth_user.save # rubocop:disable Rails/SaveBang + + expect(gl_user).to be_persisted + expect(gl_user.terms_accepted?).to be(true) + end + end + + context 'when feature flag update_oauth_registration_flow is disabled' do + before do + stub_feature_flags(update_oauth_registration_flow: false) + end + + it 'creates the user without accepted terms' do + oauth_user.save # rubocop:disable Rails/SaveBang + + expect(gl_user).to be_persisted + expect(gl_user.terms_accepted?).to be(false) + end + end + end + + context 'when terms are not enforced' do + it 'creates the user without accepted terms' do + oauth_user.save # rubocop:disable Rails/SaveBang + + expect(gl_user).to be_persisted + expect(gl_user.terms_accepted?).to be(false) + end + end + end + shared_examples 'to verify compliance with allow_single_sign_on' do context 'provider is marked as external' do it 'marks user as external' do |