diff --git a/server/modules/elastic/elastictransport.go b/server/modules/elastic/elastictransport.go index 2fd0565a..fbbcc7d7 100644 --- a/server/modules/elastic/elastictransport.go +++ b/server/modules/elastic/elastictransport.go @@ -10,6 +10,7 @@ import ( "crypto/tls" "net" "net/http" + "strings" "time" "github.com/apex/log" @@ -49,7 +50,7 @@ func (transport *ElasticTransport) RoundTrip(req *http.Request) (*http.Response, "searchUsername": user.SearchUsername, "requestId": req.Context().Value(web.ContextKeyRequestId), }).Debug("Executing Elastic request on behalf of user") - username := user.Email + username := strings.ToLower(user.Email) if user.SearchUsername != "" { username = user.SearchUsername } diff --git a/server/modules/elastic/elastictransport_test.go b/server/modules/elastic/elastictransport_test.go index 8a2ada10..5555ec41 100644 --- a/server/modules/elastic/elastictransport_test.go +++ b/server/modules/elastic/elastictransport_test.go @@ -31,7 +31,7 @@ func TestRoundTrip(tester *testing.T) { transport.internal = dummy user := model.NewUser() - user.Email = "test" + user.Email = "Test" request, _ := http.NewRequest("GET", "", nil) request = request.WithContext(context.WithValue(context.Background(), web.ContextKeyRequestor, user)) transport.RoundTrip(request) @@ -44,10 +44,10 @@ func TestRoundTripSearchUsername(tester *testing.T) { transport.internal = dummy user := model.NewUser() - user.Email = "test" - user.SearchUsername = "mysearchuser" + user.Email = "Test" + user.SearchUsername = "Mysearchuser" request, _ := http.NewRequest("GET", "", nil) request = request.WithContext(context.WithValue(context.Background(), web.ContextKeyRequestor, user)) transport.RoundTrip(request) - assert.Equal(tester, "mysearchuser", dummy.username) + assert.Equal(tester, "Mysearchuser", dummy.username) }