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
c822bbbf
Commit
c822bbbf
authored
Jun 17, 2020
by
Tetiana Chupryna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add security_setting import/export test
Add additional fixtures for ee Add test for security_setting model
parent
df51e59c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
6 deletions
+79
-6
ee/spec/factories/project_security_settings.rb
ee/spec/factories/project_security_settings.rb
+4
-0
ee/spec/fixtures/lib/gitlab/import_export/complex/project.json
...ec/fixtures/lib/gitlab/import_export/complex/project.json
+35
-0
ee/spec/fixtures/lib/gitlab/import_export/complex/tree/project.json
...xtures/lib/gitlab/import_export/complex/tree/project.json
+1
-0
ee/spec/fixtures/lib/gitlab/import_export/complex/tree/project/security_setting.ndjson
...mport_export/complex/tree/project/security_setting.ndjson
+1
-0
ee/spec/lib/ee/gitlab/import_export/project/tree_restorer_spec.rb
...lib/ee/gitlab/import_export/project/tree_restorer_spec.rb
+24
-6
ee/spec/lib/ee/gitlab/import_export/project/tree_saver_spec.rb
...ec/lib/ee/gitlab/import_export/project/tree_saver_spec.rb
+14
-0
No files found.
ee/spec/factories/project_security_settings.rb
View file @
c822bbbf
...
@@ -3,5 +3,9 @@
...
@@ -3,5 +3,9 @@
FactoryBot
.
define
do
FactoryBot
.
define
do
factory
:project_security_setting
do
factory
:project_security_setting
do
project
project
auto_fix_container_scanning
{
true
}
auto_fix_dast
{
true
}
auto_fix_dependency_scanning
{
true
}
auto_fix_sast
{
true
}
end
end
end
end
ee/spec/fixtures/lib/gitlab/import_export/complex/project.json
0 → 100644
View file @
c822bbbf
{
"description"
:
"Nisi et repellendus ut enim quo accusamus vel magnam."
,
"import_type"
:
"gitlab_project"
,
"creator_id"
:
123
,
"visibility_level"
:
10
,
"archived"
:
false
,
"project_members"
:
[
{
"id"
:
36
,
"access_level"
:
40
,
"source_id"
:
5
,
"source_type"
:
"Project"
,
"user_id"
:
16
,
"notification_level"
:
3
,
"created_at"
:
"2016-06-14T15:02:03.834Z"
,
"updated_at"
:
"2016-06-14T15:02:03.834Z"
,
"created_by_id"
:
null
,
"invite_email"
:
null
,
"invite_token"
:
null
,
"invite_accepted_at"
:
null
,
"requested_at"
:
null
,
"user"
:
{
"id"
:
16
,
"email"
:
"bernard_willms@gitlabexample.com"
,
"username"
:
"bernard_willms"
}
}
],
"security_setting"
:
{
"auto_fix_container_scanning"
:
true
,
"auto_fix_dast"
:
true
,
"auto_fix_dependency_scanning"
:
false
,
"auto_fix_sast"
:
false
}
}
ee/spec/fixtures/lib/gitlab/import_export/complex/tree/project.json
0 → 100644
View file @
c822bbbf
{
"security_setting"
:
{
"auto_fix_container_scanning"
:
true
,
"auto_fix_dast"
:
true
,
"auto_fix_dependency_scanning"
:
false
,
"auto_fix_sast"
:
false
}}
ee/spec/fixtures/lib/gitlab/import_export/complex/tree/project/security_setting.ndjson
0 → 100644
View file @
c822bbbf
{"auto_fix_container_scanning": true,"auto_fix_dast": true,"auto_fix_dependency_scanning": false,"auto_fix_sast": false}
ee/spec/lib/ee/gitlab/import_export/project/tree_restorer_spec.rb
View file @
c822bbbf
...
@@ -4,11 +4,11 @@ require 'spec_helper'
...
@@ -4,11 +4,11 @@ require 'spec_helper'
RSpec
.
describe
Gitlab
::
ImportExport
::
Project
::
TreeRestorer
do
RSpec
.
describe
Gitlab
::
ImportExport
::
Project
::
TreeRestorer
do
include
ImportExport
::
CommonUtil
include
ImportExport
::
CommonUtil
subject
(
:restored_project_json
)
{
project_tree_restorer
.
restore
}
let
(
:shared
)
{
project
.
import_export_shared
}
let
(
:shared
)
{
project
.
import_export_shared
}
let
(
:project_tree_restorer
)
{
described_class
.
new
(
user:
user
,
shared:
shared
,
project:
project
)
}
let
(
:project_tree_restorer
)
{
described_class
.
new
(
user:
user
,
shared:
shared
,
project:
project
)
}
subject
(
:restored_project_json
)
{
project_tree_restorer
.
restore
}
describe
'epics'
do
describe
'epics'
do
let_it_be
(
:user
)
{
create
(
:user
)}
let_it_be
(
:user
)
{
create
(
:user
)}
...
@@ -17,8 +17,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do
...
@@ -17,8 +17,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do
end
end
context
'with group'
do
context
'with group'
do
let
(
:issue
)
{
project
.
issues
.
find_by_title
(
'Issue with Epic'
)
}
let_it_be
(
:project
)
do
let!
(
:project
)
do
create
(
:project
,
create
(
:project
,
:builds_disabled
,
:builds_disabled
,
:issues_disabled
,
:issues_disabled
,
...
@@ -27,8 +26,10 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do
...
@@ -27,8 +26,10 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do
group:
create
(
:group
,
:private
))
group:
create
(
:group
,
:private
))
end
end
let
(
:issue
)
{
project
.
issues
.
find_by_title
(
'Issue with Epic'
)
}
context
'with pre-existing epic'
do
context
'with pre-existing epic'
do
let
!
(
:epic
)
{
create
(
:epic
,
title:
'An epic'
,
group:
project
.
group
)
}
let
_it_be
(
:epic
)
{
create
(
:epic
,
title:
'An epic'
,
group:
project
.
group
)
}
it
'associates epics'
do
it
'associates epics'
do
project
=
Project
.
find_by_path
(
'project'
)
project
=
Project
.
find_by_path
(
'project'
)
...
@@ -54,7 +55,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do
...
@@ -54,7 +55,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do
end
end
context
'with personal namespace'
do
context
'with personal namespace'
do
let
!
(
:project
)
do
let
_it_be
(
:project
)
do
create
(
:project
,
create
(
:project
,
:builds_disabled
,
:builds_disabled
,
:issues_disabled
,
:issues_disabled
,
...
@@ -94,4 +95,21 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do
...
@@ -94,4 +95,21 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do
end
end
end
end
end
end
describe
'security_settings'
do
let_it_be
(
:project
)
{
create
(
:project
,
name:
'project'
,
path:
'project'
)
}
let
(
:user
)
{
create
(
:user
)}
before
do
setup_import_export_config
(
'complex'
,
'ee'
)
end
it
'creates security setting'
do
project
=
Project
.
find_by_path
(
'project'
)
expect
{
restored_project_json
}.
to
change
{
ProjectSecuritySetting
.
count
}.
from
(
0
).
to
(
1
)
expect
(
project
.
security_setting
.
auto_fix_dependency_scanning
).
to
be_falsey
expect
(
project
.
security_setting
.
auto_fix_container_scanning
).
to
be_truthy
end
end
end
end
ee/spec/lib/ee/gitlab/import_export/project/tree_saver_spec.rb
View file @
c822bbbf
...
@@ -15,6 +15,8 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
...
@@ -15,6 +15,8 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
let_it_be
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec_ee"
}
let_it_be
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec_ee"
}
let_it_be
(
:security_setting
)
{
create
(
:project_security_setting
,
project:
project
,
auto_fix_dast:
false
)
}
after
:all
do
after
:all
do
FileUtils
.
rm_rf
(
export_path
)
FileUtils
.
rm_rf
(
export_path
)
end
end
...
@@ -64,6 +66,18 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
...
@@ -64,6 +66,18 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
expect
(
issue_json
[
'epic_issue'
][
'issue_id'
]).
to
be_nil
expect
(
issue_json
[
'epic_issue'
][
'issue_id'
]).
to
be_nil
end
end
end
end
context
'security setting'
do
let
(
:security_json
)
do
json
=
get_json
(
full_path
,
exportable_path
,
:security_setting
,
ndjson_enabled
)
ndjson_enabled
?
json
.
first
:
json
end
it
'has security settings'
do
expect
(
security_json
[
'auto_fix_dast'
]).
to
be_falsey
expect
(
security_json
[
'auto_fix_dependency_scanning'
]).
to
be_truthy
end
end
end
end
context
'with JSON'
do
context
'with JSON'
do
...
...
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