-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4396 from nickmango/bug/ecla-check
[#4348] Bug/Ecla Check
- Loading branch information
Showing
6 changed files
with
126 additions
and
35 deletions.
There are no files selected for viewing
28 changes: 7 additions & 21 deletions
28
...atures/mock_v1_signatures/mock_service.go → ...ckend-go/signatures/mocks/mock_service.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Copyright The Linux Foundation and each contributor to CommunityBridge. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package signatures | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
v1Models "github.com/communitybridge/easycla/cla-backend-go/gen/v1/models" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestUserIsApproved(t *testing.T) { | ||
ctx := context.Background() | ||
|
||
testCases := []struct { | ||
name string | ||
user *v1Models.User | ||
cclaSignature *v1Models.Signature | ||
expectedIsApproved bool | ||
}{ | ||
{ | ||
name: "User in GitHub username approval list", | ||
user: &v1Models.User{ | ||
GithubUsername: "approved-user", | ||
}, | ||
cclaSignature: &v1Models.Signature{ | ||
GithubUsernameApprovalList: []string{"approved-user"}, | ||
}, | ||
expectedIsApproved: true, | ||
}, | ||
{ | ||
name: "User not in GitHub username approval list", | ||
user: &v1Models.User{ | ||
GithubUsername: "unapproved-user", | ||
}, | ||
cclaSignature: &v1Models.Signature{ | ||
GithubUsernameApprovalList: []string{"approved-user"}, | ||
}, | ||
expectedIsApproved: false, | ||
}, | ||
{ | ||
name: "User in Email approval list", | ||
user: &v1Models.User{ | ||
Emails: []string{"[email protected]"}, | ||
}, | ||
cclaSignature: &v1Models.Signature{ | ||
EmailApprovalList: []string{"[email protected]"}, | ||
}, | ||
expectedIsApproved: true, | ||
}, | ||
{ | ||
name: "User not in Email approval list", | ||
user: &v1Models.User{ | ||
Emails: []string{"[email protected]"}, | ||
}, | ||
cclaSignature: &v1Models.Signature{ | ||
EmailApprovalList: []string{"[email protected]"}, | ||
}, | ||
expectedIsApproved: false, | ||
}, | ||
{ | ||
name: "User in Domain approval list", | ||
user: &v1Models.User{ | ||
Emails: []string{"[email protected]"}, | ||
}, | ||
cclaSignature: &v1Models.Signature{ | ||
DomainApprovalList: []string{"samsung.com"}, | ||
}, | ||
expectedIsApproved: true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
service := NewService(nil, nil, nil, nil, false, nil, nil, nil, nil, "", "", "") | ||
|
||
isApproved, err := service.UserIsApproved(ctx, tc.user, tc.cclaSignature) | ||
|
||
assert.Nil(t, err) | ||
assert.Equal(t, tc.expectedIsApproved, isApproved) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters