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

Refactor saml dependencies 186822654 #2700

Merged
merged 27 commits into from
Feb 3, 2024

Conversation

bruce-ricard
Copy link
Contributor

We have a couple refactors that will be helpful when replacing the SAML extension library.

They should also help with readability and complexity, in general.

Also added a couple tests, when we found missing coverage.

@swalchemist and me

swalchemist and others added 15 commits January 31, 2024 17:37
* Split out test assertions that don't depend on SAML
* Added a comment about missing test coverage

Co-Authored-By: Peter Chen <peter-h.chen@broadcom.com>
* There's no need to rely on SAML features for this test.

Co-Authored-By: Peter Chen <peter-h.chen@broadcom.com>
* Facilitated by introducing the uaaPrincipal variable

[#186822654]

Co-authored-by: Bruce Ricard <bruce.ricard@broadcom.com>
* Creating a new passcode package to later add a PasscodeEndpoint class to.

Co-authored-by: Bruce Ricard <bruce.ricard@broadcom.com>
* Note: breaks the build, will fix on the next commit.
* This preserves the history of the method we want to extract.

Co-authored-by: Bruce Ricard <bruce.ricard@broadcom.com>
* Finish extraction of generatePasscode().
* Moved the RequestMapping to the new PasscodeEndpoint class.
* Fixes the build.

Co-authored-by: Bruce Ricard <bruce.ricard@broadcom.com>
* Creating a test class for the new PasscodeEndpoint class by extracting existing test methods.
* The git history for these tests is in the server/src/main/java/org/cloudfoundry/identity/uaa/login/LoginInfoEndpoint.java class.

[#186822654]

Co-authored-by: Bruce Ricard <bruce.ricard@broadcom.com>
* Code is moved to become a constructor of the PasscodeInformation class. The code was already used to build the inputs of for a similar constructor call.
* Unit tests were adapted from PasscodeEndpointTest (which will be simplified in a later commit). We now have 100% code coverage of the new constructor.
* Removed redundancy with tests in PasscodeInformationTest.
* Kept a single test but improved coverage by validating the passcode in the model.
* The new comment about the untested code path is no longer relevant/true. Removed the comment.
* Not 100% sure if it's needed still in LoginInfoEndpoint
@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/186957486

The labels on this github issue will be updated when the story is started.

@bruce-ricard bruce-ricard added the saml-extension-replacement Work related to the replacement of the old SAML extension library by the newer spring security label Jan 31, 2024
@strehle
Copy link
Member

strehle commented Feb 1, 2024

sonar is not happy with it, therefore I have to check in more details
https://sonarcloud.io/summary/new_code?id=cloudfoundry-identity-parent&pullRequest=2700

@bruce-ricard
Copy link
Contributor Author

Thanks for pointing that out Markus. We'll look into it.

@swalchemist
Copy link
Contributor

Why is the Sonar action passing when SonarCloud says it failed?

@swalchemist swalchemist force-pushed the refactorSamlDependencies-186822654 branch from 83c47a0 to 4e340b0 Compare February 2, 2024 02:26
@swalchemist
Copy link
Contributor

I have pushed fixes for some of the code smells that Sonar found. However, the Sonar scan still fails because of its code coverage rules. The code we added to PasscodeInformation.java is 100% covered, but Sonar wants us to add coverage for the code that we didn't change, perhaps because we moved it to a new package.

We could possibly improve coverage by removing an unused constructor, but we'd need to figure out what to do with the Jackson annotations on that constructor.

* Covers an untested condition where an Authentication includes a Principal that is not a UaaPrincipal.
@swalchemist swalchemist force-pushed the refactorSamlDependencies-186822654 branch from 5f079f5 to 7f7d284 Compare February 2, 2024 04:13
swalchemist and others added 2 commits February 1, 2024 20:27
* Makes the constructor more consistent with the existing constructor.
* Really it's a sneaky trick to improve code coverage in the unit test.
* Refactor because sonar recommended it
@swalchemist swalchemist merged commit 2d0d516 into develop Feb 3, 2024
20 checks passed
@swalchemist swalchemist deleted the refactorSamlDependencies-186822654 branch February 3, 2024 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
saml-extension-replacement Work related to the replacement of the old SAML extension library by the newer spring security
Projects
Development

Successfully merging this pull request may close these issues.

4 participants