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

fix: Removes escape logic on IP address in mongodbatlas_access_list_api_key #1998

Merged
merged 6 commits into from
Mar 11, 2024

Conversation

maastha
Copy link
Collaborator

@maastha maastha commented Mar 7, 2024

Description

Removes escape logic on IP address in mongodbatlas_access_list_api_key since the new Atlas SDK escapes characters by default.

Link to any related issue(s): https://jira.mongodb.org/browse/CLOUDP-235189
Resolves #1984

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have read the contribution guidelines
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals, I defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

@github-actions github-actions bot added the bug label Mar 7, 2024
@maastha maastha marked this pull request as ready for review March 7, 2024 23:19
@maastha maastha requested a review from a team as a code owner March 7, 2024 23:19
CheckDestroy: checkDestroy,
Steps: []resource.TestStep{
{
ExternalProviders: acc.ExternalProviders("1.14.0"), // testing provider version before this resource was migrated to Atlas SDK
Copy link
Member

Choose a reason for hiding this comment

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

consider using SkipIfVersionBelow and/or IsProviderVersionAtLeast instead.
the issue with acc.ExternalProviders is that it will always check against that version ignoring MONGODB_ATLAS_LAST_VERSION, that can be confusing.

Copy link
Member

Choose a reason for hiding this comment

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

While this is true, I think we have to revise the provider versions we are passing for running migrations tests in the CI (https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/.github/workflows/code-health.yml#L91) and test suite. As of the moment we are simply running against latest so any test using SkipIfVersionBelow is likely being skipped if it is not the latest release.

Copy link
Collaborator Author

@maastha maastha Mar 8, 2024

Choose a reason for hiding this comment

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

using SkipIfVersionBelow(1.14.0), updated

},
},
{
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
Copy link
Member

Choose a reason for hiding this comment

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

you can use mig.TestStepCheckEmptyPlan

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

@@ -57,9 +57,54 @@ func TestAccMigrationProjectAccesslistAPIKey_SettingCIDRBlock(t *testing.T) {
PreCheck: func() { mig.PreCheckBasic(t) },
CheckDestroy: checkDestroy,
Steps: []resource.TestStep{
{
Copy link
Member

Choose a reason for hiding this comment

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

[q] since we already had a migration test defined for setting CIDR block, this would have been captured if we ran the migration test with a provider version of 1.14.0 or below right?

Copy link
Collaborator Author

@maastha maastha Mar 8, 2024

Choose a reason for hiding this comment

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

by "this" are you referring to this bug? If so, then no migration tests would not have captured this bug as we didn't have one for this specific use-case

Copy link
Member

Choose a reason for hiding this comment

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

Okay, was struggling to find the difference between the existing test and the new one. It has to do with cidrBlock value right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

right, the existing test uses subnet mask "/32", the new one uses "/16" so I named the test to have "WideCIDR"

},
})
}

func TestAccMigrationProjectAccesslistAPIKey_SettingCIDRBlock(t *testing.T) {
mig.SkipIfVersionBelow(t, "1.14.0")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you document this line? Might be beneficial to quickly know the why in the future

Copy link
Member

Choose a reason for hiding this comment

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

+1, as an example we're also documenting SkipTestForCI so we know why they're being skipped

Copy link
Collaborator Author

@maastha maastha Mar 11, 2024

Choose a reason for hiding this comment

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

added comment

Copy link
Collaborator

@andreaangiolillo andreaangiolillo left a comment

Choose a reason for hiding this comment

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

LGTM

@maastha maastha merged commit 9996916 into master Mar 11, 2024
45 checks passed
@maastha maastha deleted the CLOUDP-235189-access-list-api-key-cidr branch March 11, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants