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

Update to protovalidate & properly validate for namespaces #139

Merged
merged 5 commits into from
Aug 22, 2024

Conversation

lennysgarage
Copy link
Contributor

@lennysgarage lennysgarage commented Aug 20, 2024

PR Template:

Describe your changes

  • Upgrade from protoc-gen-validate to protovalidate
    • proto files validation updated
    • no longer uses validate.go files
    • Requests are now recursively validated through all embedded sub-messages
  • Updated ALL tests with a "rbac" namespace as required by our proto spec
  • Validation removed from service components to validation middleware to handle all validation requests
    • Added test cases for validation middleware in validation_test.go
    • Removed test cases that were just covering validation aspects of old service code. (TestLookupService_LookupSubjects_EmptyRequest, TestLookupService_LookupResources_EmptyRequest, TestLookupService_LookupResources_Empty)

When missing namespace:

ERROR:
  Code: InvalidArgument
  Message: validation error:
 - resource.type.namespace: value length must be at least 1 characters [string.min_len]
 - subject_type.namespace: value length must be at least 1 characters [string.min_len]
  Details:
  1)	{
    	  "@type": "type.googleapis.com/google.rpc.ErrorInfo",
    	  "reason": "Invalid request"
    	}

Ticket reference (if applicable)

Fixes # RHCLOUD-33724

Checklist

  • Are the agreed upon acceptance criteria fulfilled?

  • Was the 4-eye-principle applied? (async PR review, pairing, ensembling)

  • Do your changes have passing automated tests and sufficient observability?

  • Are the work steps you introduced repeatable by others, either through automation or documentation?

    • If automation is possible but not done due to other constraints, a ticket to the tech debt sprint is added
    • An SOP (Standard Operating Procedure) was created
  • The Changes were automatically built, tested, and - if needed, behind a feature flag - deployed to our production environment. (Please check this when the new deployment is done and you could verify it.)

  • Are the agreed upon coding/architectural practices applied?

  • Are security needs fullfilled? (e.g. no internal URL)

  • Is the corresponding Ticket in the right state? (should be on "review" now, put to done when this change made it to production)

  • For changes to the public API / code dependencies: Was the whole team (or a sufficient amount of ppl) able to review?

@lennysgarage lennysgarage mentioned this pull request Aug 20, 2024
11 tasks
Signed-off-by: Jonathan Marcantonio <[email protected]>
Signed-off-by: Jonathan Marcantonio <[email protected]>
Signed-off-by: Jonathan Marcantonio <[email protected]>
Copy link
Contributor

@merlante merlante left a comment

Choose a reason for hiding this comment

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

Well done, nicely handled with the middleware tests!

LGTM

@lennysgarage lennysgarage merged commit 7a002b5 into main Aug 22, 2024
7 checks passed
@lennysgarage lennysgarage deleted the RHCLOUD-33724 branch September 19, 2024 14:38
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