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

[temp] Add additional permissions to pulls and test results endpoint #827

Merged
merged 8 commits into from
Sep 19, 2024

Conversation

rohitvinnakota-codecov
Copy link
Contributor

@rohitvinnakota-codecov rohitvinnakota-codecov commented Sep 16, 2024

Purpose/Motivation

What is the feature? Why is this being done?

This change unblocks some short term workflows between Codecov and Sentry's Seer service. Seer will query Codecov's pulls endpoint for a given PR and use coverage information to generate tests.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@codecov-notifications
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.23%. Comparing base (c2a3149) to head (1d8d6a5).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##               main       #827   +/-   ##
===========================================
  Coverage   96.23000   96.23000           
===========================================
  Files           812        812           
  Lines         18567      18575    +8     
===========================================
+ Hits          17868      17876    +8     
  Misses          699        699           
Flag Coverage Δ
unit 92.46% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 92.46% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rohitvinnakota-codecov rohitvinnakota-codecov changed the title [temp] Add supertoken permissions to pulls endpoint [temp] Add supertoken permissions to pulls and test reults endpoint Sep 17, 2024
@rohitvinnakota-codecov rohitvinnakota-codecov changed the title [temp] Add supertoken permissions to pulls and test reults endpoint [temp] Add supertoken permissions to pulls and test results endpoint Sep 17, 2024
Copy link
Contributor

@adrian-codecov adrian-codecov left a comment

Choose a reason for hiding this comment

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

These look good, although I encourage you to also add tests to ensure this works accordingly - check the test_report_viewset.py file as guidance. During local development, use print() to ensure you're going through the authentication class you're expecting

@rohitvinnakota-codecov rohitvinnakota-codecov changed the title [temp] Add supertoken permissions to pulls and test results endpoint [temp] Add additional permissions to pulls and test results endpoint Sep 17, 2024
@rohitvinnakota-codecov
Copy link
Contributor Author

@codecov-ai-reviewer

@codecov-ai
Copy link

codecov-ai bot commented Sep 17, 2024

I've reviewed this Pull Request and have no helpful feedback.

def test_no_pull_if_not_super_token_nor_user_token(
self, repository_artifact_permisssions_has_permission
):
repository_artifact_permisssions_has_permission.return_value = False
Copy link
Contributor

Choose a reason for hiding this comment

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

Just realized there's a typo in permisssions, could you pls change those 🙏

"pullid": self.pulls[0].pullid,
},
),
HTTP_AUTHORIZATION="Bearer testaxs3o76rdcdpfzexuccx3uatui2nw73r",
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: since this test succeeds because the token must match the SUPER_API_TOKEN, perhaps make a constant MOCK_SUPER_API_TOKEN up top and use it where needed

self, repository_artifact_permisssions_has_permission
):
repository_artifact_permisssions_has_permission.return_value = False
res = self.client.post(
Copy link
Contributor

Choose a reason for hiding this comment

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

I also didn't explicitly ask, but you're expecting only GETs to these endpoints right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah

def test_pull_with_valid_super_token(
self, repository_artifact_permisssions_has_permission
):
repository_artifact_permisssions_has_permission.return_value = False
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm actually curious, I don't think we need this mock here. Could you try getting rid of this and see if the test still passes?

Copy link
Contributor

@adrian-codecov adrian-codecov left a comment

Choose a reason for hiding this comment

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

Left some suggestions, those applicable please do to the other test as well, but after that you should be gtg 👏

@rohitvinnakota-codecov rohitvinnakota-codecov added this pull request to the merge queue Sep 19, 2024
Merged via the queue into main with commit c2d571e Sep 19, 2024
18 of 19 checks passed
@rohitvinnakota-codecov rohitvinnakota-codecov deleted the rvinnakota/update-PR-endpoint-perms branch September 19, 2024 16:09
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.

2 participants