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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
1a2d13c8
Commit
1a2d13c8
authored
Jan 30, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
programmatically remove encrypted attributes. Added relevant spec.
parent
eeb13c16
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
lib/gitlab/import_export/relation_factory.rb
lib/gitlab/import_export/relation_factory.rb
+9
-0
spec/features/projects/import_export/export_file_spec.rb
spec/features/projects/import_export/export_file_spec.rb
+2
-2
spec/lib/gitlab/import_export/relation_factory_spec.rb
spec/lib/gitlab/import_export/relation_factory_spec.rb
+11
-0
No files found.
lib/gitlab/import_export/relation_factory.rb
View file @
1a2d13c8
...
@@ -63,6 +63,7 @@ module Gitlab
...
@@ -63,6 +63,7 @@ module Gitlab
handle_group_label
if
group_label?
handle_group_label
if
group_label?
reset_tokens!
reset_tokens!
remove_encrypted_attributes!
@relation_hash
[
'data'
].
deep_symbolize_keys!
if
@relation_name
==
:events
&&
@relation_hash
[
'data'
]
@relation_hash
[
'data'
].
deep_symbolize_keys!
if
@relation_name
==
:events
&&
@relation_hash
[
'data'
]
set_st_diffs
if
@relation_name
==
:merge_request_diff
set_st_diffs
if
@relation_name
==
:merge_request_diff
...
@@ -152,6 +153,14 @@ module Gitlab
...
@@ -152,6 +153,14 @@ module Gitlab
end
end
end
end
def
remove_encrypted_attributes!
return
if
relation_class
.
encrypted_attributes
.
empty?
relation_class
.
encrypted_attributes
.
each_key
do
|
key
|
@relation_hash
[
key
.
to_s
]
=
nil
end
end
def
relation_class
def
relation_class
@relation_class
||=
@relation_name
.
to_s
.
classify
.
constantize
@relation_class
||=
@relation_name
.
to_s
.
classify
.
constantize
end
end
...
...
spec/features/projects/import_export/export_file_spec.rb
View file @
1a2d13c8
...
@@ -74,8 +74,8 @@ feature 'Import/Export - project export integration test', feature: true, js: tr
...
@@ -74,8 +74,8 @@ feature 'Import/Export - project export integration test', feature: true, js: tr
Otherwise, please add the exception to +safe_list+ in CURRENT_SPEC using
#{
sensitive_word
}
as the key and the
Otherwise, please add the exception to +safe_list+ in CURRENT_SPEC using
#{
sensitive_word
}
as the key and the
correspondent hash or model as the value.
correspondent hash or model as the value.
Also, if the attribute is
encrypted, please add it to either the list of excluded attributes in IMPORT_EXPORT_CONFIG
Also, if the attribute is
a generated unique token, please add it to RelationFactory::TOKEN_RESET_MODELS if it needs to be
or the model to RelationFactory::TOKEN_RESET_MODELS if it includes a token that can be reset
.
reset (to prevent duplicate column problems while importing to the same instance)
.
IMPORT_EXPORT_CONFIG:
#{
Gitlab
::
ImportExport
.
config_file
}
IMPORT_EXPORT_CONFIG:
#{
Gitlab
::
ImportExport
.
config_file
}
CURRENT_SPEC:
#{
__FILE__
}
CURRENT_SPEC:
#{
__FILE__
}
...
...
spec/lib/gitlab/import_export/relation_factory_spec.rb
View file @
1a2d13c8
...
@@ -178,4 +178,15 @@ describe Gitlab::ImportExport::RelationFactory, lib: true do
...
@@ -178,4 +178,15 @@ describe Gitlab::ImportExport::RelationFactory, lib: true do
expect
(
created_object
.
author
).
to
eq
(
new_user
)
expect
(
created_object
.
author
).
to
eq
(
new_user
)
end
end
end
end
context
'encrypted attributes'
do
let
(
:relation_sym
)
{
'Ci::Variable'
}
let
(
:relation_hash
)
do
create
(
:ci_variable
).
as_json
end
it
'maps the right author to the imported note'
do
expect
(
created_object
.
value
).
to
be_nil
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