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

stub endpoints should still have working authz + coverage #885

Merged
merged 15 commits into from
Apr 7, 2022

Conversation

davepacheco
Copy link
Collaborator

@davepacheco davepacheco commented Apr 6, 2022

Supersedes #809.

This change:

  • causes unimplemented endpoints to return a valid response rather than panicking (like Return errors rather than panicking for callable APIs #809)
  • also implements authn/authz behavior that matches what we expect the finished endpoint to look like
  • also stops using expectorate to check the allowlist as discussed in chat

This was more complicated than discussed in chat, mainly because the coverage tests checks more cases than can be handled by a simple Nexus::unimplemented() function.

@davepacheco
Copy link
Collaborator Author

Depends on #873.

@davepacheco davepacheco changed the base branch from main to lookup-authorized-try-2 April 6, 2022 01:29
@davepacheco davepacheco changed the base branch from lookup-authorized-try-2 to main April 6, 2022 01:29
@davepacheco davepacheco marked this pull request as ready for review April 6, 2022 20:50
@davepacheco davepacheco requested a review from ahl April 6, 2022 20:50
nexus/src/lib.rs Outdated Show resolved Hide resolved
Co-authored-by: Justin Bennett <oss@just-be.dev>
Copy link
Contributor

@ahl ahl left a comment

Choose a reason for hiding this comment

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

so good!

/// HTTP "GET" method that is not yet implemented
///
/// This should be a transient state, used only for stub APIs
GetUnimplemented,
Copy link
Contributor

Choose a reason for hiding this comment

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

do we anticipate needing this for other methods? e.g. PostUnimplemented?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think so. For everything other than GET, we only make requests that we expect to fail for authn/authz reasons. For GET, do that, but we also make a request with a privileged user that we expect to succeed. GetUnimplemented changes our expectation about this privileged request -- that it will fail with a 500.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a comment to this effect on this variant and the previous variant in c4d8e1f.

// behavior for unauthenticated and unauthorized users. DO NOT SKIP THIS.
// Even if you're just adding a stub, see [`Nexus::unimplemented_todo()`].
// If you _added_ a test that covered an endpoint from the allowlist --
// hooray! Just delete the corresponding line from this file.
Copy link
Contributor

Choose a reason for hiding this comment

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

yes! You might even say:

Why is this not expectorate:::assert_contents? Because this file should only shrink a line at a time; if you find yourself adding something you're probably doing something wrong and you deserve to suffer. Muahahahaha.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a comment about this in c4d8e1f. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Less colorful than I would have preferred... but ok.

@davepacheco davepacheco enabled auto-merge (squash) April 7, 2022 22:55
@davepacheco davepacheco merged commit 8061338 into main Apr 7, 2022
@davepacheco davepacheco deleted the unauthz-coverage branch April 7, 2022 23:33
@davepacheco davepacheco mentioned this pull request Apr 7, 2022
71 tasks
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.

3 participants