Skip to content

Refactor CaReconcilerTest to improve readability #11343

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

Merged
merged 1 commit into from
Apr 14, 2025

Conversation

katheris
Copy link
Contributor

Type of change

Select the type of your PR

  • Refactoring

Description

Refactor the CaReconcilerTest class to improve readability.
This existing class is hard to follow since there are so many assertThat calls and many variables with similar names like clientsCaCertData, clientsCaKeyData, clusterCaCertData, clusterCaKeyData.
This PR pulls out the common asserts that check the certificate files and key files are all present and not null.
It also removes some variables that are only used once, again to improve readability.

Finally it removes the checks that compare the Ca truststore file as a whole. These checks are only passing
because in the Ca class in some cases we reuse the data directly, rather than instantiating a new hashmap.
The tests don't need to check the whether it is the exact same file, and in testExpiredCertsGetRemovedAuto we
actually wouldn't expect the file to be the same.
Since there are already checks that the correct cert is present in the truststore, the asserts that compare the whole file can be removed.

Checklist

Please go through this checklist and make sure all applicable tasks have been done

  • Write tests
  • Make sure all tests pass
  • Update documentation
  • Check RBAC rights for Kubernetes / OpenShift roles
  • Try your changes from Pod inside your Kubernetes and OpenShift cluster, not just locally
  • Reference relevant issue(s) and close them after merging
  • Update CHANGELOG.md
  • Supply screenshots for visual changes, such as Grafana dashboards

* Extract method for cert and key not null asserts
* Remove separate variables when possible to improve
readability
* Remove comparisons of store files since content
assertions are already present

Signed-off-by: Katherine Stanley <[email protected]>
@katheris katheris added this to the 0.46.0 milestone Apr 10, 2025
Copy link
Member

@see-quick see-quick left a comment

Choose a reason for hiding this comment

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

Thanks 👍

Copy link
Member

@ppatierno ppatierno left a comment

Choose a reason for hiding this comment

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

LGTM

@katheris katheris merged commit 21d61e5 into strimzi:main Apr 14, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants