-
Notifications
You must be signed in to change notification settings - Fork 541
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
Enable API Resources APIs for organization level #6002
base: master
Are you sure you want to change the base?
Enable API Resources APIs for organization level #6002
Conversation
8a510db
to
39fa1e2
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6002 +/- ##
============================================
- Coverage 40.43% 40.37% -0.06%
+ Complexity 14687 14324 -363
============================================
Files 1746 1746
Lines 123017 117515 -5502
Branches 21841 19087 -2754
============================================
- Hits 49736 47444 -2292
+ Misses 65716 62792 -2924
+ Partials 7565 7279 -286
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
39fa1e2
to
1dba26c
Compare
...in/java/org/wso2/carbon/identity/api/resource/mgt/dao/impl/APIResourceManagementDAOImpl.java
Outdated
Show resolved
Hide resolved
...in/java/org/wso2/carbon/identity/api/resource/mgt/dao/impl/APIResourceManagementDAOImpl.java
Outdated
Show resolved
Hide resolved
1dba26c
to
ce692d6
Compare
...rg.wso2.carbon.identity.api.resource.mgt.server.feature/resources/system-api-resource.xml.j2
Show resolved
Hide resolved
...ource.mgt/src/main/java/org/wso2/carbon/identity/api/resource/mgt/constant/SQLConstants.java
Outdated
Show resolved
Hide resolved
1650b88
to
853e708
Compare
public static final String GET_API_RESOURCE_BY_ID_FOR_ORGANIZATIONS = "SELECT" + | ||
" AR.ID AS API_RESOURCE_ID," + | ||
" AR.NAME AS API_RESOURCE_NAME," + | ||
" AR.IDENTIFIER AS API_RESOURCE_IDENTIFIER," + | ||
" AR.DESCRIPTION AS API_RESOURCE_DESCRIPTION," + | ||
" AR.TENANT_ID AS API_RESOURCE_TENANT_ID," + | ||
" AR.TYPE AS API_RESOURCE_TYPE," + | ||
" AR.REQUIRES_AUTHORIZATION AS REQUIRES_AUTHORIZATION," + | ||
" S.ID AS SCOPE_ID," + | ||
" S.NAME AS SCOPE_QUALIFIED_NAME," + | ||
" S.DISPLAY_NAME AS SCOPE_DISPLAY_NAME," + | ||
" S.DESCRIPTION AS SCOPE_DESCRIPTION" + | ||
" FROM API_RESOURCE AR LEFT JOIN SCOPE S ON AR.ID = S.API_ID WHERE AR.ID = ? AND (AR.TENANT_ID = ?" + | ||
" OR AR.TENANT_ID IS NULL) AND AR.TYPE != 'TENANT' AND AR.TYPE != 'SYSTEM'"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do't we have DB-specific select queries. Does this query works on all of our supported DBs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of now this was tested against H2, MySQL and MSSQL. For those this is working as expected. Other DB type testings are in progress.
853e708
to
3a19343
Compare
{TENANT_ID, new ArrayList<>(), false, 2}, | ||
{INVALID_TENANT_ID, new ArrayList<>(), true, 0}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the combinations are less.
We need to execute the test for correct TENANT_ID and INVALID_TENANT_ID when isOrganization is false
TENANT_ID and INVALID_TENANT_ID when isOrganization is true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to test the INVALID_TENANT_ID when isOrganization is true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a new combination
String apiId = addAPIResourceToDB(name, getConnection(), tenantId, identityDatabaseUtil, | ||
organizationManagementUtil, isOrganization).getId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are not allowing to add API resources for sub orgs right?
As per this test, you are adding the API resources to the sub org tenant id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No we are not allowing to create the API resources in sub org level. Here the isOrganization
property is sending to the addAPIResourceToDB
is for the mock purposes.
Mocking is added since in the actual DAO method to add the API resource, it will retrieve the added API resource from the get method where we are checking whether the corresponding tenant is an organization or not.
@@ -529,6 +576,7 @@ private APIResource addAPIResourceToDB(String namePostFix, Connection connection | |||
connection.commit(); | |||
return null; | |||
}); | |||
organizationManagementUtil.when(() -> OrganizationManagementUtil.isOrganization(anyInt())).thenReturn(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this mocking is required? can't find a usage of this in the DAO impl of addAPIResource method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When adding the API resource, inside the DAO method, it will extract the added API resource from the id[1]. Inside that method we added the organization checkl and this mocking is needed for that.
[1]
Line 168 in 0033577
return getAPIResourceById(generatedAPIId, tenantId); |
@@ -243,16 +351,32 @@ public void testIsScopeExistById(Integer tenantId, boolean expected) throws Exce | |||
public Object[][] deleteAPIResourceByIdData() { | |||
|
|||
return new Object[][]{ | |||
{TENANT_ID, false} | |||
{TENANT_ID, false, false}, | |||
{TENANT_ID, true, false} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this test correct? in sub org level to we store API resource?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No we dont. Here what the test is adding a resource and deleting that. The isOrganization
property is for mocking purposes.
7bbfc39
to
8c3c429
Compare
8c3c429
to
13aa92b
Compare
Quality Gate passedIssues Measures |
Proposed changes in this pull request
Follow up actions