-
Notifications
You must be signed in to change notification settings - Fork 75
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 support for LDAP and SAML groups #314
Merged
Merged
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
64773ea
CRUD and tests work
Didainius c33c525
Groups with tests
Didainius 3acf7d9
Merge branch 'master' into ldap_groups
Didainius 9fa6ab5
Merge branch 'master' into ldap_groups
Didainius eb9c195
Ldap spinup and port check works
Didainius b0d602b
Test worked
Didainius ad9dc3b
Extra logging
Didainius 5f989d2
Polishing
Didainius 6850eed
Testing works
Didainius 3241b2a
Cleanup, changelog
Didainius bb39da5
Immediate cleanup works well
Didainius 5399c49
Tune timeout, tags
Didainius e6ea242
Add a note about LDAP
Didainius 4353285
tests fixed
Didainius 7ff613d
Self review cleanup
Didainius 339308e
Improve initscript, tune comments
Didainius 7567f87
Cleanup
Didainius 7d43481
Comment out SAML group testing by default
Didainius 97a9aa6
Adjust LDAP user attributes to make user search work
Didainius 526af2a
Tune LDAP attribute config for Org
Didainius cde89b9
Improve Group type docs
Didainius e8f955d
address
Didainius 7871b63
[skip ci] adjust changelog
Didainius ce64981
Add nil checks to validation functions
Didainius a6101cc
Merge master
Didainius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,61 @@ | ||
/* | ||
* Copyright 2020 VMware, Inc. All rights reserved. Licensed under the Apache v2 License. | ||
*/ | ||
|
||
package govcd | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/vmware/go-vcloud-director/v2/types/v56" | ||
"github.com/vmware/go-vcloud-director/v2/util" | ||
) | ||
|
||
// LdapConfigure allows to configure LDAP mode in use by the Org | ||
func (adminOrg *AdminOrg) LdapConfigure(settings *types.OrgLdapSettingsType) (*types.OrgLdapSettingsType, error) { | ||
util.Logger.Printf("[DEBUG] Configuring LDAP mode for Org name %s", adminOrg.AdminOrg.Name) | ||
|
||
// Xmlns field is not mandatory when `types.OrgLdapSettingsType` is set as part of whole | ||
// `AdminOrg` structure but it must be set when directly updating LDAP. For that reason | ||
// `types.OrgLdapSettingsType` Xmlns struct tag has 'omitempty' set | ||
settings.Xmlns = types.XMLNamespaceVCloud | ||
|
||
href := adminOrg.AdminOrg.HREF + "/settings/ldap" | ||
_, err := adminOrg.client.ExecuteRequest(href, http.MethodPut, types.MimeOrgLdapSettings, | ||
"error updating LDAP settings: %s", settings, nil) | ||
if err != nil { | ||
return nil, fmt.Errorf("error updating LDAP mode for Org name '%s': %s", adminOrg.AdminOrg.Name, err) | ||
} | ||
|
||
ldapSettings, err := adminOrg.GetLdapConfiguration() | ||
if err != nil { | ||
return nil, fmt.Errorf("error retrieving LDAP configuration: %s", err) | ||
} | ||
|
||
return ldapSettings, nil | ||
} | ||
|
||
// LdapDisable wraps LdapConfigure to disable LDAP configuration for org | ||
func (adminOrg *AdminOrg) LdapDisable() error { | ||
vbauzys marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_, err := adminOrg.LdapConfigure(&types.OrgLdapSettingsType{OrgLdapMode: types.LdapModeNone}) | ||
return err | ||
} | ||
|
||
// GetLdapConfiguration retrieves LDAP configuration structure | ||
func (adminOrg *AdminOrg) GetLdapConfiguration() (*types.OrgLdapSettingsType, error) { | ||
util.Logger.Printf("[DEBUG] Reading LDAP configuration for Org name %s", adminOrg.AdminOrg.Name) | ||
|
||
ldapSettings := &types.OrgLdapSettingsType{} | ||
|
||
href := adminOrg.AdminOrg.HREF + "/settings/ldap" | ||
|
||
_, err := adminOrg.client.ExecuteRequest(href, http.MethodGet, types.MimeOrgLdapSettings, | ||
"error getting LDAP settings: %s", nil, ldapSettings) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return ldapSettings, nil | ||
} |
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,75 @@ | ||
// +build org functional ALL | ||
|
||
/* | ||
* Copyright 2020 VMware, Inc. All rights reserved. Licensed under the Apache v2 License. | ||
*/ | ||
|
||
package govcd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/vmware/go-vcloud-director/v2/types/v56" | ||
. "gopkg.in/check.v1" | ||
) | ||
|
||
// Test_LDAP_Configuration tests LDAP configuration functions | ||
func (vcd *TestVCD) Test_LDAP_Configuration(check *C) { | ||
if vcd.skipAdminTests { | ||
check.Skip(fmt.Sprintf(TestRequiresSysAdminPrivileges, check.TestName())) | ||
} | ||
|
||
org, err := vcd.client.GetAdminOrgByName(vcd.config.VCD.Org) | ||
check.Assert(err, IsNil) | ||
|
||
ldapSettings := &types.OrgLdapSettingsType{ | ||
OrgLdapMode: types.LdapModeCustom, | ||
CustomOrgLdapSettings: &types.CustomOrgLdapSettings{ | ||
HostName: "1.1.1.1", | ||
Port: 389, | ||
SearchBase: "dc=planetexpress,dc=com", | ||
AuthenticationMechanism: "SIMPLE", | ||
ConnectorType: "OPEN_LDAP", | ||
Username: "cn=admin,dc=planetexpress,dc=com", | ||
Password: "GoodNewsEveryone", | ||
UserAttributes: &types.OrgLdapUserAttributes{ | ||
ObjectClass: "inetOrgPerson", | ||
ObjectIdentifier: "uid", | ||
Username: "uid", | ||
Email: "mail", | ||
FullName: "cn", | ||
GivenName: "givenName", | ||
Surname: "sn", | ||
Telephone: "telephoneNumber", | ||
GroupMembershipIdentifier: "dn", | ||
}, | ||
GroupAttributes: &types.OrgLdapGroupAttributes{ | ||
ObjectClass: "group", | ||
ObjectIdentifier: "cn", | ||
GroupName: "cn", | ||
Membership: "member", | ||
MembershipIdentifier: "dn", | ||
}, | ||
}, | ||
} | ||
gotSettings, err := org.LdapConfigure(ldapSettings) | ||
check.Assert(err, IsNil) | ||
|
||
AddToCleanupList("LDAP-configuration", "orgLdapSettings", org.AdminOrg.Name, check.TestName()) | ||
|
||
check.Assert(ldapSettings.CustomOrgLdapSettings.GroupAttributes, DeepEquals, gotSettings.CustomOrgLdapSettings.GroupAttributes) | ||
check.Assert(ldapSettings.CustomOrgLdapSettings.UserAttributes, DeepEquals, gotSettings.CustomOrgLdapSettings.UserAttributes) | ||
check.Assert(ldapSettings.CustomOrgLdapSettings.UserAttributes, DeepEquals, gotSettings.CustomOrgLdapSettings.UserAttributes) | ||
check.Assert(ldapSettings.CustomOrgLdapSettings.Username, DeepEquals, gotSettings.CustomOrgLdapSettings.Username) | ||
check.Assert(ldapSettings.CustomOrgLdapSettings.AuthenticationMechanism, DeepEquals, gotSettings.CustomOrgLdapSettings.AuthenticationMechanism) | ||
check.Assert(ldapSettings.CustomOrgLdapSettings.ConnectorType, DeepEquals, gotSettings.CustomOrgLdapSettings.ConnectorType) | ||
|
||
err = org.LdapDisable() | ||
check.Assert(err, IsNil) | ||
|
||
ldapConfig, err := org.GetLdapConfiguration() | ||
check.Assert(err, IsNil) | ||
|
||
check.Assert(ldapConfig.OrgLdapMode, Equals, types.LdapModeNone) | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please tell more why are you adding additional one hundred minutes to the timeout :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not related to this exact group PR. I did hit timeouts in general for full suite runs in slower envs that is why I increased the "default".