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
58126159
Commit
58126159
authored
Oct 16, 2017
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make push rule to reject unsigned commits EEP only
parent
a1c5e146
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
62 additions
and
9 deletions
+62
-9
app/models/license.rb
app/models/license.rb
+2
-0
app/models/push_rule.rb
app/models/push_rule.rb
+1
-0
app/views/admin/push_rules/show.html.haml
app/views/admin/push_rules/show.html.haml
+1
-1
app/views/projects/push_rules/_index.html.haml
app/views/projects/push_rules/_index.html.haml
+1
-1
app/views/shared/push_rules/_form.html.haml
app/views/shared/push_rules/_form.html.haml
+1
-7
app/views/shared/push_rules/_reject_unsigned_commits_setting.html.haml
...red/push_rules/_reject_unsigned_commits_setting.html.haml
+12
-0
spec/features/admin/admin_push_rules_spec.rb
spec/features/admin/admin_push_rules_spec.rb
+33
-0
spec/models/push_rule_spec.rb
spec/models/push_rule_spec.rb
+11
-0
No files found.
app/models/license.rb
View file @
58126159
...
...
@@ -47,6 +47,7 @@ class License < ActiveRecord::Base
object_storage
service_desk
variable_environment_scope
reject_unsigned_commits
]
.
freeze
EEU_FEATURES
=
EEP_FEATURES
...
...
@@ -115,6 +116,7 @@ class License < ActiveRecord::Base
multiple_ldap_servers
object_storage
repository_size_limit
reject_unsigned_commits
]
.
freeze
validate
:valid_license
...
...
app/models/push_rule.rb
View file @
58126159
...
...
@@ -22,6 +22,7 @@ class PushRule < ActiveRecord::Base
end
def
commit_signature_allowed?
(
commit
)
return
true
unless
License
.
feature_available?
(
:reject_unsigned_commits
)
return
true
unless
reject_unsigned_commits
commit
.
has_signature?
...
...
app/views/admin/push_rules/show.html.haml
View file @
58126159
...
...
@@ -11,4 +11,4 @@
.alert.alert-danger
-
@push_rule
.
errors
.
full_messages
.
each
do
|
msg
|
%p
=
msg
=
render
"shared/push_rules
_
form"
,
f:
f
=
render
"shared/push_rules
/
form"
,
f:
f
app/views/projects/push_rules/_index.html.haml
View file @
58126159
...
...
@@ -15,4 +15,4 @@
=
form_for
[
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
@push_rule
]
do
|
f
|
=
form_errors
(
@push_rule
)
=
render
"shared/push_rules
_
form"
,
f:
f
=
render
"shared/push_rules
/
form"
,
f:
f
app/views/shared/
_push_rules
_form.html.haml
→
app/views/shared/
push_rules/
_form.html.haml
View file @
58126159
.form-group
=
f
.
check_box
:reject_unsigned_commits
,
class:
"pull-left"
,
disabled:
!
can_change_reject_unsigned_commits?
(
f
.
object
)
.prepend-left-20
=
f
.
label
:reject_unsigned_commits
,
class:
"label-light append-bottom-0"
do
Reject unsigned commits
%p
.light.append-bottom-0
=
reject_unsigned_commits_description
(
f
.
object
)
=
render
'shared/push_rules/reject_unsigned_commits_setting'
,
form:
f
,
push_rule:
f
.
object
.form-group
=
f
.
check_box
:deny_delete_tag
,
class:
"pull-left"
...
...
app/views/shared/push_rules/_reject_unsigned_commits_setting.html.haml
0 → 100644
View file @
58126159
-
return
unless
License
.
feature_available?
(
:reject_unsigned_commits
)
-
form
=
local_assigns
.
fetch
(
:form
)
-
push_rule
=
local_assigns
.
fetch
(
:push_rule
)
.form-group
=
form
.
check_box
:reject_unsigned_commits
,
class:
"pull-left"
,
disabled:
!
can_change_reject_unsigned_commits?
(
push_rule
)
.prepend-left-20
=
form
.
label
:reject_unsigned_commits
,
class:
"label-light append-bottom-0"
do
Reject unsigned commits
%p
.light.append-bottom-0
=
reject_unsigned_commits_description
(
push_rule
)
spec/features/admin/admin_push_rules_spec.rb
0 → 100644
View file @
58126159
require
'spec_helper'
describe
"Admin::PushRules"
do
let
(
:current_user
)
{
create
(
:admin
)
}
before
do
sign_in
(
current_user
)
end
context
'when reject_unsigned_commits is unlicensed'
do
before
do
stub_licensed_features
(
reject_unsigned_commits:
false
)
end
it
'does not render the setting checkbox'
do
visit
admin_push_rule_path
expect
(
page
).
not_to
have_content
(
'Reject unsigned commits'
)
end
end
context
'when reject_unsigned_commits is licensed'
do
before
do
stub_licensed_features
(
reject_unsigned_commits:
true
)
end
it
'renders the setting checkbox'
do
visit
admin_push_rule_path
expect
(
page
).
to
have_content
(
'Reject unsigned commits'
)
end
end
end
spec/models/push_rule_spec.rb
View file @
58126159
...
...
@@ -52,6 +52,17 @@ describe PushRule do
let
(
:signed_commit
)
{
double
(
has_signature?:
true
)
}
let
(
:unsigned_commit
)
{
double
(
has_signature?:
false
)
}
context
'when feature is not licensed and it is enabled'
do
before
do
stub_licensed_features
(
reject_unsigned_commits:
false
)
global_push_rule
.
update_attribute
(
:reject_unsigned_commits
,
true
)
end
it
'accepts unsigned commits'
do
expect
(
push_rule
.
commit_signature_allowed?
(
unsigned_commit
)).
to
eq
(
true
)
end
end
context
'when enabled at a global level'
do
before
do
global_push_rule
.
update_attribute
(
:reject_unsigned_commits
,
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