Browse Source

Merge pull request #14245 from dashevchenko/edqsUserCreationFix

EDQS: fixed some tenant admins not displayed in related group
pull/14286/head
Viacheslav Klimov 11 months ago
committed by GitHub
parent
commit
0d83610821
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 27
      application/src/test/java/org/thingsboard/server/controller/AbstractNotifyEntityTest.java
  2. 8
      application/src/test/java/org/thingsboard/server/controller/UserControllerTest.java
  3. 4
      dao/src/main/java/org/thingsboard/server/dao/user/UserServiceImpl.java

27
application/src/test/java/org/thingsboard/server/controller/AbstractNotifyEntityTest.java

@ -128,11 +128,17 @@ public abstract class AbstractNotifyEntityTest extends AbstractWebTest {
protected void testNotifyEntityAllOneTimeLogEntityActionEntityEqClass(HasName entity, EntityId entityId, EntityId originatorId, protected void testNotifyEntityAllOneTimeLogEntityActionEntityEqClass(HasName entity, EntityId entityId, EntityId originatorId,
TenantId tenantId, CustomerId customerId, UserId userId, String userName, TenantId tenantId, CustomerId customerId, UserId userId, String userName,
ActionType actionType, ActionType actionTypeEdge, Object... additionalInfo) { ActionType actionType, ActionType actionTypeEdge, Object... additionalInfo) {
testNotifyEntityAllOneTimeLogEntityActionEntityEqClass(tenantId, entity, entityId, originatorId, tenantId, customerId, userId, userName, actionType, actionTypeEdge, additionalInfo);
}
protected void testNotifyEntityAllOneTimeLogEntityActionEntityEqClass(TenantId entityTenantId, HasName entity, EntityId entityId, EntityId originatorId,
TenantId authTenantId, CustomerId customerId, UserId userId, String userName,
ActionType actionType, ActionType actionTypeEdge, Object... additionalInfo) {
int cntTime = 1; int cntTime = 1;
testNotificationMsgToEdgeServiceTime(entityId, tenantId, actionTypeEdge, cntTime); testNotificationMsgToEdgeServiceTime(entityId, entityTenantId, actionTypeEdge, cntTime);
testLogEntityActionEntityEqClass(entity, originatorId, tenantId, customerId, userId, userName, actionType, cntTime, additionalInfo); testLogEntityActionEntityEqClass(entity, originatorId, authTenantId, customerId, userId, userName, actionType, cntTime, additionalInfo);
ArgumentMatcher<EntityId> matcherOriginatorId = argument -> argument.equals(originatorId); ArgumentMatcher<EntityId> matcherOriginatorId = argument -> argument.equals(originatorId);
testPushMsgToRuleEngineTime(matcherOriginatorId, tenantId, entity, cntTime); testPushMsgToRuleEngineTime(matcherOriginatorId, authTenantId, entity, cntTime);
Mockito.reset(tbClusterService, auditLogService); Mockito.reset(tbClusterService, auditLogService);
} }
@ -159,17 +165,26 @@ public abstract class AbstractNotifyEntityTest extends AbstractWebTest {
TenantId tenantId, CustomerId customerId, UserId userId, String userName, TenantId tenantId, CustomerId customerId, UserId userId, String userName,
ActionType actionType, ActionType actionType,
int cntTime, int cntTimeEdge, int cntTimeRuleEngine, Object... additionalInfo) { int cntTime, int cntTimeEdge, int cntTimeRuleEngine, Object... additionalInfo) {
testNotifyManyEntityManyTimeMsgToEdgeServiceEntityEqAny(tenantId, entity, originator, tenantId, customerId, userId, userName, actionType,
cntTime, cntTimeEdge, cntTimeRuleEngine, additionalInfo);
}
protected void testNotifyManyEntityManyTimeMsgToEdgeServiceEntityEqAny(TenantId entityTenantId, HasName entity, HasName originator,
TenantId authTenantId, CustomerId customerId, UserId userId, String userName,
ActionType actionType,
int cntTime, int cntTimeEdge, int cntTimeRuleEngine, Object... additionalInfo) {
EntityId originatorId = createEntityId_NULL_UUID(originator); EntityId originatorId = createEntityId_NULL_UUID(originator);
testSendNotificationMsgToEdgeServiceTimeEntityEqAny(tenantId, actionType, cntTimeEdge); testSendNotificationMsgToEdgeServiceTimeEntityEqAny(entityTenantId, actionType, cntTimeEdge);
ArgumentMatcher<HasName> matcherEntityClassEquals = argument -> argument.getClass().equals(entity.getClass()); ArgumentMatcher<HasName> matcherEntityClassEquals = argument -> argument.getClass().equals(entity.getClass());
ArgumentMatcher<EntityId> matcherOriginatorId = argument -> argument.getClass().equals(originatorId.getClass()); ArgumentMatcher<EntityId> matcherOriginatorId = argument -> argument.getClass().equals(originatorId.getClass());
ArgumentMatcher<CustomerId> matcherCustomerId = customerId == null ? ArgumentMatcher<CustomerId> matcherCustomerId = customerId == null ?
argument -> argument.getClass().equals(CustomerId.class) : argument -> argument.equals(customerId); argument -> argument.getClass().equals(CustomerId.class) : argument -> argument.equals(customerId);
ArgumentMatcher<UserId> matcherUserId = userId == null ? ArgumentMatcher<UserId> matcherUserId = userId == null ?
argument -> argument.getClass().equals(UserId.class) : argument -> argument.equals(userId); argument -> argument.getClass().equals(UserId.class) : argument -> argument.equals(userId);
testLogEntityActionAdditionalInfo(matcherEntityClassEquals, matcherOriginatorId, tenantId, matcherCustomerId, matcherUserId, userName, actionType, cntTime, testLogEntityActionAdditionalInfo(matcherEntityClassEquals, matcherOriginatorId, authTenantId, matcherCustomerId, matcherUserId, userName, actionType, cntTime,
extractMatcherAdditionalInfoClass(additionalInfo)); extractMatcherAdditionalInfoClass(additionalInfo));
testPushMsgToRuleEngineTime(matcherOriginatorId, tenantId, entity, cntTimeRuleEngine); testPushMsgToRuleEngineTime(matcherOriginatorId, authTenantId, entity, cntTimeRuleEngine);
} }
protected void testNotifyManyEntityManyTimeMsgToEdgeServiceEntityEqAnyAdditionalInfoAny(HasName entity, HasName originator, protected void testNotifyManyEntityManyTimeMsgToEdgeServiceEntityEqAnyAdditionalInfoAny(HasName entity, HasName originator,

8
application/src/test/java/org/thingsboard/server/controller/UserControllerTest.java

@ -116,7 +116,7 @@ public class UserControllerTest extends AbstractControllerTest {
foundUser.setAdditionalInfo(savedUser.getAdditionalInfo()); foundUser.setAdditionalInfo(savedUser.getAdditionalInfo());
Assert.assertEquals(foundUser, savedUser); Assert.assertEquals(foundUser, savedUser);
testNotifyManyEntityManyTimeMsgToEdgeServiceEntityEqAny(foundUser, foundUser, testNotifyManyEntityManyTimeMsgToEdgeServiceEntityEqAny(user.getTenantId(), foundUser, foundUser,
SYSTEM_TENANT, customerNUULId, null, SYS_ADMIN_EMAIL, SYSTEM_TENANT, customerNUULId, null, SYS_ADMIN_EMAIL,
ActionType.ADDED, 1, 1, 1); ActionType.ADDED, 1, 1, 1);
Mockito.reset(tbClusterService, auditLogService); Mockito.reset(tbClusterService, auditLogService);
@ -155,7 +155,7 @@ public class UserControllerTest extends AbstractControllerTest {
doDelete("/api/user/" + savedUser.getId().getId().toString()) doDelete("/api/user/" + savedUser.getId().getId().toString())
.andExpect(status().isOk()); .andExpect(status().isOk());
testNotifyEntityAllOneTimeLogEntityActionEntityEqClass(foundUser, foundUser.getId(), foundUser.getId(), testNotifyEntityAllOneTimeLogEntityActionEntityEqClass(user.getTenantId(), foundUser, foundUser.getId(), foundUser.getId(),
SYSTEM_TENANT, customerNUULId, null, SYS_ADMIN_EMAIL, SYSTEM_TENANT, customerNUULId, null, SYS_ADMIN_EMAIL,
ActionType.DELETED, ActionType.DELETED, SYSTEM_TENANT.getId().toString()); ActionType.DELETED, ActionType.DELETED, SYSTEM_TENANT.getId().toString());
} }
@ -414,7 +414,7 @@ public class UserControllerTest extends AbstractControllerTest {
User testManyUser = new User(); User testManyUser = new User();
testManyUser.setTenantId(tenantId); testManyUser.setTenantId(tenantId);
testNotifyManyEntityManyTimeMsgToEdgeServiceEntityEqAny(testManyUser, testManyUser, testNotifyManyEntityManyTimeMsgToEdgeServiceEntityEqAny(tenantId, testManyUser, testManyUser,
SYSTEM_TENANT, customerNUULId, null, SYS_ADMIN_EMAIL, SYSTEM_TENANT, customerNUULId, null, SYS_ADMIN_EMAIL,
ActionType.ADDED, cntEntity, cntEntity, cntEntity); ActionType.ADDED, cntEntity, cntEntity, cntEntity);
@ -526,7 +526,7 @@ public class UserControllerTest extends AbstractControllerTest {
} }
User testManyUser = new User(); User testManyUser = new User();
testManyUser.setTenantId(tenantId); testManyUser.setTenantId(tenantId);
testNotifyManyEntityManyTimeMsgToEdgeServiceEntityEqAny(testManyUser, testManyUser, testNotifyManyEntityManyTimeMsgToEdgeServiceEntityEqAny(tenantId, testManyUser, testManyUser,
SYSTEM_TENANT, customerNUULId, null, SYS_ADMIN_EMAIL, SYSTEM_TENANT, customerNUULId, null, SYS_ADMIN_EMAIL,
ActionType.DELETED, cntEntity, NUMBER_OF_USERS, cntEntity, ""); ActionType.DELETED, cntEntity, NUMBER_OF_USERS, cntEntity, "");

4
dao/src/main/java/org/thingsboard/server/dao/user/UserServiceImpl.java

@ -181,7 +181,7 @@ public class UserServiceImpl extends AbstractCachedEntityService<UserCacheKey, U
userCredentialsDao.save(user.getTenantId(), userCredentials); userCredentialsDao.save(user.getTenantId(), userCredentials);
} }
eventPublisher.publishEvent(SaveEntityEvent.builder() eventPublisher.publishEvent(SaveEntityEvent.builder()
.tenantId(tenantId == null ? TenantId.SYS_TENANT_ID : tenantId) .tenantId(savedUser.getTenantId())
.entity(savedUser) .entity(savedUser)
.oldEntity(oldUser) .oldEntity(oldUser)
.entityId(savedUser.getId()) .entityId(savedUser.getId())
@ -340,7 +340,7 @@ public class UserServiceImpl extends AbstractCachedEntityService<UserCacheKey, U
eventPublisher.publishEvent(new UserCredentialsInvalidationEvent(userId)); eventPublisher.publishEvent(new UserCredentialsInvalidationEvent(userId));
countService.publishCountEntityEvictEvent(tenantId, EntityType.USER); countService.publishCountEntityEvictEvent(tenantId, EntityType.USER);
eventPublisher.publishEvent(DeleteEntityEvent.builder() eventPublisher.publishEvent(DeleteEntityEvent.builder()
.tenantId(tenantId) .tenantId(user.getTenantId())
.entityId(userId) .entityId(userId)
.entity(user) .entity(user)
.cause(cause) .cause(cause)

Loading…
Cancel
Save