Fix oauth
This commit is contained in:
parent
646c8679a6
commit
16d1e353fe
@ -160,6 +160,7 @@ public class EdgeEventSourcingListener {
|
||||
private boolean isValidSaveEntityEventForEdgeProcessing(SaveEntityEvent<?> event) {
|
||||
Object entity = event.getEntity();
|
||||
Object oldEntity = event.getOldEntity();
|
||||
if (event.getEntityId() != null) {
|
||||
switch (event.getEntityId().getEntityType()) {
|
||||
case RULE_CHAIN:
|
||||
if (entity instanceof RuleChain ruleChain) {
|
||||
@ -194,6 +195,7 @@ public class EdgeEventSourcingListener {
|
||||
case API_USAGE_STATE, EDGE:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Default: If the entity doesn't match any of the conditions, consider it as valid.
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -55,7 +55,6 @@ public class OAuth2EdgeProcessor extends BaseEdgeProcessor {
|
||||
if (oAuth2Info == null) {
|
||||
return Futures.immediateFuture(null);
|
||||
}
|
||||
|
||||
EdgeEventType type = EdgeEventType.valueOf(edgeNotificationMsg.getType());
|
||||
EdgeEventActionType actionType = EdgeEventActionType.valueOf(edgeNotificationMsg.getAction());
|
||||
return processActionForAllEdges(tenantId, type, actionType, null, JacksonUtil.toJsonNode(edgeNotificationMsg.getBody()), null);
|
||||
|
||||
@ -63,6 +63,7 @@ import org.thingsboard.server.common.data.id.DeviceProfileId;
|
||||
import org.thingsboard.server.common.data.id.EdgeId;
|
||||
import org.thingsboard.server.common.data.id.RuleChainId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2Info;
|
||||
import org.thingsboard.server.common.data.ota.ChecksumAlgorithm;
|
||||
import org.thingsboard.server.common.data.ota.OtaPackageType;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
@ -85,6 +86,7 @@ import org.thingsboard.server.gen.edge.v1.CustomerUpdateMsg;
|
||||
import org.thingsboard.server.gen.edge.v1.DeviceProfileUpdateMsg;
|
||||
import org.thingsboard.server.gen.edge.v1.DeviceUpdateMsg;
|
||||
import org.thingsboard.server.gen.edge.v1.EdgeConfiguration;
|
||||
import org.thingsboard.server.gen.edge.v1.OAuth2UpdateMsg;
|
||||
import org.thingsboard.server.gen.edge.v1.QueueUpdateMsg;
|
||||
import org.thingsboard.server.gen.edge.v1.RuleChainMetadataRequestMsg;
|
||||
import org.thingsboard.server.gen.edge.v1.RuleChainMetadataUpdateMsg;
|
||||
@ -140,6 +142,7 @@ abstract public class AbstractEdgeTest extends AbstractControllerTest {
|
||||
installation();
|
||||
|
||||
edgeImitator = new EdgeImitator("localhost", 7070, edge.getRoutingKey(), edge.getSecret());
|
||||
edgeImitator.ignoreType(OAuth2UpdateMsg.class);
|
||||
edgeImitator.expectMessageAmount(21);
|
||||
edgeImitator.connect();
|
||||
|
||||
@ -538,6 +541,18 @@ abstract public class AbstractEdgeTest extends AbstractControllerTest {
|
||||
Assert.assertTrue(customer.isPublic());
|
||||
}
|
||||
|
||||
private void validateOAuth2() throws Exception {
|
||||
Optional<OAuth2UpdateMsg> oAuth2UpdateMsgOpt = edgeImitator.findMessageByType(OAuth2UpdateMsg.class);
|
||||
Assert.assertTrue(oAuth2UpdateMsgOpt.isPresent());
|
||||
OAuth2UpdateMsg oAuth2UpdateMsg = oAuth2UpdateMsgOpt.get();
|
||||
OAuth2Info oAuth2Info = JacksonUtil.fromString(oAuth2UpdateMsg.getEntity(), OAuth2Info.class, true);
|
||||
Assert.assertNotNull(oAuth2Info);
|
||||
OAuth2Info auth2Info = doGet("/api/oauth2/config", OAuth2Info.class);
|
||||
Assert.assertNotNull(auth2Info);
|
||||
Assert.assertEquals(oAuth2Info, auth2Info);
|
||||
testAutoGeneratedCodeByProtobuf(oAuth2UpdateMsg);
|
||||
}
|
||||
|
||||
private void validateSyncCompleted() {
|
||||
Optional<SyncCompletedMsg> syncCompletedMsgOpt = edgeImitator.findMessageByType(SyncCompletedMsg.class);
|
||||
Assert.assertTrue(syncCompletedMsgOpt.isPresent());
|
||||
|
||||
@ -43,6 +43,7 @@ public class OAuth2EdgeTest extends AbstractEdgeTest {
|
||||
loginSysAdmin();
|
||||
|
||||
// enable oauth, verify nothing sent to edge
|
||||
edgeImitator.allowIgnoredTypes();
|
||||
edgeImitator.expectMessageAmount(1);
|
||||
OAuth2Info oAuth2Info = createDefaultOAuth2Info();
|
||||
oAuth2Info = doPost("/api/oauth2/config", oAuth2Info, OAuth2Info.class);
|
||||
@ -65,6 +66,7 @@ public class OAuth2EdgeTest extends AbstractEdgeTest {
|
||||
result = JacksonUtil.fromString(oAuth2UpdateMsg.getEntity(), OAuth2Info.class, true);
|
||||
Assert.assertEquals(oAuth2Info, result);
|
||||
|
||||
edgeImitator.ignoreType(OAuth2UpdateMsg.class);
|
||||
loginTenantAdmin();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user