MeilleursAgents / terraform-provider-ansiblevault

Read ansible vault from Terraform
https://registry.terraform.io/providers/MeilleursAgents/ansiblevault/latest
MIT License
76 stars 19 forks source link

Crash when opening vault with nested dictionaries #75

Closed rvben closed 4 years ago

rvben commented 4 years ago

Describe the bug If a vault is used with nested dictionaries, a crash is the consequence.

To Reproduce Steps to reproduce the behavior:

  1. Configuration examples Add the following to complex_vault_test.yaml:
    MULTI:
    LAYERED:
    YAML: multi
  2. Error or stack trace
    $ go test
    --- FAIL: TestGetVaultKey (0.36s)
    --- FAIL: TestGetVaultKey/should_handle_invalid_yaml (0.03s)
        vault_test.go:273: getVaultKey(`../../examples/ansible/invalid_yaml_test.yaml`, `api_key`) = (``, yaml: unmarshal errors:
                  line 3: cannot unmarshal !!str `I'm not...` into map[string]string), want (``, yaml: unmarshal errors:
                  line 3: cannot unmarshal !!str `I'm not...` into map[string]interface {})
    --- FAIL: TestGetVaultKey/should_handle_multi-line_vault_file (0.03s)
        vault_test.go:273: getVaultKey(`../../examples/ansible/complex_vault_test.yaml`, `API_SECRET`) = (``, yaml: unmarshal errors:
                  line 8: cannot unmarshal !!map into string), want (`password`, <nil>)
    --- FAIL: TestGetVaultKey/should_handle_multi-line_vault_value (0.03s)
        vault_test.go:273: getVaultKey(`../../examples/ansible/complex_vault_test.yaml`, `MULTILINE_token`) = (``, yaml: unmarshal errors:
                  line 8: cannot unmarshal !!map into string), want (`foo
                bar`, <nil>)
    --- FAIL: TestGetVaultKey/should_handle_error_on_not_found_key (0.03s)
        vault_test.go:273: getVaultKey(`../../examples/ansible/complex_vault_test.yaml`, `KEY_NOT_FOUND`) = (``, yaml: unmarshal errors:
                  line 8: cannot unmarshal !!map into string), want (``, key not found)
    FAIL

Expected behavior A clear and concise description of what you expected to happen.

Environment (please complete the following information):