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 ...@@ -64,7 +64,7 @@ class JiraService < IssueTrackerService
url = URI.parse(client_url) url = URI.parse(client_url)
{ {
username: username, username: username&.strip,
password: password, password: password,
site: URI.join(url, '/').to_s, # Intended to find the root site: URI.join(url, '/').to_s, # Intended to find the root
context_path: url.path, context_path: url.path,
......
---
title: 'JIRA Service: Improve username/email validation'
merge_request: 18397
author:
type: fixed
...@@ -19,7 +19,7 @@ describe JiraService do ...@@ -19,7 +19,7 @@ describe JiraService do
described_class.create( described_class.create(
project: create(:project), project: create(:project),
active: true, active: true,
username: 'username', username: 'username ',
password: 'test', password: 'test',
jira_issue_transition_id: 24, jira_issue_transition_id: 24,
url: 'http://jira.test.com/path/' url: 'http://jira.test.com/path/'
...@@ -35,6 +35,15 @@ describe JiraService do ...@@ -35,6 +35,15 @@ describe JiraService do
it 'leaves out trailing slashes in context' do it 'leaves out trailing slashes in context' do
expect(service.options[:context_path]).to eq('/path') expect(service.options[:context_path]).to eq('/path')
end 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 end
describe 'Associations' do describe 'Associations' do
...@@ -68,7 +77,7 @@ describe JiraService do ...@@ -68,7 +77,7 @@ describe JiraService do
expect(subject.properties).to be_nil expect(subject.properties).to be_nil
end end
it 'sets title correctly' do it 'sets title correctly' do
service = subject service = subject
expect(service.title).to eq('custom title') expect(service.title).to eq('custom title')
...@@ -93,7 +102,7 @@ describe JiraService do ...@@ -93,7 +102,7 @@ describe JiraService do
end end
# we need to make sure we are able to read both from properties and jira_tracker_data table # 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 context 'overriding properties' do
let(:access_params) do let(:access_params) do
{ url: url, api_url: api_url, username: username, password: password, { url: url, api_url: api_url, username: username, password: password,
...@@ -604,26 +613,6 @@ describe JiraService do ...@@ -604,26 +613,6 @@ describe JiraService do
end end
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 describe 'project and issue urls' do
context 'when gitlab.yml was initialized' do context 'when gitlab.yml was initialized' do
it 'is prepopulated with the settings' 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