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

Feature remove registry SAML #6197

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft

Conversation

Osara-B
Copy link
Contributor

@Osara-B Osara-B commented Dec 11, 2024

Proposed changes in this pull request

This is raised early in the development to validate incremental improvements done on the feature branch to test against the product-is integration tests using the pr builder action

When should this PR be merged

This is a draft PR. Do not merge this.

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 72.79822% with 244 lines in your changes missing coverage. Please review.

Project coverage is 45.90%. Comparing base (b492a3d) to head (c90315f).
Report is 25 commits behind head on master.

Files with missing lines Patch % Lines
...ore/dao/RegistrySAMLSSOServiceProviderDAOImpl.java 65.97% 103 Missing and 44 partials ⚠️
...ty/core/dao/JDBCSAMLSSOServiceProviderDAOImpl.java 86.47% 29 Missing and 14 partials ⚠️
.../identity/core/model/SAMLSSOServiceProviderDO.java 61.53% 3 Missing and 32 partials ⚠️
...y/core/persistence/IdentityPersistenceManager.java 0.00% 18 Missing ⚠️
...ity/core/dao/SAMLSSOPersistenceManagerFactory.java 92.85% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6197      +/-   ##
============================================
+ Coverage     45.66%   45.90%   +0.23%     
- Complexity    14040    14352     +312     
============================================
  Files          1632     1640       +8     
  Lines        100532   102823    +2291     
  Branches      17421    16885     -536     
============================================
+ Hits          45911    47198    +1287     
- Misses        47931    48815     +884     
- Partials       6690     6810     +120     
Flag Coverage Δ
unit 28.61% <72.79%> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Osara-B Osara-B force-pushed the fix-codecov-coverage branch from 9833bf2 to 33847a3 Compare December 17, 2024 10:13
@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/12404867110

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/12404867110
Status: failure

import static org.wso2.carbon.identity.core.dao.SAMLSSOServiceProviderConstants.SAML2TableColumns.PROPERTY_VALUE;
import static org.wso2.carbon.identity.core.dao.SAMLSSOServiceProviderConstants.SAML2TableColumns.SP_ID;

public class JDBCSAMLSSOServiceProviderDAOImpl implements SAMLSSOServiceProviderDAO {
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets add a class comment.


public class JDBCSAMLSSOServiceProviderDAOImpl implements SAMLSSOServiceProviderDAO {

private static final Log log = LogFactory.getLog(JDBCSAMLSSOServiceProviderDAOImpl.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private static final Log log = LogFactory.getLog(JDBCSAMLSSOServiceProviderDAOImpl.class);
private static final Log LOG = LogFactory.getLog(JDBCSAMLSSOServiceProviderDAOImpl.class);

public class JDBCSAMLSSOServiceProviderDAOImpl implements SAMLSSOServiceProviderDAO {

private static final Log log = LogFactory.getLog(JDBCSAMLSSOServiceProviderDAOImpl.class);
private int tenantId;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this instance variable? Having a instance variable for tenantId is could lead to lot of issues when same object are reused across many tenants.

Comment on lines +85 to +104
private static final String QUERY_TO_GET_APPLICATION_CERTIFICATE_ID = "SELECT " +
"META.VALUE FROM SP_INBOUND_AUTH INBOUND, SP_APP SP, SP_METADATA META WHERE SP.ID = INBOUND.APP_ID AND " +
"SP.ID = META.SP_ID AND META.NAME = ? AND INBOUND.INBOUND_AUTH_KEY = ? AND META.TENANT_ID = ?";
private static final String QUERY_TO_GET_APPLICATION_CERTIFICATE_ID_H2 = "SELECT " +
"META.`VALUE` FROM SP_INBOUND_AUTH INBOUND, SP_APP SP, SP_METADATA META WHERE SP.ID = INBOUND.APP_ID AND " +
"SP.ID = META.SP_ID AND META.NAME = ? AND INBOUND.INBOUND_AUTH_KEY = ? AND META.TENANT_ID = ?";
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't access the SP_ tables directly

return certificateId != null ? certificateId : -1;
}

}
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a new line

SAMLSSOServiceProviderDAO serviceProviderDAO = new SAMLSSOServiceProviderDAO(registry);
return serviceProviderDAO.addServiceProvider(serviceProviderDO);
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
SAMLSSOServiceProviderDAO serviceProviderDAO = new RegistrySAMLSSOServiceProviderDAOImpl();
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets change this to use Factory.

"META.`VALUE` FROM SP_INBOUND_AUTH INBOUND, SP_APP SP, SP_METADATA META WHERE SP.ID = INBOUND.APP_ID AND " +
"SP.ID = META.SP_ID AND META.NAME = ? AND INBOUND.INBOUND_AUTH_KEY = ? AND META.TENANT_ID = ?";

private static Log log = LogFactory.getLog(SAMLSSOServiceProviderDAO.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private static Log log = LogFactory.getLog(SAMLSSOServiceProviderDAO.class);
private static Log log = LogFactory.getLog(RegistrySAMLSSOServiceProviderDAOImpl.class);

private static final String HYBRID = "hybrid";
private static final String REGISTRY = "registry";

public SAMLSSOServiceProviderDAO buildSSOServiceProviderManager(){
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix formatting

@Osara-B Osara-B force-pushed the fix-codecov-coverage branch from 6d89915 to 1d8ffdd Compare December 19, 2024 09:47
break;
case REGISTRY:
samlSSOServiceProviderDAO = new RegistrySAMLSSOServiceProviderDAOImpl();
LOG.info("Registry based SAML storage initialized.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets change this to warn log

@Osara-B Osara-B force-pushed the fix-codecov-coverage branch 2 times, most recently from 8313f3f to 914a7de Compare December 19, 2024 16:14
@Osara-B Osara-B force-pushed the fix-codecov-coverage branch from 914a7de to 4b9f7e5 Compare December 19, 2024 16:41
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
5.8% Duplication on New Code (required ≤ 3%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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