diff --git a/api/handler/v1beta1/appeal.go b/api/handler/v1beta1/appeal.go index fc5f72d22..eaabc70ed 100644 --- a/api/handler/v1beta1/appeal.go +++ b/api/handler/v1beta1/appeal.go @@ -38,7 +38,6 @@ func (s *GRPCServer) ListUserAppeals(ctx context.Context, req *guardianv1beta1.L if req.GetAccountTypes() != nil { filters.AccountTypes = req.GetAccountTypes() } - if req.GetResourceUrns() != nil { filters.ResourceURNs = req.GetResourceUrns() } diff --git a/internal/store/postgres/appeal_repository_test.go b/internal/store/postgres/appeal_repository_test.go index 68de68e56..4a769d3fe 100644 --- a/internal/store/postgres/appeal_repository_test.go +++ b/internal/store/postgres/appeal_repository_test.go @@ -128,6 +128,42 @@ func (s *AppealRepositoryTestSuite) TestGetByID() { s.Nil(actualError) s.Equal(dummyAppeal.ID, actualRecord.ID) }) + + s.Run("should run query based on filters", func() { + dummyAppeal := &domain.Appeal{ + ResourceID: s.dummyResource.ID, + PolicyID: s.dummyPolicy.ID, + PolicyVersion: s.dummyPolicy.Version, + AccountID: "user@example.com", + AccountType: domain.DefaultAppealAccountType, + Role: "role_test", + Permissions: []string{"permission_test"}, + CreatedBy: "user@example.com", + } + testCases := []struct { + filters *domain.ListAppealsFilter + expectedArgs []driver.Value + expectedResult []*domain.Appeal + }{ + { + filters: &domain.ListAppealsFilter{ + Q: "user", + }, + expectedResult: []*domain.Appeal{dummyAppeal}, + }, + { + filters: &domain.ListAppealsFilter{ + AccountTypes: []string{"x-account-type"}, + }, + expectedResult: []*domain.Appeal{dummyAppeal}, + }, + } + + for _, tc := range testCases { + _, actualError := s.repository.Find(context.Background(), tc.filters) + s.Nil(actualError) + } + }) } func (s *AppealRepositoryTestSuite) TestFind() {