Commit ca847fc6 authored by David Fernandez's avatar David Fernandez

Merge branch 'andysoiron/truncate-jira-connect-app-key' into 'master'

Truncate Jira app key to be no longer than 64

See merge request gitlab-org/gitlab!80922
parents edfb9a86 084ec2d6
......@@ -8,7 +8,10 @@ module Atlassian
end
def app_key
"gitlab-jira-connect-#{gitlab_host}"
# App key must be <= 64 characters.
# See: https://developer.atlassian.com/cloud/jira/platform/connect-app-descriptor/#app-descriptor-structure
"gitlab-jira-connect-#{gitlab_host}"[..63]
end
private
......
# frozen_string_literal: true
require 'fast_spec_helper'
RSpec.describe Atlassian::JiraConnect do
describe '.app_name' do
subject { described_class.app_name }
it { is_expected.to eq('GitLab for Jira (localhost)') }
end
describe '.app_key' do
subject(:app_key) { described_class.app_key }
it { is_expected.to eq('gitlab-jira-connect-localhost') }
context 'host name is too long' do
before do
hostname = 'x' * 100
stub_config(gitlab: { host: hostname })
end
it 'truncates the key to be no longer than 64 characters', :aggregate_failures do
expect(app_key).to eq('gitlab-jira-connect-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
end
end
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