Skip to content

Commit

Permalink
fix(server): Support blank SearchPrincipalRequest (#1158)
Browse files Browse the repository at this point in the history
This removes the requirement set on the Server and CLI that a `SearchPrincipalRequest` must include either an `isAdmin` or `tenantId` flag.
  • Loading branch information
Snarr authored Nov 24, 2024
1 parent 0b88663 commit c4b2d52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lhctl/internal/principal.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package internal

import (
"github.com/littlehorse-enterprises/littlehorse/sdk-go/lhproto"
"github.com/littlehorse-enterprises/littlehorse/sdk-go/littlehorse"
"log"
"os"
"strings"

"github.com/littlehorse-enterprises/littlehorse/sdk-go/lhproto"
"github.com/littlehorse-enterprises/littlehorse/sdk-go/littlehorse"

"github.com/spf13/cobra"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
Expand Down Expand Up @@ -199,7 +200,6 @@ func init() {
searchPrincipalCmd.Flags().Bool("isAdmin", false, "List only Principals that are admins")
searchPrincipalCmd.Flags().Int("earliestMinutesAgo", -1, "Search only for Principals that were created no more than this number of minutes ago")
searchPrincipalCmd.Flags().Int("latestMinutesAgo", -1, "Search only for Principals that were created at least this number of minutes ago")
searchPrincipalCmd.MarkFlagsOneRequired("tenantId", "isAdmin")

deployCmd.AddCommand(deployPrincipalCmd)
deleteCmd.AddCommand(deletePrincipalCmd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Message;
import io.grpc.Status;
import io.littlehorse.common.LHStore;
import io.littlehorse.common.exceptions.LHApiException;
import io.littlehorse.common.model.getable.objectId.PrincipalIdModel;
Expand Down Expand Up @@ -76,8 +75,8 @@ public SearchPrincipalRequest.Builder toProto() throws LHApiException {
case TENANTID:
builder.setTenantId(tenantId);
break;
case PRINCIPALCRITERIA_NOT_SET:
throw new LHApiException(Status.FAILED_PRECONDITION, "Principal query criteria is not valid.");
default:
break;
}

return builder;
Expand Down Expand Up @@ -109,8 +108,8 @@ public void initFrom(Message proto, ExecutionContext context) throws LHSerdeErro
case TENANTID:
tenantId = p.getTenantId();
break;
case PRINCIPALCRITERIA_NOT_SET:
throw new LHSerdeError("Principal query criteria is not valid.");
default:
break;
}
}

Expand Down

0 comments on commit c4b2d52

Please sign in to comment.