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

resource/random_password+random_string: Prevent override_special differences upgrading from 3.3.2 #312

Merged
merged 7 commits into from
Sep 6, 2022

Commits on Sep 2, 2022

  1. resource/random_password: Fix bcrypt_hash generation

    Reference: #307
    
    This change fixes the source of the `bcrypt_hash` generation to being the result of the random password generation. The issue was introduced in v3.4.0.
    
    Previously:
    
    ```
    --- FAIL: TestAccResourcePassword_BcryptHash (0.63s)
        /Users/bflad/src/github.com/hashicorp/terraform-provider-random/internal/provider/resource_password_test.go:107: Step 1/1 error: Check failed: Check 3/3 error: crypto/bcrypt: hashedPassword is not the hash of the given password
    ```
    
    Suggested CHANGELOG:
    
    ```
    NOTES:
    
    * resource/random_password: If the resource was created between versions 3.4.0 and 3.4.2, the `bcrypt_hash` value will not correctly verify against the `result` value. Use `terraform taint` or `terraform apply -replace` to trigger resource recreation with this version.
    
    BUG FIXES:
    
    * resource/random_password: Fixed incorrect `bcrypt_hash` generation since version 3.4.0
    ```
    bflad committed Sep 2, 2022
    Configuration menu
    Copy the full SHA
    a07c5b8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3f7f815 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    87c2826 View commit details
    Browse the repository at this point in the history

Commits on Sep 5, 2022

  1. resource/random_password+random_string: Prevent differences upgrading…

    … from 3.3.2
    
    Reference: #306
    
    This fixes the `override_special` attribute issues by removing `Computed: true` and the empty string default value plan modifier (this attribute's value should always come from the practitioner) and resolves the underlying issue of always reading `plan.OverrideSpecial.Value` into the state, which will never be correct for null configurations.
    
    For any environment that happened to upgrade to 3.4.2 and save the empty string into state, the replacement plan modifier will allow in-place modification from empty string (`""`) to `null`.
    
    Previously after removing `Computed: true` and default value plan modifier:
    
    ```
    === CONT  TestAccResourcePassword_OverrideSpecial_FromVersion3_3_2
        resource_password_test.go:221: Step 2/2 error: Error running apply: exit status 1
    
            Error: Provider produced inconsistent result after apply
    
            When applying changes to random_password.test, provider
            "provider[\"registry.terraform.io/hashicorp/random\"]" produced an unexpected
            new value: .override_special: was null, but now cty.StringVal("").
    
            This is a bug in the provider, which should be reported in the provider's own
            issue tracker.
    === CONT  TestAccResourcePassword_OverrideSpecial_FromVersion3_4_2
        resource_password_test.go:255: Step 2/2 error: Error running apply: exit status 1
    
            Error: Provider produced inconsistent result after apply
    
            When applying changes to random_password.test, provider
            "provider[\"registry.terraform.io/hashicorp/random\"]" produced an unexpected
            new value: .override_special: was null, but now cty.StringVal("").
    
            This is a bug in the provider, which should be reported in the provider's own
            issue tracker.
    ```
    
    Previously before adjusting requires replace plan modifier:
    
    ```
    === CONT  TestAccResourcePassword_OverrideSpecial_FromVersion3_3_2
        resource_password_test.go:221: Step 2/2 error: Check failed: Check 3/3 error: attribute values are different, got :i$(*K3_Vinv and FSw{$8sB#Uc3
    === CONT  TestAccResourcePassword_OverrideSpecial_FromVersion3_4_2
        resource_password_test.go:255: Step 2/2 error: Check failed: Check 3/3 error: attribute values are different, got VrNYb]{#Z2Xu and XZD#_<BjDhkH
    ```
    bflad committed Sep 5, 2022
    Configuration menu
    Copy the full SHA
    115d254 View commit details
    Browse the repository at this point in the history

Commits on Sep 6, 2022

  1. Apply suggestions from code review

    Co-authored-by: Benjamin Bennett <ben.bennett@hashicorp.com>
    bflad and bendbennett committed Sep 6, 2022
    Configuration menu
    Copy the full SHA
    0c11bcb View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ed063cd View commit details
    Browse the repository at this point in the history
  3. resource/random_password+random_string: Set keepers and override_spec…

    …ial explicitly to null during import
    
    Previously:
    
    ```
    === RUN   TestAccResourcePassword
        resource_password_test.go:67: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.
    
            (map[string]string) (len=1) {
             (string) (len=16) "override_special": (string) ""
            }
    
            (map[string]string) {
            }
    --- FAIL: TestAccResourcePassword (0.79s)
    ```
    bflad committed Sep 6, 2022
    Configuration menu
    Copy the full SHA
    f83d5f0 View commit details
    Browse the repository at this point in the history