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

Add PyPI Observation API integration #1

Merged
merged 12 commits into from
Mar 2, 2024
Merged

Add PyPI Observation API integration #1

merged 12 commits into from
Mar 2, 2024

Conversation

Robin5605
Copy link
Contributor

No description provided.

Put the `httpx.Client` instance in it's own module that can be imported
around as necessary. Essentially a singleton. Also has authentication
information and base URL attached to it, for ease for use.
It makes sense for the root route (`GET /`) to be in the `app.py` module
(where the FastAPI app instance is located). This will probably be
replaced by current Dragonfly Reporter API version later on in a
separate PR, as the [echo
endpoint](https://github.com/pypi/pypi-observation-api-private-beta?tab=readme-ov-file#get-danger-apiecho)
will most likely be removed in v1.
This will make it easier to test compared to a global singleton that
gets imported around - we can simply use FastAPI's [Testing
Dependencies](https://fastapi.tiangolo.com/advanced/testing-dependencies/)
feature.
Since this app only has two endpoints as of now (including the echo
endpoint), it's probably fine to just leave it in app.py
AbooMinister25
AbooMinister25 previously approved these changes Mar 2, 2024
Copy link

@AbooMinister25 AbooMinister25 left a comment

Choose a reason for hiding this comment

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

LGTM for the most part.

Tests don't run in CI if this isn't set to *something*
Add a test case that checks that the "kind" in the payload is set to
"malware," but also that "inspector_url" is not present. Normally, the
Observations API requires that the "inspector_url" field be present if
the kind is "is_malware," so let's see if this endpoint enforces that.
Copy link
Contributor

@jonathan-d-zhang jonathan-d-zhang left a comment

Choose a reason for hiding this comment

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

:shipit:. Note that you'll have to modify the dockerfile if you've changed how to run the server.

Copy link
Contributor

@jonathan-d-zhang jonathan-d-zhang left a comment

Choose a reason for hiding this comment

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

:shipit:

@Robin5605 Robin5605 merged commit e1cdbbf into main Mar 2, 2024
3 checks passed
@Robin5605 Robin5605 deleted the observation-api branch March 2, 2024 04:02
@Xithrius
Copy link
Member

Xithrius commented Mar 3, 2024

I forgor 💀

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.

4 participants