stable

Clone or download

Read-only

REST route to regenerate webhook secret

You can issue the following REST call: PATCH /gitlab_repositories { "generate_new_secret": { "gitlab_repository_id": 2, "gitlab_repository_url": "https://gitlab.example.com/repo/url" } } This will: 1. Delete the previous webhook (if exists) in corresponding GitLab project 2. Generate a new webhook secret for the repository 3. Create a new webhook in corresponding GitLab project 5. Save the id of the new webhook in DB If we don't know the id of the old webhook (which is the case on existing usages), then it will be kept in the GitLab project. Maintainers will have to remove it by hand. Note: you may need to adjust the SSL verification settings of the new webhook depending on your environment. Note: initial thoughts was to [edit the existing webhook], but implementation seemed to be a little bit more complex than simply remove and create. Part of story #17182: reference tuleap artifacts in gitlab merge requests [edit the existing webhook] https://docs.gitlab.com/ee/api/projects.html#edit-project-hook Change-Id: I7058d600cbd5a5d62aba86eb9f3be3ea6392071c

Modified Files

Name
M plugins/gitlab/include/API/ClientWrapper.php +31 −0 Go to diff View file
M plugins/gitlab/include/REST/v1/GitlabRepositoryPatchRepresentation.php +6 −1 Go to diff View file
M plugins/gitlab/include/REST/v1/GitlabRepositoryResource.php +81 −26 Go to diff View file
A plugins/gitlab/include/REST/v1/GitlabRepositoryWebhookSecretPatchRepresentation.php +39 −0 Go to diff View file
A plugins/gitlab/include/REST/v1/WebhookSecretGenerator.php +131 −0 Go to diff View file
M plugins/gitlab/include/Repository/GitlabRepositoryCreator.php +1 −1 Go to diff View file
M plugins/gitlab/include/Repository/Webhook/WebhookCreator.php +58 −4 Go to diff View file
M plugins/gitlab/include/Repository/Webhook/WebhookDao.php +6 −2 Go to diff View file
M plugins/gitlab/include/gitlabPlugin.php +2 −2 Go to diff View file
M plugins/gitlab/site-content/fr_FR/LC_MESSAGES/tuleap-gitlab.po +20 −1 Go to diff View file
A plugins/gitlab/tests/unit/API/ClientWrapperTest.php +196 −0 Go to diff View file
A plugins/gitlab/tests/unit/REST/v1/WebhookSecretGeneratorTest.php +393 −0 Go to diff View file
M plugins/gitlab/tests/unit/Repository/GitlabRepositoryCreatorTest.php +1 −1 Go to diff View file
M plugins/gitlab/tests/unit/Repository/GitlabRepositoryFactoryTest.php +10 −8 Go to diff View file
M plugins/gitlab/tests/unit/Repository/Webhook/WebhookCreatorTest.php +130 −5 Go to diff View file