Page MenuHomeSoftware Heritage

save_origin_webhooks: Handle private repositories
ClosedPublic

Authored by anlambert on Nov 21 2022, 5:40 PM.

Details

Summary

Private repositories cannot be cloned without authentication so we
cannot create save requests for those.

So return an HTTP 400 error code when receiving push webhooks for such
repositories and inform users about the fact they cannot be publicly
cloned.

Related to T4548

Depends on D8867

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D8868 (id=31960)

Could not rebase; Attempt merge onto 01e50d60cd...

Updating 01e50d60..1b8992d5
Fast-forward
 swh/web/save_origin_webhooks/bitbucket.py          |  6 ++-
 swh/web/save_origin_webhooks/generic_receiver.py   | 16 ++++++-
 swh/web/save_origin_webhooks/gitea.py              |  6 ++-
 swh/web/save_origin_webhooks/github.py             |  9 +++-
 swh/web/save_origin_webhooks/gitlab.py             |  9 +++-
 swh/web/save_origin_webhooks/sourceforge.py        |  6 ++-
 .../save_origin_webhooks/tests/test_bitbucket.py   | 17 ++++++++
 swh/web/save_origin_webhooks/tests/test_gitea.py   | 16 +++++++
 swh/web/save_origin_webhooks/tests/test_github.py  | 39 +++++++++++++++++
 swh/web/save_origin_webhooks/tests/test_gitlab.py  | 17 ++++++++
 .../save_origin_webhooks/tests/test_sourceforge.py | 49 ++++++++++++++++++++++
 swh/web/save_origin_webhooks/tests/utils.py        | 38 ++++++++++++++---
 12 files changed, 210 insertions(+), 18 deletions(-)
Changes applied before test
commit 1b8992d585a0770336fcc7ef55dead1a57564741
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Mon Nov 21 17:36:21 2022 +0100

    save_origin_webhooks: Handle private repositories
    
    Private repositories cannot be cloned without authentication so we
    cannot create save requests for those.
    
    So return an HTTP 400 error code when receiving push webhooks for such
    repositories and inform users about the fact they cannot be publicly
    cloned.
    
    Related to T4548

commit 84922dfd698b65eceaaedf2fc3cbfeccc792f728
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Mon Nov 21 15:42:17 2022 +0100

    save_origin_webhooks: Handle github ping event
    
    Previously, github webhook receiver was returning a 400 HTTP error code
    for a ping event which can be confusing for users so ensure to return
    a 200 HTTP code.
    
    Related to T4548

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/2158/ for more details.

This revision is now accepted and ready to land.Nov 21 2022, 7:06 PM