Browse Source

removed authority customer user for endpoints

pull/12009/head
IrynaMatveieva 2 years ago
parent
commit
3c073bad6e
  1. 4
      application/src/main/java/org/thingsboard/server/controller/CalculatedFieldController.java
  2. 4
      dao/src/main/java/org/thingsboard/server/dao/device/DeviceProfileServiceImpl.java
  3. 1
      dao/src/test/java/org/thingsboard/server/dao/service/AssetProfileServiceTest.java
  4. 5
      dao/src/test/java/org/thingsboard/server/dao/service/DeviceProfileServiceTest.java

4
application/src/main/java/org/thingsboard/server/controller/CalculatedFieldController.java

@ -57,7 +57,7 @@ public class CalculatedFieldController extends BaseController {
"Referencing non-existing Calculated Field Id will cause 'Not Found' error. " +
"Remove 'id', 'tenantId' from the request body example (below) to create new Calculated Field entity. "
+ TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH)
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
@RequestMapping(value = "/calculatedField", method = RequestMethod.POST)
@ResponseBody
public CalculatedField saveCalculatedField(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "A JSON value representing the calculated field.")
@ -70,7 +70,7 @@ public class CalculatedFieldController extends BaseController {
@ApiOperation(value = "Get Calculated Field (getCalculatedFieldById)",
notes = "Fetch the Calculated Field object based on the provided Calculated Field Id."
)
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
@RequestMapping(value = "/calculatedField/{calculatedFieldId}", method = RequestMethod.GET)
@ResponseBody
public CalculatedField getCalculatedFieldById(@Parameter @PathVariable(CALCULATED_FIELD_ID) String strCalculatedFieldId) throws ThingsboardException {

4
dao/src/main/java/org/thingsboard/server/dao/device/DeviceProfileServiceImpl.java

@ -230,8 +230,8 @@ public class DeviceProfileServiceImpl extends CachedVersionedEntityService<Devic
if (deviceProfile == null) {
return;
}
if (!force && entityViewService.existsByTenantIdAndEntityId(tenantId, id)) {
throw new DataValidationException("Can't delete device that has entity views!");
if (!force && deviceProfile.isDefault()) {
throw new DataValidationException("Deletion of Default Device Profile is prohibited!");
}
removeDeviceProfile(tenantId, deviceProfile);
}

1
dao/src/test/java/org/thingsboard/server/dao/service/AssetProfileServiceTest.java

@ -380,4 +380,5 @@ public class AssetProfileServiceTest extends AbstractServiceTest {
assertThat(assetProfileInfos).isEqualTo(expected);
}
}

5
dao/src/test/java/org/thingsboard/server/dao/service/DeviceProfileServiceTest.java

@ -31,11 +31,9 @@ import org.thingsboard.server.common.data.DeviceProfileInfo;
import org.thingsboard.server.common.data.DeviceTransportType;
import org.thingsboard.server.common.data.EntityInfo;
import org.thingsboard.server.common.data.OtaPackage;
import org.thingsboard.server.common.data.calculated_field.CalculatedField;
import org.thingsboard.server.common.data.ota.ChecksumAlgorithm;
import org.thingsboard.server.common.data.page.PageData;
import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.dao.calculated_field.CalculatedFieldService;
import org.thingsboard.server.dao.device.DeviceProfileService;
import org.thingsboard.server.dao.device.DeviceService;
import org.thingsboard.server.dao.exception.DataValidationException;
@ -51,7 +49,6 @@ import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.thingsboard.server.common.data.ota.OtaPackageType.FIRMWARE;
@DaoSqlTest
@ -400,7 +397,7 @@ public class DeviceProfileServiceTest extends AbstractServiceTest {
var profileA = deviceProfileService.saveDeviceProfile(
createDeviceProfile(tenantId, "profile A"));
createDeviceProfile(tenantId, "profile A"));
deviceProfiles.add(deviceProfileService.saveDeviceProfile(profileA));

Loading…
Cancel
Save