mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-24 03:56:05 +10:00
Merge branch 'invalidate_password' into 'master'
Invalidate stored jira password if the endpoint URL is changed https://gitlab.com/gitlab-org/gitlab-ce/issues/2997 See merge request !38
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
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"
|
||||
|
||||
@@ -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 '\
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user