Skip to content

Commit

Permalink
Allow API resource type change even when existing scopes are not modi…
Browse files Browse the repository at this point in the history
…fied
  • Loading branch information
sadilchamishka committed Sep 11, 2024
1 parent 1f23c06 commit 8de7d27
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
* Copyright (c) 2023-2024, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand All @@ -19,6 +19,7 @@
package org.wso2.carbon.identity.api.resource.mgt.util;

import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.api.resource.mgt.APIResourceManagerImpl;
Expand Down Expand Up @@ -118,7 +119,8 @@ public static void addSystemAPIs() {
.filter(scope1 -> apiResourceFromDB.getScopes().stream()
.noneMatch(scope2 -> scope2.getName().equals(scope1.getName())))
.collect(Collectors.toList());
if (addedScopes.isEmpty()) {
if (addedScopes.isEmpty() &&
!StringUtils.equals(apiResourceFromDB.getType(), updatedAPIResource.getType())) {
continue;
}

Expand All @@ -131,7 +133,7 @@ public static void addSystemAPIs() {
.type(updatedAPIResource.getType())
.tenantId(apiResourceFromDB.getTenantId())
.requiresAuthorization(apiResourceFromDB.isAuthorizationRequired())
.scopes(updatedAPIResource.getScopes())
.scopes(apiResourceFromDB.getScopes())

Check warning on line 136 in components/api-resource-mgt/org.wso2.carbon.identity.api.resource.mgt/src/main/java/org/wso2/carbon/identity/api/resource/mgt/util/APIResourceManagementUtil.java

View check run for this annotation

Codecov / codecov/patch

components/api-resource-mgt/org.wso2.carbon.identity.api.resource.mgt/src/main/java/org/wso2/carbon/identity/api/resource/mgt/util/APIResourceManagementUtil.java#L136

Added line #L136 was not covered by tests
.subscribedApplications(apiResourceFromDB.getSubscribedApplications())
.properties(apiResourceFromDB.getProperties())
.build();
Expand Down

0 comments on commit 8de7d27

Please sign in to comment.