Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for group id mapping #349

Merged
merged 14 commits into from
Jan 10, 2024
17 changes: 17 additions & 0 deletions tap/identity-handlers/tyk_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (
var UserGroupMapping = map[string]string{
"devs": "devs-group",
"admins": "admins-group",
"CN=tyk_admin,OU=Security Groups,OU=GenericOrg,DC=GenericOrg,DC=COM,DC=GEN": "tyk-admin",
}

func TestGetEmail(t *testing.T) {
Expand Down Expand Up @@ -204,6 +205,22 @@ func TestGetGroupId(t *testing.T) {
DefaultGroupID: "devs",
UserGroupMapping: UserGroupMapping,
},
{
TestName: "Custom group id field not empty, and the claim being an array",
CustomGroupIDField: "memberOf",
user: goth.User{RawData: map[string]interface{}{
"memberOf": []string{
"CN=tyk_admin,OU=Security Groups,OU=GenericOrg,DC=GenericOrg,DC=COM,DC=GEN",
"CN=openshift-uat-users,OU=Security Groups,OU=GenericOrg,DC=GenericOrg,DC=COM,DC=GEN",
"CN=Generic Contract Employees,OU=Email_Group,OU=GenericOrg,DC=GenericOrg,DC=COM,DC=GEN",
"CN=VPN-Group-Outsourced,OU=Security Groups,OU=GenericOrg,DC=GenericOrg,DC=COM,DC=GEN",
"CN=Normal Group,OU=Security Groups,OU=GenericOrg,DC=GenericOrg,DC=COM,DC=GEN",
},
}},
ExpectedGroupID: "tyk-admin",
DefaultGroupID: "devs",
UserGroupMapping: UserGroupMapping,
},
}

for _, tc := range cases {
Expand Down
Loading