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

Allow API resource type change even when existing scopes are not modified #5932

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
.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 @@
.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
Loading