Skip to content

Commit

Permalink
Merge pull request #4473 from nickmango/feature/authorize-api
Browse files Browse the repository at this point in the history
[#4472] Approval List search
  • Loading branch information
nickmango authored Nov 4, 2024
2 parents 373849c + c40885f commit 0c3f707
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 0c3f707

Please sign in to comment.