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
8642dd89
Commit
8642dd89
authored
Oct 22, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor `license_management:` to use new `reports:` syntax
parent
04d83aec
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
38 additions
and
217 deletions
+38
-217
ee/app/helpers/ee/gitlab_routing_helper.rb
ee/app/helpers/ee/gitlab_routing_helper.rb
+4
-3
ee/app/models/ee/ci/build.rb
ee/app/models/ee/ci/build.rb
+0
-5
ee/app/models/ee/ci/pipeline.rb
ee/app/models/ee/ci/pipeline.rb
+5
-10
ee/app/models/ee/merge_request.rb
ee/app/models/ee/merge_request.rb
+0
-4
ee/app/serializers/ee/merge_request_widget_entity.rb
ee/app/serializers/ee/merge_request_widget_entity.rb
+6
-10
ee/app/views/projects/pipelines/_tabs_content.html.haml
ee/app/views/projects/pipelines/_tabs_content.html.haml
+1
-1
ee/spec/controllers/projects/pipelines_controller_spec.rb
ee/spec/controllers/projects/pipelines_controller_spec.rb
+2
-12
ee/spec/factories/ci/job_artifacts.rb
ee/spec/factories/ci/job_artifacts.rb
+18
-0
ee/spec/models/ci/build_spec.rb
ee/spec/models/ci/build_spec.rb
+0
-65
ee/spec/models/ci/pipeline_spec.rb
ee/spec/models/ci/pipeline_spec.rb
+0
-64
ee/spec/models/merge_request_spec.rb
ee/spec/models/merge_request_spec.rb
+0
-33
ee/spec/serializers/merge_request_widget_entity_spec.rb
ee/spec/serializers/merge_request_widget_entity_spec.rb
+2
-10
No files found.
ee/app/helpers/ee/gitlab_routing_helper.rb
View file @
8642dd89
...
@@ -30,9 +30,10 @@ module EE
...
@@ -30,9 +30,10 @@ module EE
end
end
def
license_management_artifact_url
(
pipeline
)
def
license_management_artifact_url
(
pipeline
)
raw_project_build_artifacts_url
(
pipeline
.
project
,
return
unless
pipeline
pipeline
.
license_management_artifact
,
path:
Ci
::
Build
::
LICENSE_MANAGEMENT_FILE
)
pipeline
.
present
(
current_user:
current_user
)
.
downloadable_path_for_report_type
(
:license_management
)
end
end
def
license_management_api_url
(
project
)
def
license_management_api_url
(
project
)
...
...
ee/app/models/ee/ci/build.rb
View file @
8642dd89
...
@@ -33,11 +33,6 @@ module EE
...
@@ -33,11 +33,6 @@ module EE
::
Gitlab
::
Database
::
LoadBalancing
::
Sticking
.
stick
(
:build
,
id
)
::
Gitlab
::
Database
::
LoadBalancing
::
Sticking
.
stick
(
:build
,
id
)
end
end
def
has_license_management_json?
name_in?
(
'license_management'
)
&&
has_artifact?
(
LICENSE_MANAGEMENT_FILE
)
end
def
log_geo_deleted_event
def
log_geo_deleted_event
# It is not needed to generate a Geo deleted event
# It is not needed to generate a Geo deleted event
# since Legacy Artifacts are migrated to multi-build artifacts
# since Legacy Artifacts are migrated to multi-build artifacts
...
...
ee/app/models/ee/ci/pipeline.rb
View file @
8642dd89
...
@@ -59,6 +59,10 @@ module EE
...
@@ -59,6 +59,10 @@ module EE
performance:
{
performance:
{
names:
%w(performance deploy)
,
names:
%w(performance deploy)
,
files:
%w(performance.json)
files:
%w(performance.json)
},
license_management:
{
names:
%w(license_management)
,
files:
%w(gl-license-management-report.json)
}
}
}.
freeze
}.
freeze
...
@@ -101,17 +105,8 @@ module EE
...
@@ -101,17 +105,8 @@ module EE
nil
nil
end
end
def
license_management_artifact
@license_management_artifact
||=
artifacts_with_files
.
find
(
&
:has_license_management_json?
)
end
def
has_license_management_data?
license_management_artifact
&
.
success?
end
def
expose_license_management_data?
def
expose_license_management_data?
project
.
feature_available?
(
:license_management
)
&&
any_report_artifact_for_type
(
:license_management
)
has_license_management_data?
end
end
def
has_security_reports?
def
has_security_reports?
...
...
ee/app/models/ee/merge_request.rb
View file @
8642dd89
...
@@ -16,12 +16,8 @@ module EE
...
@@ -16,12 +16,8 @@ module EE
validate
:validate_approvals_before_merge
,
unless: :importing?
validate
:validate_approvals_before_merge
,
unless: :importing?
delegate
:license_management_artifact
,
to: :head_pipeline
,
prefix: :head
,
allow_nil:
true
delegate
:license_management_artifact
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:sha
,
to: :head_pipeline
,
prefix: :head_pipeline
,
allow_nil:
true
delegate
:sha
,
to: :head_pipeline
,
prefix: :head_pipeline
,
allow_nil:
true
delegate
:sha
,
to: :base_pipeline
,
prefix: :base_pipeline
,
allow_nil:
true
delegate
:sha
,
to: :base_pipeline
,
prefix: :base_pipeline
,
allow_nil:
true
delegate
:has_license_management_data?
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:expose_license_management_data?
,
to: :head_pipeline
,
allow_nil:
true
delegate
:merge_requests_author_approval?
,
to: :target_project
,
allow_nil:
true
delegate
:merge_requests_author_approval?
,
to: :target_project
,
allow_nil:
true
participant
:participant_approvers
participant
:participant_approvers
...
...
ee/app/serializers/ee/merge_request_widget_entity.rb
View file @
8642dd89
...
@@ -56,17 +56,13 @@ module EE
...
@@ -56,17 +56,13 @@ module EE
end
end
end
end
expose
:license_management
,
if:
->
(
mr
,
_
)
{
mr
.
expose_license_management_data?
}
do
expose
:license_management
,
if:
->
(
mr
,
_
)
{
head_pipeline_downloadable_path_for_report_type
(
:license_management
)
}
do
expose
:head_path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_build
,
mr
.
head_license_management_artifact
)
}
do
|
merge_request
|
expose
:head_path
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
source_project
,
head_pipeline_downloadable_path_for_report_type
(
:license_management
)
merge_request
.
head_license_management_artifact
,
path:
Ci
::
Build
::
LICENSE_MANAGEMENT_FILE
)
end
end
expose
:base_path
,
if:
->
(
mr
,
_
)
{
mr
.
base_has_license_management_data?
&&
can?
(
current_user
,
:read_build
,
mr
.
base_license_management_artifact
)
}
do
|
merge_request
|
expose
:base_path
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
target_project
,
base_pipeline_downloadable_path_for_report_type
(
:license_management
)
merge_request
.
base_license_management_artifact
,
path:
Ci
::
Build
::
LICENSE_MANAGEMENT_FILE
)
end
end
expose
:managed_licenses_path
do
|
merge_request
|
expose
:managed_licenses_path
do
|
merge_request
|
...
@@ -77,7 +73,7 @@ module EE
...
@@ -77,7 +73,7 @@ module EE
can?
(
current_user
,
:admin_software_license_policy
,
merge_request
)
can?
(
current_user
,
:admin_software_license_policy
,
merge_request
)
end
end
expose
:license_management_settings_path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:admin_software_license_policy
,
mr
.
target_project
)
}
do
|
merge_request
|
expose
:license_management_settings_path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:admin_software_license_policy
,
mr
.
target_project
)
}
do
|
merge_request
|
license_management_settings_path
(
merge_request
.
target_project
)
license_management_settings_path
(
merge_request
.
target_project
)
end
end
...
...
ee/app/views/projects/pipelines/_tabs_content.html.haml
View file @
8642dd89
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
-
if
pipeline
.
expose_license_management_data?
-
if
pipeline
.
expose_license_management_data?
#js-tab-licenses
.tab-pane
#js-tab-licenses
.tab-pane
#js-licenses-app
{
data:
{
license_
head_path:
pipeline
.
expose_license_management_data?
?
license_management_artifact_url
(
pipeline
)
:
nil
,
#js-licenses-app
{
data:
{
license_
management_artifact_url
(
pipeline
)
,
api_url:
license_management_api_url
(
project
),
api_url:
license_management_api_url
(
project
),
license_management_settings_path:
license_management_settings_path
,
license_management_settings_path:
license_management_settings_path
,
can_manage_licenses:
can?
(
current_user
,
:admin_software_license_policy
,
project
).
to_s
}
}
can_manage_licenses:
can?
(
current_user
,
:admin_software_license_policy
,
project
).
to_s
}
}
ee/spec/controllers/projects/pipelines_controller_spec.rb
View file @
8642dd89
...
@@ -83,18 +83,8 @@ describe Projects::PipelinesController do
...
@@ -83,18 +83,8 @@ describe Projects::PipelinesController do
context
'with a license management artifact'
do
context
'with a license management artifact'
do
before
do
before
do
create
(
build
=
create
(
:ci_build
,
pipeline:
pipeline
)
:ci_build
,
create
(
:ee_ci_job_artifact
,
:license_management
,
build:
build
)
:success
,
:artifacts
,
name:
'license_management'
,
pipeline:
pipeline
,
options:
{
artifacts:
{
paths:
[
Ci
::
Build
::
LICENSE_MANAGEMENT_FILE
]
}
}
)
end
end
context
'with feature enabled'
do
context
'with feature enabled'
do
...
...
ee/spec/factories/ci/job_artifacts.rb
View file @
8642dd89
...
@@ -21,5 +21,23 @@ FactoryBot.define do
...
@@ -21,5 +21,23 @@ FactoryBot.define do
Rails
.
root
.
join
(
'ee/spec/fixtures/reports/security/sast_with_corrupted_data.json'
),
'application/json'
)
Rails
.
root
.
join
(
'ee/spec/fixtures/reports/security/sast_with_corrupted_data.json'
),
'application/json'
)
end
end
end
end
trait
:performance
do
file_format
:raw
file_type
:performance
after
(
:build
)
do
|
artifact
,
_
|
artifact
.
file
=
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/trace/sample_trace'
),
'text/plain'
)
end
end
trait
:license_management
do
file_format
:raw
file_type
:license_management
after
(
:build
)
do
|
artifact
,
_
|
artifact
.
file
=
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/trace/sample_trace'
),
'text/plain'
)
end
end
end
end
ee/spec/models/ci/build_spec.rb
View file @
8642dd89
...
@@ -115,71 +115,6 @@ describe Ci::Build do
...
@@ -115,71 +115,6 @@ describe Ci::Build do
end
end
end
end
build_artifacts_methods
=
{
has_license_management_json?:
{
filename:
Ci
::
Build
::
LICENSE_MANAGEMENT_FILE
,
job_names:
%w[license_management]
}
}
build_artifacts_methods
.
each
do
|
method
,
requirements
|
filename
=
requirements
[
:filename
]
job_names
=
requirements
[
:job_names
]
describe
"#
#{
method
}
"
do
job_names
.
each
do
|
job_name
|
context
"with a job named
#{
job_name
}
and a file named
#{
filename
}
"
do
let
(
:build
)
do
create
(
:ci_build
,
:artifacts
,
name:
job_name
,
pipeline:
pipeline
,
options:
{
artifacts:
{
paths:
[
filename
,
'some-other-artifact.txt'
]
}
}
)
end
it
{
expect
(
build
.
send
(
method
)).
to
be_truthy
}
end
end
context
'with an invalid filename'
do
let
(
:build
)
do
create
(
:ci_build
,
:artifacts
,
name:
job_names
.
first
,
pipeline:
pipeline
,
options:
{}
)
end
it
{
expect
(
build
.
send
(
method
)).
to
be_falsey
}
end
context
'with an invalid job name'
do
let
(
:build
)
do
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
,
options:
{
artifacts:
{
paths:
[
filename
,
'some-other-artifact.txt'
]
}
}
)
end
it
{
expect
(
build
.
send
(
method
)).
to
be_falsey
}
end
end
end
describe
'.with_security_reports'
do
describe
'.with_security_reports'
do
subject
{
described_class
.
with_security_reports
}
subject
{
described_class
.
with_security_reports
}
...
...
ee/spec/models/ci/pipeline_spec.rb
View file @
8642dd89
...
@@ -20,70 +20,6 @@ describe Ci::Pipeline do
...
@@ -20,70 +20,6 @@ describe Ci::Pipeline do
end
end
end
end
PIPELINE_ARTIFACTS_METHODS
=
[
{
method: :license_management_artifact
,
options:
[
Ci
::
Build
::
LICENSE_MANAGEMENT_FILE
,
'license_management'
]
}
].
freeze
PIPELINE_ARTIFACTS_METHODS
.
each
do
|
method_test
|
method
,
options
=
method_test
.
values_at
(
:method
,
:options
)
describe
method
.
to_s
do
context
'has corresponding job'
do
let!
(
:build
)
do
filename
,
name
=
options
create
(
:ci_build
,
:artifacts
,
name:
name
,
pipeline:
pipeline
,
options:
{
artifacts:
{
paths:
[
filename
]
}
}
)
end
it
{
expect
(
pipeline
.
send
(
method
)).
to
eq
(
build
)
}
end
context
'no corresponding job'
do
before
do
create
(
:ci_build
,
pipeline:
pipeline
)
end
it
{
expect
(
pipeline
.
send
(
method
)).
to
be_nil
}
end
end
end
%w(performance license_management)
.
each
do
|
type
|
method
=
"has_
#{
type
}
_data?"
describe
"#
#{
method
}
"
do
let
(
:artifact
)
{
double
(
success?:
true
)
}
before
do
allow
(
pipeline
).
to
receive
(
:"
#{
type
}
_artifact"
).
and_return
(
artifact
)
end
it
{
expect
(
pipeline
.
send
(
method
.
to_sym
)).
to
be_truthy
}
end
end
%w(performance license_management)
.
each
do
|
type
|
method
=
"expose_
#{
type
}
_data?"
describe
"#
#{
method
}
"
do
before
do
allow
(
pipeline
).
to
receive
(
:"has_
#{
type
}
_data?"
).
and_return
(
true
)
allow
(
pipeline
.
project
).
to
receive
(
:feature_available?
).
and_return
(
true
)
end
it
{
expect
(
pipeline
.
send
(
method
.
to_sym
)).
to
be_truthy
}
end
end
describe
'#with_legacy_security_reports scope'
do
describe
'#with_legacy_security_reports scope'
do
let
(
:pipeline_1
)
{
create
(
:ci_pipeline_without_jobs
,
project:
project
)
}
let
(
:pipeline_1
)
{
create
(
:ci_pipeline_without_jobs
,
project:
project
)
}
let
(
:pipeline_2
)
{
create
(
:ci_pipeline_without_jobs
,
project:
project
)
}
let
(
:pipeline_2
)
{
create
(
:ci_pipeline_without_jobs
,
project:
project
)
}
...
...
ee/spec/models/merge_request_spec.rb
View file @
8642dd89
...
@@ -40,37 +40,4 @@ describe MergeRequest do
...
@@ -40,37 +40,4 @@ describe MergeRequest do
it
{
expect
(
subject
.
base_pipeline
).
to
eq
(
pipeline
)
}
it
{
expect
(
subject
.
base_pipeline
).
to
eq
(
pipeline
)
}
end
end
describe
'#base_license_management_artifact'
do
before
do
allow
(
subject
.
base_pipeline
).
to
receive
(
:license_management_artifact
)
.
and_return
(
1
)
end
it
'delegates to merge request diff'
do
expect
(
subject
.
base_license_management_artifact
).
to
eq
(
1
)
end
end
describe
'#head_license_management_artifact'
do
before
do
allow
(
subject
.
head_pipeline
).
to
receive
(
:license_management_artifact
)
.
and_return
(
1
)
end
it
'delegates to merge request diff'
do
expect
(
subject
.
head_license_management_artifact
).
to
eq
(
1
)
end
end
describe
'#expose_license_management_data?'
do
before
do
allow
(
subject
.
head_pipeline
).
to
receive
(
:expose_license_management_data?
)
.
and_return
(
1
)
end
it
'delegates to merge request diff'
do
expect
(
subject
.
expose_license_management_data?
).
to
eq
(
1
)
end
end
end
end
ee/spec/serializers/merge_request_widget_entity_spec.rb
View file @
8642dd89
...
@@ -76,16 +76,8 @@ describe MergeRequestWidgetEntity do
...
@@ -76,16 +76,8 @@ describe MergeRequestWidgetEntity do
describe
'#license_management'
do
describe
'#license_management'
do
before
do
before
do
build
=
create
(
:ci_build
,
name:
'license_management'
,
pipeline:
pipeline
)
build
=
create
(
:ci_build
,
pipeline:
pipeline
)
create
(
:ee_ci_job_artifact
,
:license_management
,
build:
build
)
allow
(
merge_request
).
to
receive_messages
(
expose_license_management_data?:
true
,
base_has_license_management_data?:
true
,
base_license_management_artifact:
build
,
head_license_management_artifact:
build
,
head_pipeline:
pipeline
,
target_project:
project
)
end
end
it
'should not be included, if license management features are off'
do
it
'should not be included, if license management features are off'
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