fixed customer id check for CustomerData
This commit is contained in:
parent
8966ec8b01
commit
32611a19c6
@ -1116,6 +1116,29 @@ public class EntityServiceTest extends AbstractControllerTest {
|
|||||||
assertThat(deviceName).isEqualTo(devices.get(0).getName());
|
assertThat(deviceName).isEqualTo(devices.get(0).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFindCustomerBySingleEntityFilter() {
|
||||||
|
SingleEntityFilter singleEntityFilter = new SingleEntityFilter();
|
||||||
|
singleEntityFilter.setSingleEntity(customerId);
|
||||||
|
List<EntityKey> entityFields = List.of(
|
||||||
|
new EntityKey(EntityKeyType.ENTITY_FIELD, "name")
|
||||||
|
);
|
||||||
|
EntityDataPageLink pageLink = new EntityDataPageLink(1000, 0, null, null);
|
||||||
|
EntityDataQuery query = new EntityDataQuery(singleEntityFilter, pageLink, entityFields, null, null);
|
||||||
|
|
||||||
|
//find by tenant
|
||||||
|
PageData<EntityData> result = findByQueryAndCheck(query, 1);
|
||||||
|
String customerName = result.getData().get(0).getLatest().get(EntityKeyType.ENTITY_FIELD).get("name").getValue();
|
||||||
|
assertThat(customerName).isEqualTo(TEST_CUSTOMER_NAME);
|
||||||
|
|
||||||
|
// find by customer user with generic permission
|
||||||
|
PageData<EntityData> customerResults = findByQueryAndCheck(customerId, query, 1);
|
||||||
|
|
||||||
|
customerName = customerResults.getData().get(0).getLatest().get(EntityKeyType.ENTITY_FIELD).get("name").getValue();
|
||||||
|
assertThat(customerName).isEqualTo(TEST_CUSTOMER_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFindEntitiesByRelationEntityTypeFilter() {
|
public void testFindEntitiesByRelationEntityTypeFilter() {
|
||||||
Customer customer = new Customer();
|
Customer customer = new Customer();
|
||||||
|
|||||||
@ -65,7 +65,8 @@ public abstract class AbstractQueryProcessor<T extends EntityFilter> implements
|
|||||||
|
|
||||||
protected static boolean checkCustomerId(UUID customerId, EntityData<?> ed) {
|
protected static boolean checkCustomerId(UUID customerId, EntityData<?> ed) {
|
||||||
return customerId.equals(ed.getCustomerId()) || (ed.getEntityType() == EntityType.DASHBOARD &&
|
return customerId.equals(ed.getCustomerId()) || (ed.getEntityType() == EntityType.DASHBOARD &&
|
||||||
ed.getFields().getAssignedCustomerIds().contains(customerId));
|
ed.getFields().getAssignedCustomerIds().contains(customerId)
|
||||||
|
|| (ed.getEntityType() == EntityType.CUSTOMER && customerId.equals(ed.getId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean matches(EntityData<?> ed) {
|
protected boolean matches(EntityData<?> ed) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user