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

Allow vault_ldap_auth resources to be imported #387

Merged

Commits on Apr 5, 2019

  1. Allow importing for vault_ldap_auth resources

    Fixes hashicorp#383
    
    ```
    terraform import -allow-missing-config vault_ldap_auth_backend_group.foo auth/ldap/groups/foo
    vault_ldap_auth_backend_group.foo: Importing from ID "auth/ldap/groups/foo"...
    vault_ldap_auth_backend_group.foo: Import complete!
      Imported vault_ldap_auth_backend_group (ID: auth/ldap/groups/foo)
    vault_ldap_auth_backend_group.foo: Refreshing state... (ID: auth/ldap/groups/foo)
    
    Import successful!
    
    The resources that were imported are shown above. These resources are now in
    your Terraform state and will henceforth be managed by Terraform.
    ```
    
    I've not updated any docs yet, and I've only manually tested
    `vault_ldap_auth_backend_group` by hand so far, so this still needs docs
    written and tests added.
    lucymhdavies committed Apr 5, 2019
    Configuration menu
    Copy the full SHA
    45221de View commit details
    Browse the repository at this point in the history

Commits on Apr 6, 2019

  1. Failing tests for LDAP Resource imports

    Turns out, there's more to it than appeared to be the case from my
    previous commit.
    
    I've not run the full test suite, but only tested the resources I have
    modified as follows
    
    ```
    docker run -it --rm -p 8200:8200 vault server -dev -dev-root-token-id="root"
    
    VAULT_ADDR=http://0.0.0.0:8200 VAULT_TOKEN=root TF_ACC=1 go test -v --run TestLDAPAuthBackendGroup github.com/terraform-providers/terraform-provider-vault/vault
    ```
    
    Currently they fail due to, for example:
    
    ```
    === RUN   TestLDAPAuthBackendGroup_import
    --- FAIL: TestLDAPAuthBackendGroup_import (0.12s)
        testing.go:538: Step 1 error: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.
    
            (map[string]string) {
            }
    
            (map[string]string) (len=2) {
             (string) (len=7) "backend": (string) (len=39) "tf-test-ldap-backend-392924653340835300",
             (string) (len=9) "groupname": (string) (len=38) "tf-test-ldap-group-3866433073382041940"
            }
    ```
    Lucy Davinhart authored and lucymhdavies committed Apr 6, 2019
    Configuration menu
    Copy the full SHA
    bd3e43a View commit details
    Browse the repository at this point in the history
  2. LDAP Auth resources can now be imported

    I took inspiration from how AppRoles work, borrowing a lot of the code
    from there.
    
    ```
    $ VAULT_ADDR=http://0.0.0.0:8200 VAULT_TOKEN=root TF_ACC=1 go test -v --run TestLDAPAuthBackend github.com/terraform-providers/terraform-provider-vault/vault
    === RUN   TestLDAPAuthBackendGroup_import
    --- PASS: TestLDAPAuthBackendGroup_import (0.11s)
    === RUN   TestLDAPAuthBackendGroup_basic
    --- PASS: TestLDAPAuthBackendGroup_basic (0.09s)
    === RUN   TestLDAPAuthBackend_import
    --- PASS: TestLDAPAuthBackend_import (0.08s)
    === RUN   TestLDAPAuthBackend_basic
    --- PASS: TestLDAPAuthBackend_basic (0.07s)
    === RUN   TestLDAPAuthBackendUser_import
    --- PASS: TestLDAPAuthBackendUser_import (0.08s)
    === RUN   TestLDAPAuthBackendUser_basic
    --- PASS: TestLDAPAuthBackendUser_basic (0.08s)
    PASS
    ok  	github.com/terraform-providers/terraform-provider-vault/vault	0.529s
    ```
    
    Needed to modify `TestLDAPAuthBackend_import` slightly, as I forgot that
    `bindpass` isn't returned from the Vault API
    lucymhdavies committed Apr 6, 2019
    Configuration menu
    Copy the full SHA
    bc8f3df View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    612577b View commit details
    Browse the repository at this point in the history