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
833480da
Commit
833480da
authored
May 07, 2018
by
Jacob Schatz
Committed by
Micaël Bergeron
Jun 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for pseudo anonymous
parent
e9c28fd0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
3 deletions
+67
-3
ee/spec/lib/gitlab/pseudo_spec.rb
ee/spec/lib/gitlab/pseudo_spec.rb
+62
-0
lib/pseudonymity/table.rb
lib/pseudonymity/table.rb
+4
-2
lib/tasks/gitlab/db.rake
lib/tasks/gitlab/db.rake
+1
-1
No files found.
ee/spec/lib/gitlab/pseudo_spec.rb
0 → 100644
View file @
833480da
require
'spec_helper'
describe
Gitlab
::
Pseudonymity
do
let!
(
:project
)
{
create
(
:project
)
}
let
(
:base_dir
)
{
Dir
.
mktmpdir
}
subject
(
:pseudo
)
{
Pseudonymity
::
Table
.
new
}
after
do
FileUtils
.
rm_rf
(
base_dir
)
end
# create temp directory in before block
describe
'Pseudo tables'
do
it
'outputs project tables to csv'
do
pseudo
.
config
[
"output"
][
"csv"
]
=
base_dir
pseudo
.
config
[
"tables"
]
=
{
"projects"
=>
{
"whitelist"
=>
[
"id"
,
"name"
,
"path"
,
"description"
],
"pseudo"
=>
[
"id"
]
}
}
expect
(
pseudo
.
config
[
"output"
][
"csv"
]).
to
eq
(
base_dir
)
# grab the first table it outputs. There would only be 1.
project_table_file
=
pseudo
.
tables_to_csv
[
0
]
# Ignore the `.` and `..` in the directory.
entry
=
Dir
.
entries
(
base_dir
)[
2
]
expect
(
project_table_file
.
include?
"projects_"
).
to
be
true
expect
(
project_table_file
.
include?
".csv"
).
to
be
true
expect
(
project_table_file
.
include?
entry
).
to
be
true
columns
=
[]
project_data
=
[]
File
.
foreach
(
project_table_file
).
with_index
do
|
line
,
line_num
|
if
line_num
==
0
columns
=
line
.
split
(
","
)
end
if
line_num
==
1
project_data
=
line
.
split
(
","
)
break
end
end
# check if CSV columns are correct
expect
(
columns
.
to_set
).
to
eq
([
"id"
,
"name"
,
"path"
,
"description
\n
"
].
to_set
)
# is it pseudonymous
expect
(
project_data
[
0
]).
not_to
eq
(
1
)
# sha 256 is 64 chars in length
expect
(
project_data
[
0
].
length
).
to
eq
(
64
)
end
end
end
lib/pseudonymity/table.rb
View file @
833480da
...
...
@@ -24,6 +24,8 @@ module Pseudonymity
end
class
Table
attr_accessor
:config
def
initialize
@config
=
{}
@csv_output
=
""
...
...
@@ -31,8 +33,8 @@ module Pseudonymity
end
def
tables_to_csv
tables
=
@
config
[
"tables"
]
@csv_output
=
@
config
[
"output"
][
"csv"
]
tables
=
config
[
"tables"
]
@csv_output
=
config
[
"output"
][
"csv"
]
if
not
File
.
directory?
(
@csv_output
)
puts
"No such directory
#{
@csv_output
}
"
return
...
...
lib/tasks/gitlab/db.rake
View file @
833480da
...
...
@@ -70,7 +70,7 @@ namespace :gitlab do
Gitlab
::
DowntimeCheck
.
new
.
check_and_print
(
migrations
)
end
desc
'Output pseudonymity dump of selected table'
desc
'Output pseudonymity dump of selected table
s
'
task
:pseudonymity_dump
=>
:environment
do
table
=
Pseudonymity
::
Table
.
new
table
.
tables_to_csv
...
...
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