summaryrefslogtreecommitdiff
path: root/spec/services/users/validate_otp_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/users/validate_otp_service_spec.rb')
-rw-r--r--spec/services/users/validate_otp_service_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/services/users/validate_otp_service_spec.rb b/spec/services/users/validate_otp_service_spec.rb
new file mode 100644
index 00000000000..826755d6145
--- /dev/null
+++ b/spec/services/users/validate_otp_service_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Users::ValidateOtpService do
+ let_it_be(:user) { create(:user) }
+ let(:otp_code) { 42 }
+
+ subject(:validate) { described_class.new(user).execute(otp_code) }
+
+ context 'Devise' do
+ it 'calls Devise strategy' do
+ expect_next_instance_of(::Gitlab::Auth::Otp::Strategies::Devise) do |strategy|
+ expect(strategy).to receive(:validate).with(otp_code).once
+ end
+
+ validate
+ end
+ end
+
+ context 'FortiAuthenticator' do
+ before do
+ stub_feature_flags(forti_authenticator: true)
+ end
+
+ it 'calls FortiAuthenticator strategy' do
+ expect_next_instance_of(::Gitlab::Auth::Otp::Strategies::FortiAuthenticator) do |strategy|
+ expect(strategy).to receive(:validate).with(otp_code).once
+ end
+
+ validate
+ end
+ end
+end