try_api: implement /patches endpoint (bug 1979247, bug 1983216)#473
try_api: implement /patches endpoint (bug 1979247, bug 1983216)#473
Conversation
9beacc1 to
19161a2
Compare
6d1386e to
3ac4ed5
Compare
6bd2ed4 to
62e6e99
Compare
59e52b1 to
e28e179
Compare
e28e179 to
8ddf2d4
Compare
04e0d91 to
69ac9bf
Compare
a82fb77 to
24c340d
Compare
|
Now based on #476 as it relies on the permission checking logic. |
9b87c41 to
cf95e87
Compare
zzzeid
left a comment
There was a problem hiding this comment.
Few more changes requested. Overall looking good, main comments are around permission checking.
|
@zzzeid all comments addressed. The permission check changes are in #476, which can be reviewed/landed independently. I'm not sure why this PR here shows conflicts at the moment, as I think it's up-to-date with |
zzzeid
left a comment
There was a problem hiding this comment.
Looking great! Final stretch I think.
src/lando/utils/management/commands/create_environment_repos.py
Outdated
Show resolved
Hide resolved
src/lando/utils/management/commands/create_environment_repos.py
Outdated
Show resolved
Hide resolved
zzzeid
left a comment
There was a problem hiding this comment.
Looks good - just a bit of cleanup in src/lando/main/auth.py and I think this will be ready to land.
I think we should clean up some of this auth backend business in a separate follow up, I'll file a QoL bug for this. Ideally we'd be able to reuse this functionality as a standard auth backend.
Ok, done 😅
Yeah, Ninja diverges ever so slightly from Django auth. That said, I think the way the Token backend currently is, it should be already usable by Django. The Ninja-specific adaptation is done in |
More on this: I think this is already the case.
I've removed the fallback for now, but I think this is what would make the auth backend less standard, as it would now only allow Token-based auth... Though I think that I now see where you're going: do you mean to aim for dedicated auth backends for token vs. OIDC flow, rather than one implementing both, so we can mix and match depending on need? In a way, that's something that would sit better in the mozilla-django-oidc lib, but in a different way than how I implemented it (or maybe very much in the current state of the Anyway, I'm just rambling at this point, and trying to capture my understanding somewhere. Let's chat about it next time we catch up! |
zzzeid
left a comment
There was a problem hiding this comment.
lgtm! (with a couple of nits)
a1eb891 to
c3318bb
Compare
|
@zzzeid I updated AccessTokenLandoOIDCAuthenticationBackend as per your suggestion, and I'm testing in develop. I'll merge this tomorrow. |
|
As part of rebasing this to avoid conflicts, I've managed to cleanly separate
into its own PR: #945 |
03c4ef2 to
e51e03f
Compare
|
Pfiou. Rebased on diff from the force-push: https://github.com/mozilla-conduit/lando/compare/03c4ef2be7bfa79219f5d102329b77c3c3b97e63..e51e03fe56fb1ef056b7f47fb67e9421035c2d5c |
|
Pushing one big squashed commit. |
conftest: add try repo to mocked_repo_config repo: add try_enabled field (bug 1979247) settings: add try_api to APPLICATIONS (bug 1979247) create_environment_repos: add try repo in suite (bug 1986575) try_api: patches endpoint (bug 1979247) try_api: use PatchHelper to parse patches (bug 1979247) try_api: resolve base_commit at submission time (bug 1979247) try_api: test SCM1 auth auth: fix require_permission to return wrapped method utils.auth: add PermissionAccessTokenAuth (bug 1983216) Update src/lando/try_api/api.py Co-authored-by: Connor Sheehan <cosheehan@mozilla.com> utils.auth: don't allow delegated permissions in PermissionAccessTokenAuth utils.exceptions: move problem_exception_handler from treestatus (bug 2008894) This allows us to reuse it verbatim from other modules. utils.exception: add support for ForbiddenProblemException (bug 2008894) try_api: use django.test.clients (bug 2008895) try_api: add error handling with RFC 7807 responses repo: coalesce try_enabled and is_try try_api/tests: add client_post fixture test_transplants: test blocker_scm_permission and add integrated_transplant_without_permissions utils.auth: add user_has_direct_permission models: move user_has_direct_permission to Profile model try_api: check user permission against target_repo try_api: remove extra argument to logger utils.ninja_auth: move AccessTokenLandoOIDCAuthenticationBackend to main.auth, and rename try_api.api: don't set priority on Try jobs try_api.api: don't expose exceptions CommitMap: add TRY_REPO_MAPPING to support determining where to lookup CommitMaps from test_transplants: test blocker_scm_permission and add integrated_transplant_without_permissions utils.auth: add user_has_direct_permission models: move user_has_direct_permission to Profile model Profile: support app_label in has_direct_perm Update src/lando/main/models/profile.py Co-authored-by: Connor Sheehan <cosheehan@mozilla.com> Repo: add user_allowed method to check direct required_permission on User update for Repo.user_allowed tests: update fixtures for Try repo parameters create_environment_repos: disable commit message hook for try Update src/lando/try_api/api.py Co-authored-by: Zeid <2043828+zzzeid@users.noreply.github.com> auth: don't create Django users on API requests try_api: add test for base_commit_vcs values try_api: use SCM rather than VCS in user messaging try_api/tests: don't embed b64 literals create_environment_repos: DRY TRY_HOOKS try_api: move some patchhelper calls out of try/except auth: limit AccessTokenLandoOIDCAuthenticationBackend to token auth without fallback test: ensure that AccessTokenLandoOIDCAuthenticationBackend creates users correctly Apply suggestion from @shtrom Update src/lando/main/auth.py Co-authored-by: Zeid <2043828+zzzeid@users.noreply.github.com> auth: make AccessTokenLandoOIDCAuthenticationBackend behave more closely to OIDCAuthenticationBackend
|
rebased on main |
|
Pull request closed by commit a9f2b20 |
Reimplement the
/try/patchesendpoint from old lando, somach trycan submit Try job to this version of Lando using the same API.is_tryfield (bug 1979247)extraargument to loggerTRY_REPO_MAPPINGto support determining where to lookup CommitMaps fromuser_can_pushmethod to check direct required_permission on User