diff options
Diffstat (limited to 'spec/lib/gitlab/jira/middleware_spec.rb')
-rw-r--r-- | spec/lib/gitlab/jira/middleware_spec.rb | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/spec/lib/gitlab/jira/middleware_spec.rb b/spec/lib/gitlab/jira/middleware_spec.rb deleted file mode 100644 index 09cf67d0657..00000000000 --- a/spec/lib/gitlab/jira/middleware_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -require 'fast_spec_helper' - -RSpec.describe Gitlab::Jira::Middleware do - let(:app) { double(:app) } - let(:middleware) { described_class.new(app) } - let(:jira_user_agent) { 'Jira DVCS Connector Vertigo/5.0.0-D20170810T012915' } - - describe '.jira_dvcs_connector?' do - it 'returns true when DVCS connector' do - expect(described_class.jira_dvcs_connector?('HTTP_USER_AGENT' => jira_user_agent)).to eq(true) - 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 - expect(described_class.jira_dvcs_connector?('HTTP_USER_AGENT' => 'pokemon')).to eq(false) - end - end - - describe '#call' do - it 'adjusts HTTP_AUTHORIZATION env when request from Jira DVCS user agent' do - expect(app).to receive(:call).with({ 'HTTP_USER_AGENT' => jira_user_agent, - 'HTTP_AUTHORIZATION' => 'Bearer hash-123' }) - - middleware.call('HTTP_USER_AGENT' => jira_user_agent, 'HTTP_AUTHORIZATION' => 'token hash-123') - end - - it 'does not change HTTP_AUTHORIZATION env when request is not from Jira DVCS user agent' do - env = { 'HTTP_USER_AGENT' => 'Mozilla/5.0', 'HTTP_AUTHORIZATION' => 'token hash-123' } - - expect(app).to receive(:call).with(env) - - middleware.call(env) - end - end -end |