Browse Source

extended widgetTypes access to customer user authority

pull/9687/head
dashevchenko 3 years ago
parent
commit
3f2633fba5
  1. 4
      application/src/main/java/org/thingsboard/server/controller/WidgetTypeController.java
  2. 14
      application/src/test/java/org/thingsboard/server/controller/WidgetTypeControllerTest.java

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

@ -216,7 +216,7 @@ public class WidgetTypeController extends AutoCommitController {
@ApiOperation(value = "Get all Widget types for specified Bundle (getBundleWidgetTypes)",
notes = "Returns an array of Widget Type objects that belong to specified Widget Bundle." + WIDGET_TYPE_DESCRIPTION + " " + SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH)
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
@RequestMapping(value = "/widgetTypes", params = {"widgetsBundleId"}, method = RequestMethod.GET)
@ResponseBody
public List<WidgetType> getBundleWidgetTypes(
@ -248,7 +248,7 @@ public class WidgetTypeController extends AutoCommitController {
@ApiOperation(value = "Get all Widget types details for specified Bundle (getBundleWidgetTypes)",
notes = "Returns an array of Widget Type Details objects that belong to specified Widget Bundle." + WIDGET_TYPE_DETAILS_DESCRIPTION + " " + SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH)
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
@RequestMapping(value = "/widgetTypesDetails", params = {"widgetsBundleId"}, method = RequestMethod.GET)
@ResponseBody
public List<WidgetTypeDetails> getBundleWidgetTypesDetails(

14
application/src/test/java/org/thingsboard/server/controller/WidgetTypeControllerTest.java

@ -190,6 +190,20 @@ public class WidgetTypeControllerTest extends AbstractControllerTest {
Collections.sort(loadedWidgetTypes, idComparator);
Assert.assertEquals(widgetTypes, loadedWidgetTypes);
loginCustomerUser();
List<WidgetType> loadedWidgetTypes2 = doGetTyped("/api/widgetTypes?widgetsBundleId={widgetsBundleId}",
new TypeReference<>(){}, widgetsBundle.getId().getId().toString());
Collections.sort(loadedWidgetTypes2, idComparator);
Assert.assertEquals(widgetTypes, loadedWidgetTypes2);
List<WidgetTypeDetails> loadedWidgetTypes3 = doGetTyped("/api/widgetTypesDetails?widgetsBundleId={widgetsBundleId}",
new TypeReference<>(){}, widgetsBundle.getId().getId().toString());
List<WidgetType> widgetTypes3 = loadedWidgetTypes3.stream().map(WidgetType::new).collect(Collectors.toList());
Collections.sort(widgetTypes3, idComparator);
Assert.assertEquals(widgetTypes3, loadedWidgetTypes);
}
@Test

Loading…
Cancel
Save