-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport of auth/ldap: Add username to alias.metadata.name into relea…
…se/1.9.x (#13726) * backport of commit 5dc6e43 * backport of commit 002ed5f * backport of commit 77e4dfe * backport of commit 6514151 * backport of commit eb7cee2 * backport of commit 7dc5acc * backport of commit 9ae01d7 Co-authored-by: Jason O'Donnell <[email protected]>
- Loading branch information
1 parent
4e1213e
commit ffa1f54
Showing
4 changed files
with
68 additions
and
22 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -597,6 +597,26 @@ func TestBackend_basic_authbind_userfilter(t *testing.T) { | |
|
||
} | ||
|
||
func TestBackend_basic_authbind_metadata_name(t *testing.T) { | ||
|
||
b := factory(t) | ||
cleanup, cfg := ldap.PrepareTestContainer(t, "latest") | ||
defer cleanup() | ||
|
||
cfg.UserAttr = "cn" | ||
cfg.UPNDomain = "planetexpress.com" | ||
|
||
addUPNAttributeToLDAPSchemaAndUser(t, cfg, "cn=Hubert J. Farnsworth,ou=people,dc=planetexpress,dc=com", "[email protected]") | ||
|
||
logicaltest.Test(t, logicaltest.TestCase{ | ||
CredentialBackend: b, | ||
Steps: []logicaltest.TestStep{ | ||
testAccStepConfigUrlWithAuthBind(t, cfg), | ||
testAccStepLoginAliasMetadataName(t, "professor", "professor"), | ||
}, | ||
}) | ||
} | ||
|
||
func addUPNAttributeToLDAPSchemaAndUser(t *testing.T, cfg *ldaputil.ConfigEntry, testUserDN string, testUserUPN string) { | ||
// Setup connection | ||
client := &ldaputil.Client{ | ||
|
@@ -644,23 +664,6 @@ func addUPNAttributeToLDAPSchemaAndUser(t *testing.T, cfg *ldaputil.ConfigEntry, | |
|
||
} | ||
|
||
func TestBackend_basic_authbind_upndomain(t *testing.T) { | ||
b := factory(t) | ||
cleanup, cfg := ldap.PrepareTestContainer(t, "latest") | ||
defer cleanup() | ||
cfg.UPNDomain = "planetexpress.com" | ||
|
||
addUPNAttributeToLDAPSchemaAndUser(t, cfg, "cn=Hubert J. Farnsworth,ou=people,dc=planetexpress,dc=com", "[email protected]") | ||
|
||
logicaltest.Test(t, logicaltest.TestCase{ | ||
CredentialBackend: b, | ||
Steps: []logicaltest.TestStep{ | ||
testAccStepConfigUrlWithAuthBind(t, cfg), | ||
testAccStepLoginNoAttachedPolicies(t, "professor", "professor"), | ||
}, | ||
}) | ||
} | ||
|
||
func TestBackend_basic_discover(t *testing.T) { | ||
b := factory(t) | ||
cleanup, cfg := ldap.PrepareTestContainer(t, "latest") | ||
|
@@ -990,6 +993,19 @@ func testAccStepLoginNoAttachedPolicies(t *testing.T, user string, pass string) | |
} | ||
} | ||
|
||
func testAccStepLoginAliasMetadataName(t *testing.T, user string, pass string) logicaltest.TestStep { | ||
return logicaltest.TestStep{ | ||
Operation: logical.UpdateOperation, | ||
Path: "login/" + user, | ||
Data: map[string]interface{}{ | ||
"password": pass, | ||
}, | ||
Unauthenticated: true, | ||
|
||
Check: logicaltest.TestCheckAuthEntityAliasMetadataName("name", user), | ||
} | ||
} | ||
|
||
func testAccStepLoginFailure(t *testing.T, user string, pass string) logicaltest.TestStep { | ||
return logicaltest.TestStep{ | ||
Operation: logical.UpdateOperation, | ||
|
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,3 @@ | ||
```release-note:improvement | ||
auth/ldap: Add username to alias metadata | ||
``` |
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