diff options
author | Quanqi Jing <jqq@readboy.com> | 2019-08-22 08:31:53 +0300 |
---|---|---|
committer | Quanqi Jing <jqq@readboy.com> | 2019-08-23 06:21:19 +0300 |
commit | 6d6d46e5f4695f2482d468461923df6ca23ed4fc (patch) | |
tree | fcad8221c0877ac22d58952a0bc9c103730e5fee | |
parent | df2e86fd6cd1675ba613089cdf417dff89f8f11e (diff) |
Add bypass_two_factor spec
-rw-r--r-- | spec/lib/gitlab/auth/o_auth/user_spec.rb | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/spec/lib/gitlab/auth/o_auth/user_spec.rb b/spec/lib/gitlab/auth/o_auth/user_spec.rb index a9b15c411dc..6ec37e79959 100644 --- a/spec/lib/gitlab/auth/o_auth/user_spec.rb +++ b/spec/lib/gitlab/auth/o_auth/user_spec.rb @@ -787,11 +787,22 @@ describe Gitlab::Auth::OAuth::User do end end - describe '#bypass_two_factor?' do - subject { oauth_user.bypass_two_factor? } - - it 'returns always false' do - is_expected.to be_falsey + describe "#bypass_two_factor?" do + it "when with allow_bypass_two_factor disabled (Default)" do + stub_omniauth_config(allow_bypass_two_factor: false) + expect(oauth_user.bypass_two_factor?).to be_falsey + end + it "when with allow_bypass_two_factor enabled" do + stub_omniauth_config(allow_bypass_two_factor: true) + expect(oauth_user.bypass_two_factor?).to be_truthy + end + it "when provider in allow_bypass_two_factor array" do + stub_omniauth_config(allow_bypass_two_factor: [provider]) + expect(oauth_user.bypass_two_factor?).to be_truthy + end + it "when provider not in allow_bypass_two_factor array" do + stub_omniauth_config(allow_bypass_two_factor: ["foo"]) + expect(oauth_user.bypass_two_factor?).to be_falsey end end end |