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 LDAP identity source resource #1010

Merged
merged 4 commits into from
Nov 15, 2023
Merged

Add LDAP identity source resource #1010

merged 4 commits into from
Nov 15, 2023

Conversation

wsquan171
Copy link
Contributor

This PR adds policy LDAP identity source resource. Both ActiveDirectoryIdentitySource and OpenLdapIdentitySource type LDAP are supported. The two resources have different resource type on NSX API, but shares the same attributes.

@wsquan171
Copy link
Contributor Author

/test-all

1 similar comment
@ksamoray
Copy link
Collaborator

/test-all

Description: "Username or DN for LDAP authentication",
Optional: true,
},
"certificates": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this certificate path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It's the public cert of the servers to tell NSX to trust. Has to be a string of pem. No path allowed.


func TestAccResourceNsxtPolicyLdapIdentitySource_basic(t *testing.T) {
testResourceName := "nsxt_policy_ldap_identity_source.test"
ldapType := nsxModel.LdapIdentitySource_RESOURCE_TYPE_ACTIVEDIRECTORYIDENTITYSOURCE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we test both types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we make 2 sets of ENVs (one set for open LDAP another for AD)? Or just add another ENV var to select which type of server to test against?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the same set of ENV variable work for both types? In this case, I would suggest to reuse same vars for both types

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bind_identity will be different. It all boils down to how we expect this acc test to be run in our pipelines in the future. If we want to cover both in one go then we need 2 servers (openldap + ad) anyways, so 2 sets of VARs. Otherwise the VAR names makes sense for both server types. Just different values should be set to them.

"description": getDataSourceDescriptionSchema(),
"revision": getRevisionSchema(),
"tag": getTagsSchema(),
"type": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be defined as ForceNew, or can resource type be updated on existing object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

)

var ldapServerTypes = [](string){
nsxModel.LdapIdentitySource_RESOURCE_TYPE_ACTIVEDIRECTORYIDENTITYSOURCE,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to offer more user friendly values than OpenLdapIdentitySource - perhaps OpenLdap and ActiveDirectory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

LdapServers: ldapServers,
ResourceType: serverType,
}
dataValue, errs := converter.ConvertToVapi(obj, nsxModel.LdapIdentitySourceBindingType())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work for the other server type? I think even it if works now, SDK might add validations in future that would fail if structs diverge. I would suggest to convert to the correct type even if those are identical for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting using proper binding types now.

Signed-off-by: Shawn Wang <[email protected]>
@ksamoray
Copy link
Collaborator

Do we need some infrastructure to test this?
We could setup an LDAP server or such on the CI jumphost VM if that helps.

@wsquan171
Copy link
Contributor Author

/test-all

@wsquan171 wsquan171 merged commit 18e6e5a into vmware:master Nov 15, 2023
@wsquan171 wsquan171 deleted the ldap branch November 15, 2023 01:40
@wsquan171
Copy link
Contributor Author

Do we need some infrastructure to test this? We could setup an LDAP server or such on the CI jumphost VM if that helps.

Kobi, I agree that it's worth testing. I can follow up with test related changes when we have a better idea regarding how we add openldap or AD over ldap in our testing env. Merging this PR for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants