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 test for ParseRelation function #1050

Merged
merged 4 commits into from
Sep 29, 2023

Conversation

kian99
Copy link
Contributor

@kian99 kian99 commented Sep 29, 2023

Description

  • Ensure all valid relation strings can be parsed to a relation type

Currently a command like ./jimmctl auth relation check user-kian-parvin@external audit_log_viewer controller-jimm fails with the error ERROR unknown relation (failed to parse tuple object key) because the audit_log_viewer relation wasn't added to the ParseRelation function.

Added a test to make sure we can catch this in the future, and found we also didn't have the controller and model relation strings mapped (possibly intentionally? though I don't see why).

Engineering checklist

Check only items that apply

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

- Ensure all valid relation strings can be parsed to a relation type
@@ -36,6 +38,10 @@ var (
NoRelation cofga.Relation = ""
)

// AllRelations contains a slice of all valid relations.
// NB: Add any new relations from the above to this slice.
var AllRelations = []cofga.Relation{MemberRelation, AdministratorRelation, ControllerRelation, ModelRelation, ConsumerRelation, ReaderRelation, WriterRelation, CanAddModelRelation, AuditLogViewerRelation, NoRelation}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this only used in the test?

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 it is, do you want me to make it unexported?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it's best to keep it just visible for the test files.

@kian99 kian99 merged commit de480ca into canonical:feature-rebac Sep 29, 2023
2 checks passed
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