From c40885f44f0c596c7aa1039ceb88a6bff3a978e0 Mon Sep 17 00:00:00 2001 From: Harold Wanyama Date: Mon, 4 Nov 2024 20:37:44 +0300 Subject: [PATCH] [#4472] Approval List search - added case insensitive search for emails Signed-off-by: Harold Wanyama --- cla-backend-go/signatures/service.go | 8 +++++--- cla-backend-go/signatures/service_test.go | 10 ++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cla-backend-go/signatures/service.go b/cla-backend-go/signatures/service.go index f4295df4c..bf01ed100 100644 --- a/cla-backend-go/signatures/service.go +++ b/cla-backend-go/signatures/service.go @@ -1316,9 +1316,11 @@ func (s service) UserIsApproved(ctx context.Context, user *models.User, cclaSign if len(emailApprovalList) > 0 { for _, email := range emails { log.WithFields(f).Debugf("checking email: %s", email) - if utils.StringInSlice(email, emailApprovalList) { - log.WithFields(f).Debugf("found matching email: %s in the email approval list", email) - return true, nil + // case insensitive search + for _, emailApproval := range emailApprovalList { + if strings.EqualFold(email, emailApproval) { + return true, nil + } } } } else { diff --git a/cla-backend-go/signatures/service_test.go b/cla-backend-go/signatures/service_test.go index 9d35f9da2..61e0f2e73 100644 --- a/cla-backend-go/signatures/service_test.go +++ b/cla-backend-go/signatures/service_test.go @@ -70,6 +70,16 @@ func TestUserIsApproved(t *testing.T) { }, expectedIsApproved: true, }, + { + name: "Test user email case - email approval", + user: &v1Models.User{ + Emails: []string{"Foo@gmail.com"}, + }, + cclaSignature: &v1Models.Signature{ + EmailApprovalList: []string{"foo@gmail.com"}, + }, + expectedIsApproved: true, + }, } for _, tc := range testCases {