-
Notifications
You must be signed in to change notification settings - Fork 38
feat: migrate policy APIs to Connect RPC #1164
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pull Request Test Coverage Report for Build 18153861202Details
💛 - Coveralls |
- Migrate CreatePolicy from gRPC to Connect RPC format - Add comprehensive test coverage with 8 scenarios - Preserve identical business logic and error handling - Add Connect RPC error mappings for role.ErrInvalidID and policy.ErrInvalidDetail - Include metadata handling and audit logging functionality
- Migrate GetPolicy from gRPC to Connect RPC format - Add comprehensive test coverage with 6 scenarios - Preserve identical business logic and error handling - Map policy errors (ErrNotExist, ErrInvalidUUID, ErrInvalidID) to ErrPolicyNotFound - Use Connect error codes (NotFound, Internal) for proper HTTP status mapping - Include metadata transformation error handling
23ad5d1
to
25d45ae
Compare
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.
Pull Request Overview
This PR migrates 6 policy APIs from gRPC to Connect RPC format, completing the IAM API standardization initiative. The migration follows established patterns for Connect RPC implementation while preserving identical business logic.
- Migration of all 6 policy APIs to Connect RPC with proper request/response wrapping
- Addition of comprehensive test coverage for all migrated APIs
- Implementation of proper error handling with Connect error codes
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
internal/api/v1beta1connect/relation.go | Removed unused ErrNamespaceSplitNotation error variable |
internal/api/v1beta1connect/policy_test.go | Added comprehensive test suite for all 6 policy Connect RPC endpoints |
internal/api/v1beta1connect/policy.go | Implemented all 6 policy Connect RPC endpoints with proper error handling |
internal/api/v1beta1connect/mocks/policy_service.go | Generated mock service interface for policy service |
internal/api/v1beta1connect/errors.go | Added policy-specific error constants |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
||
resourceType, resourceID, err := schema.SplitNamespaceAndResourceID(request.Msg.GetBody().GetResource()) | ||
if err != nil { | ||
return nil, connect.NewError(connect.CodeInvalidArgument, ErrNamespaceSplitNotation) |
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.
ErrNamespaceSplitNotation is being referenced but was removed from relation.go. This will cause a compile error since the error is not defined in this file.
Copilot uses AI. Check for mistakes.
} | ||
principalType, principalID, err := schema.SplitNamespaceAndResourceID(request.Msg.GetBody().GetPrincipal()) | ||
if err != nil { | ||
return nil, connect.NewError(connect.CodeInvalidArgument, ErrNamespaceSplitNotation) |
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.
ErrNamespaceSplitNotation is being referenced but was removed from relation.go. This will cause a compile error since the error is not defined in this file.
Copilot uses AI. Check for mistakes.
|
||
principalType, principalID, err := schema.SplitNamespaceAndResourceID(request.Msg.GetBody().GetPrincipal()) | ||
if err != nil { | ||
return nil, connect.NewError(connect.CodeInvalidArgument, ErrNamespaceSplitNotation) |
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.
ErrNamespaceSplitNotation is being referenced but was removed from relation.go. This will cause a compile error since the error is not defined in this file.
Copilot uses AI. Check for mistakes.
}, | ||
}), | ||
want: nil, | ||
wantErr: ErrNamespaceSplitNotation, |
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.
ErrNamespaceSplitNotation is being referenced in the test but was removed from relation.go. This will cause a compile error since the error is not defined.
wantErr: ErrNamespaceSplitNotation, | |
wantErr: ErrBadRequest, |
Copilot uses AI. Check for mistakes.
Summary
Migrate 6 policy APIs from gRPC to Connect RPC format as part of the IAM API standardization initiative.
APIs to Migrate
Progress: 6/6 APIs Complete (100%) 🎉
Implementation Details
✅ CreatePolicy (COMPLETED)
Files Changed:
internal/api/v1beta1connect/policy.go
- Connect RPC implementationinternal/api/v1beta1connect/policy_test.go
- Comprehensive test suite with 8 scenariosinternal/api/v1beta1connect/mocks/policy_service.go
- Mock service interfaceKey Features:
connect.Request[T]
andconnect.Response[T]
Test Coverage:
✅ GetPolicy (COMPLETED)
Files Changed:
internal/api/v1beta1connect/errors.go
- AddedErrPolicyNotFound
error constantinternal/api/v1beta1connect/policy.go
- Added GetPolicy Connect RPC implementationinternal/api/v1beta1connect/policy_test.go
- Added comprehensive test suiteKey Features:
CodeNotFound
for missing policies,CodeInternal
for service errorsTest Coverage:
✅ ListPolicies (COMPLETED)
Files Changed:
internal/api/v1beta1connect/policy.go
- Added ListPolicies Connect RPC implementation and resolveFilter helperinternal/api/v1beta1connect/policy_test.go
- Added comprehensive test suiteKey Features:
CodeInvalidArgument
for filter errors,CodeInternal
for service errorsTest Coverage:
✅ UpdatePolicy (COMPLETED)
Files Changed:
internal/api/v1beta1connect/policy.go
- Added UpdatePolicy Connect RPC implementationinternal/api/v1beta1connect/policy_test.go
- Added test suiteKey Features:
CodeUnimplemented
with proper error messageTest Coverage:
✅ DeletePolicy (COMPLETED)
Files Changed:
internal/api/v1beta1connect/policy.go
- Added DeletePolicy Connect RPC implementationinternal/api/v1beta1connect/policy_test.go
- Added comprehensive test suiteKey Features:
CodeNotFound
for missing policies,CodeInvalidArgument
for invalid details,CodeAlreadyExists
for conflicts,CodeInternal
for service errorsTest Coverage:
✅ CreatePolicyForProject (COMPLETED)
Files Changed:
internal/api/v1beta1connect/errors.go
- AddedErrProjectNotFound
error constantinternal/api/v1beta1connect/policy.go
- Added CreatePolicyForProject Connect RPC implementationinternal/api/v1beta1connect/policy_test.go
- Added comprehensive test suiteKey Features:
CodeInvalidArgument
for validation errors,CodeNotFound
for missing projects,CodeInternal
for service errorsTest Coverage:
Testing
Migration Pattern
Each API follows the established Connect RPC migration pattern:
request.Msg.GetFieldName()
connect.NewResponse()
Status
✅ MIGRATION COMPLETE - All 6 policy APIs successfully migrated to Connect RPC!