Skip to content

Commit

Permalink
[#4472] Approval List search
Browse files Browse the repository at this point in the history
- added case insensitive search for emails

Signed-off-by: Harold Wanyama <[email protected]>
  • Loading branch information
nickmango committed Nov 4, 2024
1 parent 373849c commit c40885f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cla-backend-go/signatures/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions cla-backend-go/signatures/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ func TestUserIsApproved(t *testing.T) {
},
expectedIsApproved: true,
},
{
name: "Test user email case - email approval",
user: &v1Models.User{
Emails: []string{"[email protected]"},
},
cclaSignature: &v1Models.Signature{
EmailApprovalList: []string{"[email protected]"},
},
expectedIsApproved: true,
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit c40885f

Please sign in to comment.