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

Fix CustomUsersOu position in OrgLdapSettingsType #625

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changes/v2.22.0/625-bug-fixes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Addressed Issue [1134](https://github.com/vmware/terraform-provider-vcd/issues/1134): Can't use SYSTEM `ldap_mode` [GH-625]
42 changes: 42 additions & 0 deletions govcd/adminorg_ldap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,48 @@ func (vcd *TestVCD) Test_LDAP(check *C) {
vcd.test_GroupUserListIsPopulated(check)
}

func (vcd *TestVCD) Test_LDAPSystem(check *C) {
if vcd.skipAdminTests {
check.Skip(fmt.Sprintf(TestRequiresSysAdminPrivileges, check.TestName()))
}
vcd.checkSkipWhenApiToken(check)

// Due to a bug in VCD, when configuring LDAP service, Org publishing catalog settings `Publish external catalogs` and
// `Subscribe to external catalogs ` gets disabled. For that reason we are getting the current values from those vars
// to set them at the end of the test, to avoid interference with other tests.
adminOrg, err := vcd.client.GetAdminOrgByName(vcd.org.Org.Name)
check.Assert(err, IsNil)
check.Assert(adminOrg, NotNil)

publishExternalCatalogs := adminOrg.AdminOrg.OrgSettings.OrgGeneralSettings.CanPublishExternally
subscribeToExternalCatalogs := adminOrg.AdminOrg.OrgSettings.OrgGeneralSettings.CanSubscribe
ldapSettings := types.OrgLdapSettingsType{
OrgLdapMode: "SYSTEM",
CustomUsersOu: "ou=Foo,dc=domain,dc=local base DN",
}

_, err = adminOrg.LdapConfigure(&ldapSettings)
check.Assert(err, IsNil)
defer func() {
fmt.Println("Unconfiguring LDAP")
// Clear LDAP configuration
err = adminOrg.LdapDisable()
check.Assert(err, IsNil)

// Due to the VCD bug mentioned above, we need to set the previous state from the publishing settings vars
check.Assert(adminOrg.Refresh(), IsNil)

adminOrg.AdminOrg.OrgSettings.OrgGeneralSettings.CanPublishExternally = publishExternalCatalogs
adminOrg.AdminOrg.OrgSettings.OrgGeneralSettings.CanSubscribe = subscribeToExternalCatalogs

task, err := adminOrg.Update()
check.Assert(err, IsNil)

err = task.WaitTaskCompletion()
check.Assert(err, IsNil)
}()
}

// configureLdapForOrg sets up LDAP configuration in vCD org
func configureLdapForOrg(vcd *TestVCD, adminOrg *AdminOrg, ldapHostIp, testName string) error {
fmt.Printf("# Configuring LDAP settings for Org '%s'", vcd.config.VCD.Org)
Expand Down
2 changes: 1 addition & 1 deletion types/v56/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -941,8 +941,8 @@ type OrgLdapSettingsType struct {
Type string `xml:"type,attr,omitempty"` // The MIME type of the entity.
Link LinkList `xml:"Link,omitempty"` // A reference to an entity or operation associated with this object.

CustomUsersOu string `xml:"CustomUsersOu,omitempty"` // If OrgLdapMode is SYSTEM, specifies an LDAP attribute=value pair to use for OU (organizational unit).
OrgLdapMode string `xml:"OrgLdapMode,omitempty"` // LDAP mode you want
CustomUsersOu string `xml:"CustomUsersOu,omitempty"` // If OrgLdapMode is SYSTEM, specifies an LDAP attribute=value pair to use for OU (organizational unit).
CustomOrgLdapSettings *CustomOrgLdapSettings `xml:"CustomOrgLdapSettings,omitempty"` // Needs to be set if user chooses custom mode
}

Expand Down
Loading