Validate username/pw for Jiraservice, require them in the API
This commit is contained in:
parent
82446a2bd0
commit
cc5ba3d907
|
@ -3,6 +3,8 @@ class JiraService < IssueTrackerService
|
||||||
|
|
||||||
validates :url, url: true, presence: true, if: :activated?
|
validates :url, url: true, presence: true, if: :activated?
|
||||||
validates :api_url, url: true, allow_blank: true
|
validates :api_url, url: true, allow_blank: true
|
||||||
|
validates :username, presence: true, if: :activated?
|
||||||
|
validates :password, presence: true, if: :activated?
|
||||||
|
|
||||||
prop_accessor :username, :password, :url, :api_url, :jira_issue_transition_id, :title, :description
|
prop_accessor :username, :password, :url, :api_url, :jira_issue_transition_id, :title, :description
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Validate username/pw for Jiraservice, require them in the API
|
||||||
|
merge_request:
|
||||||
|
author: Robert Schilling
|
||||||
|
type: fixed
|
|
@ -313,13 +313,13 @@ module API
|
||||||
desc: 'The base URL to the JIRA instance API. Web URL value will be used if not set. E.g., https://jira-api.example.com'
|
desc: 'The base URL to the JIRA instance API. Web URL value will be used if not set. E.g., https://jira-api.example.com'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
required: false,
|
required: true,
|
||||||
name: :username,
|
name: :username,
|
||||||
type: String,
|
type: String,
|
||||||
desc: 'The username of the user created to be used with GitLab/JIRA'
|
desc: 'The username of the user created to be used with GitLab/JIRA'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
required: false,
|
required: true,
|
||||||
name: :password,
|
name: :password,
|
||||||
type: String,
|
type: String,
|
||||||
desc: 'The password of the user created to be used with GitLab/JIRA'
|
desc: 'The password of the user created to be used with GitLab/JIRA'
|
||||||
|
|
|
@ -24,6 +24,8 @@ describe JiraService do
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.not_to validate_presence_of(:url) }
|
it { is_expected.not_to validate_presence_of(:url) }
|
||||||
|
it { is_expected.not_to validate_presence_of(:username) }
|
||||||
|
it { is_expected.not_to validate_presence_of(:password) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'validating urls' do
|
context 'validating urls' do
|
||||||
|
@ -54,6 +56,18 @@ describe JiraService do
|
||||||
expect(service).not_to be_valid
|
expect(service).not_to be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'is not valid when username is missing' do
|
||||||
|
service.username = nil
|
||||||
|
|
||||||
|
expect(service).not_to be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'is not valid when password is missing' do
|
||||||
|
service.password = nil
|
||||||
|
|
||||||
|
expect(service).not_to be_valid
|
||||||
|
end
|
||||||
|
|
||||||
it 'is valid when api url is a valid url' do
|
it 'is valid when api url is a valid url' do
|
||||||
service.api_url = 'http://jira.test.com/api'
|
service.api_url = 'http://jira.test.com/api'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue