fix(user): add search query for login name (#4173)

* fix(user): add search query for login name

* fix(user): change login name query to IN from EXISTS

* fix(loginname): include InQuery into ListQuery with SubSelect as possible datasource

* fix(user): apply suggestions from code review

Co-authored-by: Livio Spring <livio.a@gmail.com>

* fix: correct unit test for search query

Co-authored-by: Fabi <38692350+hifabienne@users.noreply.github.com>
Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
Stefan Benz
2022-10-31 13:03:23 +00:00
committed by GitHub
parent 92eeb68be9
commit 5d17da542d
10 changed files with 801 additions and 22 deletions

View File

@@ -85,9 +85,9 @@ func hostFromContext(ctx context.Context, headerName string) (string, error) {
return host[0], nil
}
//isAllowedToSendHTTP1Header check if the gRPC call was sent to `localhost`
//this is only possible when calling the server directly running on localhost
//or through the gRPC gateway
// isAllowedToSendHTTP1Header check if the gRPC call was sent to `localhost`
// this is only possible when calling the server directly running on localhost
// or through the gRPC gateway
func isAllowedToSendHTTP1Header(md metadata.MD) bool {
authority, ok := md[":authority"]
return ok && len(authority) == 1 && strings.Split(authority[0], ":")[0] == "localhost"

View File

@@ -36,6 +36,8 @@ func UserQueryToQuery(query *user_pb.SearchQuery) (query.SearchQuery, error) {
return StateQueryToQuery(q.StateQuery)
case *user_pb.SearchQuery_TypeQuery:
return TypeQueryToQuery(q.TypeQuery)
case *user_pb.SearchQuery_LoginNameQuery:
return LoginNameQueryToQuery(q.LoginNameQuery)
case *user_pb.SearchQuery_ResourceOwner:
return ResourceOwnerQueryToQuery(q.ResourceOwner)
default:
@@ -75,6 +77,10 @@ func TypeQueryToQuery(q *user_pb.TypeQuery) (query.SearchQuery, error) {
return query.NewUserTypeSearchQuery(int32(q.Type))
}
func LoginNameQueryToQuery(q *user_pb.LoginNameQuery) (query.SearchQuery, error) {
return query.NewUserLoginNameExistsQuery(q.LoginName, object.TextMethodToQuery(q.Method))
}
func ResourceOwnerQueryToQuery(q *user_pb.ResourceOwnerQuery) (query.SearchQuery, error) {
return query.NewUserResourceOwnerSearchQuery(q.OrgID, query.TextEquals)
}

View File

@@ -65,8 +65,8 @@ func (i *spaHandler) Open(name string) (http.File, error) {
return &file{File: f}, nil
}
//file wraps the http.File and fs.FileInfo interfaces
//to return the build.Date() as ModTime() of the file
// file wraps the http.File and fs.FileInfo interfaces
// to return the build.Date() as ModTime() of the file
type file struct {
http.File
fs.FileInfo