Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
5ba84fec
Commit
5ba84fec
authored
4 years ago
by
Eva Bardou
Committed by
Bastien Abadie
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Return a 403 when there are no OAuthCredentials for the push hook
parent
0bd968ac
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1244
Return a 403 when there are no OAuthCredentials for the push hook
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/dataimport/api.py
+2
-1
2 additions, 1 deletion
arkindex/dataimport/api.py
arkindex/dataimport/tests/test_providers.py
+9
-0
9 additions, 0 deletions
arkindex/dataimport/tests/test_providers.py
with
11 additions
and
1 deletion
arkindex/dataimport/api.py
+
2
−
1
View file @
5ba84fec
...
...
@@ -505,7 +505,8 @@ class GitRepositoryImportHook(APIView):
def
post
(
self
,
request
,
pk
=
None
,
**
kwargs
):
repo
=
get_object_or_404
(
Repository
,
id
=
pk
)
assert
repo
.
enabled
,
'
No credentials available
'
if
not
repo
.
enabled
:
raise
PermissionDenied
(
detail
=
'
No credentials available for this repository.
'
)
repo
.
provider_class
(
credentials
=
repo
.
credentials
).
handle_webhook
(
repo
,
request
)
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
...
...
This diff is collapsed.
Click to expand it.
arkindex/dataimport/tests/test_providers.py
+
9
−
0
View file @
5ba84fec
...
...
@@ -33,6 +33,15 @@ class TestProviders(FixtureAPITestCase):
glp
=
GitLabProvider
(
credentials
=
self
.
creds
,
url
=
'
something
'
)
self
.
assertEqual
(
glp
.
url
,
'
something
'
)
@patch
(
'
arkindex.dataimport.api.Repository.provider_class
'
)
def
test_webhook_no_credentials
(
self
,
provider_class
):
self
.
client
.
force_login
(
self
.
user
)
self
.
repo
.
credentials
=
None
self
.
repo
.
save
()
response
=
self
.
client
.
post
(
reverse
(
'
api:import-hook
'
,
kwargs
=
{
'
pk
'
:
self
.
repo
.
id
}))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
self
.
assertDictEqual
(
response
.
json
(),
{
'
detail
'
:
'
No credentials available for this repository.
'
})
@patch
(
'
arkindex.dataimport.api.Repository.provider_class
'
)
def
test_webhook
(
self
,
provider_class
):
self
.
client
.
force_login
(
self
.
user
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment