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/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-11 02:24:31 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-11 02:24:31 +0300
commit83380b5e7f6489d6429af539ebd2fd1bb973d90f (patch)
tree60df92052073f1619b2b3515b5aa3d928fc60f9c /spec/lib
parent21585f82e753689cc46f59c02d8e207756d794bf (diff)
Add latest changes from gitlab-org/security/gitlab@13-8-stable-ee
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/auth/otp/strategies/forti_token_cloud_spec.rb21
1 files changed, 17 insertions, 4 deletions
diff --git a/spec/lib/gitlab/auth/otp/strategies/forti_token_cloud_spec.rb b/spec/lib/gitlab/auth/otp/strategies/forti_token_cloud_spec.rb
index 1580fc82279..368cf98dfec 100644
--- a/spec/lib/gitlab/auth/otp/strategies/forti_token_cloud_spec.rb
+++ b/spec/lib/gitlab/auth/otp/strategies/forti_token_cloud_spec.rb
@@ -13,6 +13,8 @@ RSpec.describe Gitlab::Auth::Otp::Strategies::FortiTokenCloud do
let(:otp_verification_url) { url + '/auth' }
let(:access_token) { 'an_access_token' }
let(:access_token_create_response_body) { '' }
+ let(:access_token_request_body) { { client_id: client_id, client_secret: client_secret } }
+ let(:headers) { { 'Content-Type': 'application/json' } }
subject(:validate) { described_class.new(user).validate(otp_code) }
@@ -27,11 +29,8 @@ RSpec.describe Gitlab::Auth::Otp::Strategies::FortiTokenCloud do
client_secret: client_secret
)
- access_token_request_body = { client_id: client_id,
- client_secret: client_secret }
-
stub_request(:post, access_token_create_url)
- .with(body: JSON(access_token_request_body), headers: { 'Content-Type' => 'application/json' })
+ .with(body: JSON(access_token_request_body), headers: headers)
.to_return(
status: access_token_create_response_status,
body: Gitlab::Json.generate(access_token_create_response_body),
@@ -81,6 +80,20 @@ RSpec.describe Gitlab::Auth::Otp::Strategies::FortiTokenCloud do
end
end
+ context 'SSL Verification' do
+ let(:access_token_create_response_status) { 400 }
+
+ context 'with `Gitlab::HTTP`' do
+ it 'does not use a `verify` argument,'\
+ 'thereby always performing SSL verification while making API calls' do
+ expect(Gitlab::HTTP).to receive(:post)
+ .with(access_token_create_url, body: JSON(access_token_request_body), headers: headers).and_call_original
+
+ validate
+ end
+ end
+ end
+
def stub_forti_token_cloud_config(forti_token_cloud_settings)
allow(::Gitlab.config.forti_token_cloud).to(receive_messages(forti_token_cloud_settings))
end