Commit 99600468 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch '19152-improve-jira-username-validation' into 'master'

JIRA Service: Improve username/email validation

See merge request gitlab-org/gitlab!18397
parents e2bd24ed 79622c9b
......@@ -64,7 +64,7 @@ class JiraService < IssueTrackerService
url = URI.parse(client_url)
{
username: username,
username: username&.strip,
password: password,
site: URI.join(url, '/').to_s, # Intended to find the root
context_path: url.path,
......
---
title: 'JIRA Service: Improve username/email validation'
merge_request: 18397
author:
type: fixed
......@@ -19,7 +19,7 @@ describe JiraService do
described_class.create(
project: create(:project),
active: true,
username: 'username',
username: 'username ',
password: 'test',
jira_issue_transition_id: 24,
url: 'http://jira.test.com/path/'
......@@ -35,6 +35,15 @@ describe JiraService do
it 'leaves out trailing slashes in context' do
expect(service.options[:context_path]).to eq('/path')
end
it 'leaves out trailing whitespaces in username' do
expect(service.options[:username]).to eq('username')
end
it 'provides additional cookies to allow basic auth with oracle webgate' do
expect(service.options[:use_cookies]).to eq(true)
expect(service.options[:additional_cookies]).to eq(['OBBasicAuth=fromDialog'])
end
end
describe 'Associations' do
......@@ -93,7 +102,7 @@ describe JiraService do
end
# we need to make sure we are able to read both from properties and jira_tracker_data table
# TODO: change this as part of #63084
# TODO: change this as part of https://gitlab.com/gitlab-org/gitlab/issues/29404
context 'overriding properties' do
let(:access_params) do
{ url: url, api_url: api_url, username: username, password: password,
......@@ -604,26 +613,6 @@ describe JiraService do
end
end
describe 'additional cookies' do
let(:project) { create(:project) }
context 'provides additional cookies to allow basic auth with oracle webgate' do
before do
@service = project.create_jira_service(
active: true, properties: { url: 'http://jira.com' })
end
after do
@service.destroy!
end
it 'is initialized' do
expect(@service.options[:use_cookies]).to eq(true)
expect(@service.options[:additional_cookies]).to eq(['OBBasicAuth=fromDialog'])
end
end
end
describe 'project and issue urls' do
context 'when gitlab.yml was initialized' do
it 'is prepopulated with the settings' do
......
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