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
2ee5dcf2
Commit
2ee5dcf2
authored
Aug 24, 2020
by
Aishwarya Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API to delete group push rule
Adds ability for group owners and admins to delete push rules for a group.
parent
ce721bd7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
19 deletions
+97
-19
doc/api/groups.md
doc/api/groups.md
+22
-0
ee/changelogs/unreleased/delete_group_push_rule.yml
ee/changelogs/unreleased/delete_group_push_rule.yml
+5
-0
ee/lib/api/group_push_rule.rb
ee/lib/api/group_push_rule.rb
+13
-4
ee/spec/requests/api/group_push_rule_spec.rb
ee/spec/requests/api/group_push_rule_spec.rb
+57
-15
No files found.
doc/api/groups.md
View file @
2ee5dcf2
...
...
@@ -1170,10 +1170,14 @@ DELETE /groups/:id/share/:group_id
## Push Rules **(STARTER)**
> Introduced in [GitLab Starter](https://about.gitlab.com/pricing/) 13.4.
### Get group push rules **(STARTER)**
Get the
[
push rules
](
../user/group/index.md#group-push-rules-starter
)
of a group.
Only available to group owners and administrators.
```
plaintext
GET /groups/:id/push_rule
```
...
...
@@ -1215,6 +1219,8 @@ the `commit_committer_check` and `reject_unsigned_commits` parameters:
Adds
[
push rules
](
../user/group/index.md#group-push-rules-starter
)
to the specified group.
Only available to group owners and administrators.
```
plaintext
POST /groups/:id/push_rule
```
...
...
@@ -1260,6 +1266,8 @@ Response:
Edit push rules for a specified group.
Only available to group owners and administrators.
```
plaintext
PUT /groups/:id/push_rule
```
...
...
@@ -1300,3 +1308,17 @@ Response:
"max_file_size"
:
100
}
```
### Delete group push rule **(STARTER)**
Deletes the
[
push rules
](
../user/group/index.md#group-push-rules-starter
)
of a group.
Only available to group owners and administrators.
```
plaintext
DELETE /groups/:id/push_rule
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the group
](
README.md#namespaced-path-encoding
)
|
ee/changelogs/unreleased/delete_group_push_rule.yml
0 → 100644
View file @
2ee5dcf2
---
title
:
API to delete group push rule
merge_request
:
40293
author
:
type
:
added
ee/lib/api/group_push_rule.rb
View file @
2ee5dcf2
...
...
@@ -3,8 +3,7 @@
module
API
class
GroupPushRule
<
Grape
::
API
::
Instance
before
{
authenticate!
}
before
{
authorize_admin_group
}
before
{
check_feature_availability!
}
before
{
check_group_push_rule_access!
}
before
{
authorize_change_param
(
user_group
,
:commit_committer_check
,
:reject_unsigned_commits
)
}
params
do
...
...
@@ -13,8 +12,8 @@ module API
resource
:groups
do
helpers
do
def
check_
feature_availability
!
not_found!
unless
user_group
.
feature_available?
(
:push_rules
)
def
check_
group_push_rule_access
!
not_found!
unless
can?
(
current_user
,
:change_push_rules
,
user_group
)
end
params
:push_rule_params
do
...
...
@@ -82,6 +81,16 @@ module API
render_validation_error!
(
push_rule
)
end
end
desc
'Deletes group push rule'
do
detail
'This feature was introduced in GitLab 13.4.'
end
delete
":id/push_rule"
do
push_rule
=
user_group
.
push_rule
not_found!
unless
push_rule
destroy_conditionally!
(
push_rule
)
end
end
end
end
ee/spec/requests/api/group_push_rule_spec.rb
View file @
2ee5dcf2
...
...
@@ -77,19 +77,19 @@ RSpec.describe API::GroupPushRule, 'GroupPushRule', api: true do
expect
(
json_response
).
to
eq
(
{
"author_email_regex"
=>
attributes
[
:author_email_regex
],
"branch_name_regex"
=>
nil
,
"commit_committer_check"
=>
true
,
"commit_message_negative_regex"
=>
attributes
[
:commit_message_negative_regex
],
"commit_message_regex"
=>
attributes
[
:commit_message_regex
],
"created_at"
=>
group
.
reload
.
push_rule
.
created_at
.
iso8601
(
3
),
"deny_delete_tag"
=>
false
,
"file_name_regex"
=>
nil
,
"id"
=>
group
.
push_rule
.
id
,
"max_file_size"
=>
100
,
"member_check"
=>
false
,
"prevent_secrets"
=>
true
,
"reject_unsigned_commits"
=>
true
"author_email_regex"
=>
attributes
[
:author_email_regex
],
"branch_name_regex"
=>
nil
,
"commit_committer_check"
=>
true
,
"commit_message_negative_regex"
=>
attributes
[
:commit_message_negative_regex
],
"commit_message_regex"
=>
attributes
[
:commit_message_regex
],
"created_at"
=>
group
.
reload
.
push_rule
.
created_at
.
iso8601
(
3
),
"deny_delete_tag"
=>
false
,
"file_name_regex"
=>
nil
,
"id"
=>
group
.
push_rule
.
id
,
"max_file_size"
=>
100
,
"member_check"
=>
false
,
"prevent_secrets"
=>
true
,
"reject_unsigned_commits"
=>
true
}
)
end
...
...
@@ -292,8 +292,8 @@ RSpec.describe API::GroupPushRule, 'GroupPushRule', api: true do
it
'updates attributes as expected'
do
expect
{
subject
}.
to
change
{
group
.
reload
.
push_rule
.
author_email_regex
}
.
from
(
attributes
[
:author_email_regex
])
.
to
(
attributes_for_update
[
:author_email_regex
])
.
from
(
attributes
[
:author_email_regex
])
.
to
(
attributes_for_update
[
:author_email_regex
])
end
context
'when push rule does not exist for group'
do
...
...
@@ -366,4 +366,46 @@ RSpec.describe API::GroupPushRule, 'GroupPushRule', api: true do
end
end
end
describe
'DELETE /groups/:id/push_rule'
do
let_it_be
(
:push_rule
)
{
create
(
:push_rule
,
**
attributes
)
}
let_it_be
(
:group
)
{
create
(
:group
,
push_rule:
push_rule
)
}
context
'authorized user'
do
context
'when licensed'
do
include_context
'licensed features available'
context
'with group push rule'
do
it
do
delete
api
(
"/groups/
#{
group
.
id
}
/push_rule"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
expect
(
group
.
reload
.
push_rule
).
to
be
nil
end
end
context
'when push rule does not exist'
do
it
'returns not found'
do
no_push_rule_group
=
create
(
:group
)
delete
api
(
"/groups/
#{
no_push_rule_group
.
id
}
/push_rule"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
context
'when unlicensed'
do
subject
{
delete
api
(
"/groups/
#{
group
.
id
}
/push_rule"
,
admin
)
}
it_behaves_like
'not found when feature is unavailable'
end
end
context
'permissions'
do
subject
{
delete
api
(
"/groups/
#{
group
.
id
}
/push_rule"
,
user
)
}
it_behaves_like
'allow access to api based on role'
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