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

enhancement: Add support for test fixtures #294

Merged
merged 36 commits into from
Sep 20, 2021

Conversation

dbuduev
Copy link
Contributor

@dbuduev dbuduev commented Sep 15, 2021

Description

Adds support for test fixtures.
Discussion: #285

Fixes #14

Checklist

  • The PR title has the correct prefix
  • PR is linked to the corresponding issue
  • All commits are signed-off (git commit -s ...) to provide the DCO

Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Copy link
Contributor

@charithe charithe left a comment

Choose a reason for hiding this comment

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

Looking good 👍🏽 I didn't dive too deep because it's still a draft but I pointed out some of the things that stood out to me.

One thing I am wondering is whether we should support inline principal and resource definitions as well. Otherwise, in order to get a test suite up, the user needs to create three files and a directory -- which is a lot of ceremony. I think we should make it very easy to get started writing tests and then refactor them as they get complicated. WDYT?

Finally, once the implementation is done, let's remember to update the testing documentation and the photo-share tutorial to reflect the changes made here.

api/public/cerbos/policy/v1/policy.proto Outdated Show resolved Hide resolved
api/public/cerbos/policy/v1/policy.proto Outdated Show resolved Hide resolved
internal/util/filesystem.go Outdated Show resolved Hide resolved
internal/verify/verify.go Outdated Show resolved Hide resolved
@dbuduev dbuduev marked this pull request as ready for review September 16, 2021 07:15
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
@dbuduev
Copy link
Contributor Author

dbuduev commented Sep 17, 2021

I have implemented the changes you have proposed including the embedded principals and resources option.

TODO:

  • update the documentation
  • check whether misconfigured tests error reporting has good UX

Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
api/public/cerbos/policy/v1/policy.proto Outdated Show resolved Hide resolved
internal/verify/test_fixture.go Outdated Show resolved Hide resolved
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Copy link
Contributor

@charithe charithe left a comment

Choose a reason for hiding this comment

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

Almost there. Just a few small things to address.

docs/modules/policies/pages/compile.adoc Outdated Show resolved Hide resolved
docs/modules/policies/pages/compile.adoc Outdated Show resolved Hide resolved
docs/modules/policies/pages/compile.adoc Outdated Show resolved Hide resolved
docs/modules/policies/pages/compile.adoc Show resolved Hide resolved
internal/verify/verify.go Outdated Show resolved Hide resolved
dbuduev and others added 5 commits September 20, 2021 19:39
Co-authored-by: Charith Ellawala <charithe@users.noreply.github.com>
Co-authored-by: Charith Ellawala <charithe@users.noreply.github.com>
Co-authored-by: Charith Ellawala <charithe@users.noreply.github.com>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Signed-off-by: Dennis Buduev <dennis@cerbos.dev>
Copy link
Contributor

@charithe charithe left a comment

Choose a reason for hiding this comment

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

LGTM. Nice job 👍🏽

@charithe
Copy link
Contributor

I'll do a sudo merge to override the protobuf check.

@charithe charithe merged commit 2596673 into cerbos:main Sep 20, 2021
@dbuduev dbuduev deleted the add-ext-refs-to-tests branch September 21, 2021 00:22
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.

Support for test fixtures
2 participants