-
Notifications
You must be signed in to change notification settings - Fork 795
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
3078 test unauthenticated requests rejected #3217
3078 test unauthenticated requests rejected #3217
Conversation
def test_unauthenticated_user_cannot_access_API(island): | ||
island_requests = MonkeyIslandRequests(island) | ||
|
||
assert ( | ||
island_requests.post(AGENT_EVENTS_ENDPOINT, data=None).status_code | ||
== HTTPStatus.UNAUTHORIZED | ||
) | ||
assert ( | ||
island_requests.post(AGENT_HEARTBEAT_ENDPOINT, data=None).status_code | ||
== HTTPStatus.UNAUTHORIZED | ||
) | ||
assert island_requests.put(PUT_LOG_ENDPOINT, data=None).status_code == HTTPStatus.UNAUTHORIZED | ||
assert island_requests.get(GET_AGENT_PLUGINS_ENDPOINT).status_code == HTTPStatus.UNAUTHORIZED | ||
assert ( | ||
island_requests.get("/api/agent-plugins/plugin-type/plugin-name/manifest").status_code | ||
== HTTPStatus.UNAUTHORIZED | ||
) | ||
assert island_requests.get(GET_AGENT_SIGNALS_ENDPOINT).status_code == HTTPStatus.UNAUTHORIZED | ||
assert ( | ||
island_requests.post(GET_AGENTS_ENDPOINT, data=None).status_code == HTTPStatus.UNAUTHORIZED | ||
) | ||
assert island_requests.get(GET_AGENT_EVENTS_ENDPOINT).status_code == HTTPStatus.UNAUTHORIZED | ||
assert island_requests.get(PUT_LOG_ENDPOINT).status_code == HTTPStatus.UNAUTHORIZED | ||
assert ( | ||
island_requests.post(TERMINATE_AGENTS_ENDPOINT, data=None).status_code | ||
== HTTPStatus.UNAUTHORIZED | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long test. At least let's divide them by method: POST, GET, and PUT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think an all around better approach would be to publish something like an OpenAPI spec and then redesign this test to programatically try all endpoints, but that's out of scope for this release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaking these up could result in a large number of login requests which is unnecessary. A whole lot of refactoring needs to happen in this file anyway. I say we just push it until later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comment
bb68f97
to
ea5323c
Compare
What does this PR do?
Add a blackbox test to verify API rejects unauthenticated requests.
Merge after #3216
PR Checklist
Was the CHANGELOG.md updated to reflect the changes?Was the documentation framework updated to reflect the changes?Testing Checklist
Added relevant unit tests?If applicable, add screenshots or log transcripts of the feature working