Commit 61891c26 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'fix-jira-user-agent' into 'master'

Fix user agent string for Hosted Jira

Closes #10737

See merge request gitlab-org/gitlab-ee!10545
parents 13ec1bcb b27e5497
---
title: Fix user agent string for Hosted Jira
merge_request: 10545
author:
type: fixed
...@@ -4,7 +4,7 @@ module Gitlab ...@@ -4,7 +4,7 @@ module Gitlab
module Jira module Jira
class Middleware class Middleware
def self.jira_dvcs_connector?(env) def self.jira_dvcs_connector?(env)
env['HTTP_USER_AGENT']&.start_with?('JIRA DVCS Connector') env['HTTP_USER_AGENT']&.downcase&.start_with?('jira dvcs connector')
end end
def initialize(app) def initialize(app)
......
...@@ -10,6 +10,10 @@ describe Gitlab::Jira::Middleware do ...@@ -10,6 +10,10 @@ describe Gitlab::Jira::Middleware do
expect(described_class.jira_dvcs_connector?('HTTP_USER_AGENT' => jira_user_agent)).to eq(true) expect(described_class.jira_dvcs_connector?('HTTP_USER_AGENT' => jira_user_agent)).to eq(true)
end end
it 'returns true if user agent starts with "Jira DVCS Connector"' do
expect(described_class.jira_dvcs_connector?('HTTP_USER_AGENT' => 'Jira DVCS Connector')).to eq(true)
end
it 'returns false when not DVCS connector' do it 'returns false when not DVCS connector' do
expect(described_class.jira_dvcs_connector?('HTTP_USER_AGENT' => 'pokemon')).to eq(false) expect(described_class.jira_dvcs_connector?('HTTP_USER_AGENT' => 'pokemon')).to eq(false)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment