Created
October 16, 2024 17:39
-
-
Save crobby/f20b1a4ee2744ee639f29e62106e6d75 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| diff --git a/pkg/auth/providers/ldap/ldap_client_test.go b/pkg/auth/providers/ldap/ldap_client_test.go | |
| index d749c4432..c7c761b8d 100644 | |
| --- a/pkg/auth/providers/ldap/ldap_client_test.go | |
| +++ b/pkg/auth/providers/ldap/ldap_client_test.go | |
| @@ -161,6 +161,84 @@ type args struct { | |
| wantGroupPrincipals: nil, | |
| wantErr: true, | |
| }, | |
| + { | |
| + name: "successful user login with SearchUsingServiceAccount true", | |
| + fields: fields{ | |
| + userMGR: mockUserManager{ | |
| + hasAccess: true, | |
| + }, | |
| + tokenMGR: &tokens.Manager{}, | |
| + caPool: &x509.CertPool{}, | |
| + userScope: "providername_user", | |
| + groupScope: "providername_group", | |
| + }, | |
| + args: args{ | |
| + lConn: newMockLdapConnClient(), | |
| + credential: &v32.BasicLogin{ | |
| + Username: DummyUsername, | |
| + Password: DummyPassword, | |
| + }, | |
| + config: &v3.LdapConfig{ | |
| + LdapFields: v32.LdapFields{ | |
| + ServiceAccountDistinguishedName: DummySAUsername, | |
| + ServiceAccountPassword: DummySAUPassword, | |
| + UserObjectClass: UserObjectClassName, | |
| + SearchUsingServiceAccount: true, | |
| + }, | |
| + }, | |
| + caPool: &x509.CertPool{}, | |
| + }, | |
| + wantUserPrincipal: v3.Principal{ | |
| + ObjectMeta: v1.ObjectMeta{ | |
| + Name: "providername_user://ldap.test.domain", | |
| + }, | |
| + PrincipalType: "user", | |
| + Me: true, | |
| + }, | |
| + wantGroupPrincipals: []v3.Principal{ | |
| + { | |
| + ObjectMeta: v1.ObjectMeta{ | |
| + Name: "providername_group://ldap.test.domain", | |
| + }, | |
| + PrincipalType: "user", | |
| + Me: true, | |
| + }, | |
| + }, | |
| + wantErr: false, | |
| + }, | |
| + { | |
| + name: "user login with invalid credentials with SearchUsingServiceAccount true", | |
| + fields: fields{ | |
| + userMGR: mockUserManager{ | |
| + hasAccess: false, | |
| + }, | |
| + tokenMGR: &tokens.Manager{}, | |
| + caPool: &x509.CertPool{}, | |
| + userScope: "providername_user", | |
| + groupScope: "providername_group", | |
| + }, | |
| + args: args{ | |
| + lConn: &mockLdapConn{ | |
| + canAuthenticate: false, | |
| + }, | |
| + credential: &v32.BasicLogin{ | |
| + Username: DummyUsername, | |
| + Password: DummyPassword, | |
| + }, | |
| + config: &v3.LdapConfig{ | |
| + LdapFields: v32.LdapFields{ | |
| + ServiceAccountDistinguishedName: DummySAUsername, | |
| + ServiceAccountPassword: DummySAUPassword, | |
| + UserObjectClass: UserObjectClassName, | |
| + SearchUsingServiceAccount: true, | |
| + }, | |
| + }, | |
| + caPool: &x509.CertPool{}, | |
| + }, | |
| + wantUserPrincipal: v3.Principal{}, | |
| + wantGroupPrincipals: nil, | |
| + wantErr: true, | |
| + }, | |
| } | |
| for _, tt := range tests { | |
| t.Run(tt.name, func(t *testing.T) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment