Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webhook-service has to work with private repositories #50

Merged
merged 62 commits into from
Mar 7, 2019

Conversation

jachro
Copy link
Contributor

@jachro jachro commented Feb 28, 2019

This PR makes the webhook-service's endpoints to work with private repositories. The changes to the endpoints are:

  • POST /projects/:id/webhooks/validation validates project's hook. The behaviour of the endpoint is the following:
Project visibility Scenario Response code Notes
Public Hook exists OK (200)
Public Hook does not exist NOT_FOUND (404)
Private The given Access Token is valid and hook exists OK (200) The given Access Token replaces the stored one (if there was one in the Token Repository already)
Private The given Access Token is valid but hook does not exist NOT_FOUND (404) Access Token is removed from the Token Repository (if any was stored)
Private The given Access Token is invalid but there's a valid stored Access Token and hook exists OK (200)
Private The given Access Token is invalid but there's a valid stored Access Token and hook does not exist NOT_FOUND (404) Access Token is removed from the Token Repository
Internal INTERNAL_SERVER_ERROR (500)
Any If anything goes wrong INTERNAL_SERVER_ERROR (500)
  • POST /projects/:id/webhooks validates project's hook prior to a new hook is created using the same rules as in the grid above. Then hook is created only for cases marked with NOT_FOUND and the hook creation endpoint responds with CREATED (201). For cases marked in the grid with OK, the hook creation endpoint responds with OK, too.

  • POST /webhooks/events - the endpoint works as before except for private repos events when the endpoint tries to use a stored Access Token. In fact, an attempt to fetch an Access Token is performed regardless of project visibility and if there's no token found, there's an assumption that the event is for a Public project.

closes #42

@jachro jachro force-pushed the validation-for-private-repo branch 2 times, most recently from b3f168b to 063a545 Compare March 1, 2019 14:01
@jachro jachro force-pushed the validation-for-private-repo branch from 063a545 to 42af67a Compare March 1, 2019 15:52
@rokroskar
Copy link
Member

@jachro is this ready to be tested?

@jachro
Copy link
Contributor Author

jachro commented Mar 5, 2019

@rokroskar not yet. I found a bug yesterday and some noise in the logs. I addressed most of that yesterday but need to re-test today.

@lorenzo-cavazzi lorenzo-cavazzi self-requested a review March 7, 2019 15:58
Copy link
Member

@lorenzo-cavazzi lorenzo-cavazzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working for both public and private repos.

Can also be tried it in the UI with these:

@jachro jachro merged commit 36eedf7 into master Mar 7, 2019
@jachro jachro deleted the validation-for-private-repo branch March 7, 2019 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

POST /projects/:id/webhooks/validation for validating project's hook presence
3 participants