Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7b266997
Commit
7b266997
authored
Oct 22, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Invalidate stored jira password if the endpoint URL is changed
parent
5bd8b016
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
0 deletions
+76
-0
CHANGELOG-EE
CHANGELOG-EE
+3
-0
app/models/project_services/jira_service.rb
app/models/project_services/jira_service.rb
+8
-0
spec/models/project_services/jira_service_spec.rb
spec/models/project_services/jira_service_spec.rb
+65
-0
No files found.
CHANGELOG-EE
View file @
7b266997
v 8.2.0
- Invalidate stored jira password if the endpoint URL is changed
v 8.1.0 (unreleased)
- added an issues template (Hannes Rosenögger)
- Fix "Rebase onto master"
...
...
app/models/project_services/jira_service.rb
View file @
7b266997
...
...
@@ -27,6 +27,14 @@ class JiraService < IssueTrackerService
before_validation
:set_api_version
,
:set_jira_issue_transition_id
before_update
:reset_password
def
reset_password
if
project_url_changed?
&&
!
password_touched?
self
.
password
=
nil
end
end
def
help
line1
=
'Setting `project_url`, `issues_url` and `new_issue_url` will '
\
'allow a user to easily navigate to the Jira issue tracker. See the '
\
...
...
spec/models/project_services/jira_service_spec.rb
View file @
7b266997
...
...
@@ -140,4 +140,69 @@ describe JiraService do
end
end
end
describe
"Execute"
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
context
"when a password was previously set"
do
before
do
@service
=
JiraService
.
create
(
project:
create
(
:project
),
properties:
{
project_url:
'http://gitlab.com'
,
username:
'mic'
,
password:
"password"
}
)
end
it
"reset password if url changed"
do
@service
.
project_url
=
'http://gitlab1.com'
@service
.
save
expect
(
@service
.
password
).
to
be_nil
end
it
"does not reset password if username changed"
do
@service
.
username
=
"some_name"
@service
.
save
expect
(
@service
.
password
).
to
eq
(
"password"
)
end
it
"does not reset password if new url is set together with password, even if it's the same password"
do
@service
.
project_url
=
'http://gitlab_edited.com'
@service
.
password
=
'password'
@service
.
save
expect
(
@service
.
password
).
to
eq
(
"password"
)
expect
(
@service
.
project_url
).
to
eq
(
"http://gitlab_edited.com"
)
end
it
"should reset password if url changed, even if setter called multiple times"
do
@service
.
project_url
=
'http://gitlab1.com'
@service
.
project_url
=
'http://gitlab1.com'
@service
.
save
expect
(
@service
.
password
).
to
be_nil
end
end
context
"when no password was previously set"
do
before
do
@service
=
JiraService
.
create
(
project:
create
(
:project
),
properties:
{
project_url:
'http://gitlab.com'
,
username:
'mic'
}
)
end
it
"saves password if new url is set together with password"
do
@service
.
project_url
=
'http://gitlab_edited.com'
@service
.
password
=
'password'
@service
.
save
expect
(
@service
.
password
).
to
eq
(
"password"
)
expect
(
@service
.
project_url
).
to
eq
(
"http://gitlab_edited.com"
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment