Skip to content

Commit

Permalink
fix: Fixes mongodbatlas_ldap_configuration Delete function (#2221)
Browse files Browse the repository at this point in the history
* disables LDAP in Delete

* run in serial as ldap config is destroyed now in Delete
  • Loading branch information
lantoli authored Apr 30, 2024
1 parent 8ae5176 commit 36dc7a8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/2221.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/mongodbatlas_ldap_configuration: Disables LDAP when the resource is destroyed, instead of deleting userToDNMapping document
```
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,13 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag.

func resourceDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
connV2 := meta.(*config.MongoDBClient).AtlasV2
_, _, err := connV2.LDAPConfigurationApi.DeleteLDAPConfiguration(ctx, d.Id()).Execute()
params := &admin.UserSecurity{
Ldap: &admin.LDAPSecuritySettings{
AuthenticationEnabled: conversion.Pointer(false),
AuthorizationEnabled: conversion.Pointer(false),
},
}
_, _, err := connV2.LDAPConfigurationApi.SaveLDAPConfiguration(ctx, d.Id(), params).Execute()
if err != nil {
return diag.FromErr(fmt.Errorf(errorDelete, d.Id(), err))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import (
)

func TestMigLDAPConfiguration_basic(t *testing.T) {
mig.CreateAndRunTest(t, basicTestCase(t))
mig.CreateAndRunTestNonParallel(t, basicTestCase(t))
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
)

func TestAccLDAPConfiguration_basic(t *testing.T) {
resource.ParallelTest(t, *basicTestCase(t))
resource.Test(t, *basicTestCase(t))
}

func TestAccLDAPConfiguration_withVerify_CACertificateComplete(t *testing.T) {
Expand Down

0 comments on commit 36dc7a8

Please sign in to comment.