Skip to content

fix: implement BasicAuthHandler#getAuthenticationInfo in tests#26895

Open
Mihix wants to merge 1 commit intowso2:masterfrom
Mihix:fix/basic-authhandler-authinfo
Open

fix: implement BasicAuthHandler#getAuthenticationInfo in tests#26895
Mihix wants to merge 1 commit intowso2:masterfrom
Mihix:fix/basic-authhandler-authinfo

Conversation

@Mihix
Copy link
Copy Markdown

@Mihix Mihix commented Mar 4, 2026

I noticed that getAuthenticationInfo() was essentially a dead end—it always returned null, even though the class had all the credentials it needed. This was a bit of a landmine for anyone calling the method, as it could lead to unexpected crashes or authentication silent-fails. I’ve updated it to actually 'speak up' and return a fully formed BasicAuthInfo object. Now, the method does exactly what it says on the tin, making it much safer for the rest of the team to use.

public AuthenticationInfo getAuthenticationInfo() {
    BasicAuthInfo authInfo = new BasicAuthInfo();
    authInfo.setUserName(USER_NAME);
    authInfo.setPassword(PASSWORD);
    authInfo.setAuthorizationHeader(getBase64EncodedBasicAuthHeader(USER_NAME, PASSWORD));
    return authInfo;
}

    public AuthenticationInfo getAuthenticationInfo() {
    BasicAuthInfo authInfo = new BasicAuthInfo();
    authInfo.setUserName(USER_NAME);
    authInfo.setPassword(PASSWORD);
    authInfo.setAuthorizationHeader(getBase64EncodedBasicAuthHeader(USER_NAME, PASSWORD));
    return authInfo;
}

full Git link - https://github.com/Mihix/Fix-BasicAuthHandler-getAuthenticationInfo-returning-null-in-integration-tests-in-PRODUCT-IS-WS02.git

Avoid returning null AuthenticationInfo in test utilities by creating a BasicAuthInfo populated with default credentials and a Basic auth header.

Made-with: Cursor
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 4, 2026

Walkthrough

Two test utility classes modified to implement getAuthenticationInfo() method. Previously returning null, both methods now construct and return a populated BasicAuthInfo object with username, password, and Base64-encoded Authorization header.

Changes

Cohort / File(s) Summary
BasicAuthHandler Test Utilities
modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/utils/BasicAuthHandler.java, modules/integration/tests-ui-integration/src/test/java/org/wso2/identity/ui/integration/test/utils/BasicAuthHandler.java
Implementation of getAuthenticationInfo() method changed from returning null to returning fully populated BasicAuthInfo object with username, password, and Authorization header.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 From null to truth, our handlers rise,
With auth credentials, properly sized,
Base64 dreams in headers so bright,
No more null returns in the test-night! 🌙✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: implementing a previously null-returning method in the BasicAuthHandler test utility class.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 4, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/utils/BasicAuthHandler.java (1)

27-27: Redundant import from the same package.

BasicAuthInfo is in the same package (org.wso2.identity.integration.test.utils) as this class, so the explicit import is unnecessary. Java automatically resolves classes within the same package.

♻️ Proposed fix
-import org.wso2.identity.integration.test.utils.BasicAuthInfo;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/utils/BasicAuthHandler.java`
at line 27, Remove the redundant import of BasicAuthInfo from BasicAuthHandler:
since BasicAuthInfo is in the same package
org.wso2.identity.integration.test.utils, delete the import statement
referencing BasicAuthInfo and rely on the package-local resolution; update the
import list in BasicAuthHandler to eliminate that unused line and run a quick
build to ensure no remaining import warnings.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/utils/BasicAuthHandler.java`:
- Line 27: Remove the redundant import of BasicAuthInfo from BasicAuthHandler:
since BasicAuthInfo is in the same package
org.wso2.identity.integration.test.utils, delete the import statement
referencing BasicAuthInfo and rely on the package-local resolution; update the
import list in BasicAuthHandler to eliminate that unused line and run a quick
build to ensure no remaining import warnings.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3ca7b258-1db9-4778-99e2-44c9aa696dd4

📥 Commits

Reviewing files that changed from the base of the PR and between 73fbe0c and 01bfb86.

📒 Files selected for processing (2)
  • modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/utils/BasicAuthHandler.java
  • modules/integration/tests-ui-integration/src/test/java/org/wso2/identity/ui/integration/test/utils/BasicAuthHandler.java

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.

2 participants