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
afec33d8
Commit
afec33d8
authored
Sep 01, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unsetting credentials data for pull mirrors
parent
0c01f887
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
2 deletions
+53
-2
changelogs/unreleased-ee/fix-pull-mirror-setting-nil.yml
changelogs/unreleased-ee/fix-pull-mirror-setting-nil.yml
+5
-0
ee/app/models/ee/project_import_data.rb
ee/app/models/ee/project_import_data.rb
+20
-2
spec/ee/spec/models/ee/project_import_data_spec.rb
spec/ee/spec/models/ee/project_import_data_spec.rb
+28
-0
No files found.
changelogs/unreleased-ee/fix-pull-mirror-setting-nil.yml
0 → 100644
View file @
afec33d8
---
title
:
Fix unsetting credentials data for pull mirrors
merge_request
:
2810
author
:
type
:
fixed
ee/app/models/ee/project_import_data.rb
View file @
afec33d8
...
...
@@ -5,6 +5,16 @@ module EE
bits:
4096
}.
freeze
CREDENTIALS_FIELDS
=
%i[
auth_method
password
ssh_known_hosts
ssh_known_hosts_verified_at
ssh_known_hosts_verified_by_id
ssh_private_key
user
]
.
freeze
extend
ActiveSupport
::
Concern
included
do
...
...
@@ -26,14 +36,22 @@ module EE
project
&
.
import_url
&
.
start_with?
(
'ssh://'
)
end
%i[auth_method user password ssh_private_key ssh_known_hosts ssh_known_hosts_verified_at ssh_known_hosts_verified_by_id]
.
each
do
|
name
|
CREDENTIALS_FIELDS
.
each
do
|
name
|
define_method
(
name
)
do
credentials
[
name
]
if
credentials
.
present?
end
define_method
(
"
#{
name
}
="
)
do
|
value
|
self
.
credentials
||=
{}
self
.
credentials
[
name
]
=
value
# Removal of the password, username, etc, generally causes an update of
# the value to the empty string. Detect and gracefully handle this case.
if
value
.
present?
self
.
credentials
[
name
]
=
value
else
self
.
credentials
.
delete
(
name
)
nil
end
end
end
...
...
spec/ee/spec/models/ee/project_import_data_spec.rb
View file @
afec33d8
...
...
@@ -62,6 +62,34 @@ describe ProjectImportData do
end
end
describe
'credential fields accessors'
do
let
(
:accessors
)
{
%i[auth_method password ssh_known_hosts ssh_known_hosts_verified_at ssh_known_hosts_verified_by_id ssh_private_key user]
}
it
{
expect
(
described_class
::
CREDENTIALS_FIELDS
).
to
contain_exactly
(
*
accessors
)
}
where
(
:field
)
{
described_class
::
CREDENTIALS_FIELDS
}
with_them
do
it
'sets the value in the credentials hash'
do
import_data
.
send
(
"
#{
field
}
="
,
'foo'
)
expect
(
import_data
.
credentials
[
field
]).
to
eq
(
'foo'
)
end
it
'sets a not-present value to nil'
do
import_data
.
send
(
"
#{
field
}
="
,
''
)
expect
(
import_data
.
credentials
[
field
]).
to
be_nil
end
it
'returns the data in the credentials hash'
do
import_data
.
credentials
[
field
]
=
'foo'
expect
(
import_data
.
send
(
field
)).
to
eq
(
'foo'
)
end
end
end
describe
'#ssh_import?'
do
where
(
:import_url
,
:expected
)
do
'ssh://example.com'
|
true
...
...
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