Search in sources :

Example 6 with ProvisionDeviceResponseMsg

use of org.thingsboard.server.gen.transport.TransportProtos.ProvisionDeviceResponseMsg in project thingsboard by thingsboard.

the class AbstractMqttProvisionProtoDeviceTest method processTestProvisioningDisabledDevice.

protected void processTestProvisioningDisabledDevice() throws Exception {
    super.processBeforeTest("Test Provision device", "Test Provision gateway", TransportPayloadType.PROTOBUF, null, null, null, null, null, null, null, null, DeviceProfileProvisionType.DISABLED, false, false);
    ProvisionDeviceResponseMsg result = ProvisionDeviceResponseMsg.parseFrom(createMqttClientAndPublish().getPayloadBytes());
    Assert.assertNotNull(result);
    Assert.assertEquals(ProvisionResponseStatus.NOT_FOUND.name(), result.getStatus().toString());
}
Also used : ProvisionDeviceResponseMsg(org.thingsboard.server.gen.transport.TransportProtos.ProvisionDeviceResponseMsg)

Example 7 with ProvisionDeviceResponseMsg

use of org.thingsboard.server.gen.transport.TransportProtos.ProvisionDeviceResponseMsg in project thingsboard by thingsboard.

the class AbstractMqttProvisionProtoDeviceTest method processTestProvisioningCreateNewDeviceWithMqttBasic.

protected void processTestProvisioningCreateNewDeviceWithMqttBasic() throws Exception {
    super.processBeforeTest("Test Provision device3", "Test Provision gateway", TransportPayloadType.PROTOBUF, null, null, null, null, null, null, "testProvisionKey", "testProvisionSecret", DeviceProfileProvisionType.ALLOW_CREATE_NEW_DEVICES, false, false);
    CredentialsDataProto requestCredentials = CredentialsDataProto.newBuilder().setValidateBasicMqttCredRequestMsg(ValidateBasicMqttCredRequestMsg.newBuilder().setClientId("test_clientId").setUserName("test_username").setPassword("test_password").build()).build();
    ProvisionDeviceResponseMsg response = ProvisionDeviceResponseMsg.parseFrom(createMqttClientAndPublish(createTestsProvisionMessage(CredentialsType.MQTT_BASIC, requestCredentials)).getPayloadBytes());
    Device createdDevice = deviceService.findDeviceByTenantIdAndName(savedTenant.getTenantId(), "Test Provision device");
    Assert.assertNotNull(createdDevice);
    DeviceCredentials deviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(savedTenant.getTenantId(), createdDevice.getId());
    Assert.assertEquals(deviceCredentials.getCredentialsType().name(), response.getCredentialsType().toString());
    Assert.assertEquals(deviceCredentials.getCredentialsType(), DeviceCredentialsType.MQTT_BASIC);
    Assert.assertEquals(deviceCredentials.getCredentialsId(), EncryptionUtil.getSha3Hash("|", "test_clientId", "test_username"));
    BasicMqttCredentials mqttCredentials = new BasicMqttCredentials();
    mqttCredentials.setClientId("test_clientId");
    mqttCredentials.setUserName("test_username");
    mqttCredentials.setPassword("test_password");
    Assert.assertEquals(deviceCredentials.getCredentialsValue(), JacksonUtil.toString(mqttCredentials));
    Assert.assertEquals(ProvisionResponseStatus.SUCCESS.name(), response.getStatus().toString());
}
Also used : CredentialsDataProto(org.thingsboard.server.gen.transport.TransportProtos.CredentialsDataProto) BasicMqttCredentials(org.thingsboard.server.common.data.device.credentials.BasicMqttCredentials) ProvisionDeviceResponseMsg(org.thingsboard.server.gen.transport.TransportProtos.ProvisionDeviceResponseMsg) Device(org.thingsboard.server.common.data.Device) DeviceCredentials(org.thingsboard.server.common.data.security.DeviceCredentials)

Example 8 with ProvisionDeviceResponseMsg

use of org.thingsboard.server.gen.transport.TransportProtos.ProvisionDeviceResponseMsg in project thingsboard by thingsboard.

the class AbstractMqttProvisionProtoDeviceTest method processTestProvisioningCheckPreProvisionedDevice.

protected void processTestProvisioningCheckPreProvisionedDevice() throws Exception {
    super.processBeforeTest("Test Provision device", "Test Provision gateway", TransportPayloadType.PROTOBUF, null, null, null, null, null, null, "testProvisionKey", "testProvisionSecret", DeviceProfileProvisionType.CHECK_PRE_PROVISIONED_DEVICES, false, false);
    ProvisionDeviceResponseMsg response = ProvisionDeviceResponseMsg.parseFrom(createMqttClientAndPublish().getPayloadBytes());
    DeviceCredentials deviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(savedTenant.getTenantId(), savedDevice.getId());
    Assert.assertEquals(deviceCredentials.getCredentialsType().name(), response.getCredentialsType().toString());
    Assert.assertEquals(ProvisionResponseStatus.SUCCESS.name(), response.getStatus().toString());
}
Also used : ProvisionDeviceResponseMsg(org.thingsboard.server.gen.transport.TransportProtos.ProvisionDeviceResponseMsg) DeviceCredentials(org.thingsboard.server.common.data.security.DeviceCredentials)

Example 9 with ProvisionDeviceResponseMsg

use of org.thingsboard.server.gen.transport.TransportProtos.ProvisionDeviceResponseMsg in project thingsboard by thingsboard.

the class AbstractMqttProvisionProtoDeviceTest method processTestProvisioningCreateNewDeviceWithoutCredentials.

protected void processTestProvisioningCreateNewDeviceWithoutCredentials() throws Exception {
    super.processBeforeTest("Test Provision device3", "Test Provision gateway", TransportPayloadType.PROTOBUF, null, null, null, null, null, null, "testProvisionKey", "testProvisionSecret", DeviceProfileProvisionType.ALLOW_CREATE_NEW_DEVICES, false, false);
    ProvisionDeviceResponseMsg response = ProvisionDeviceResponseMsg.parseFrom(createMqttClientAndPublish().getPayloadBytes());
    Device createdDevice = deviceService.findDeviceByTenantIdAndName(savedTenant.getTenantId(), "Test Provision device");
    Assert.assertNotNull(createdDevice);
    DeviceCredentials deviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(savedTenant.getTenantId(), createdDevice.getId());
    Assert.assertEquals(deviceCredentials.getCredentialsType().name(), response.getCredentialsType().toString());
    Assert.assertEquals(ProvisionResponseStatus.SUCCESS.name(), response.getStatus().toString());
}
Also used : ProvisionDeviceResponseMsg(org.thingsboard.server.gen.transport.TransportProtos.ProvisionDeviceResponseMsg) Device(org.thingsboard.server.common.data.Device) DeviceCredentials(org.thingsboard.server.common.data.security.DeviceCredentials)

Example 10 with ProvisionDeviceResponseMsg

use of org.thingsboard.server.gen.transport.TransportProtos.ProvisionDeviceResponseMsg in project thingsboard by thingsboard.

the class AbstractMqttProvisionProtoDeviceTest method processTestProvisioningCreateNewDeviceWithAccessToken.

protected void processTestProvisioningCreateNewDeviceWithAccessToken() throws Exception {
    super.processBeforeTest("Test Provision device3", "Test Provision gateway", TransportPayloadType.PROTOBUF, null, null, null, null, null, null, "testProvisionKey", "testProvisionSecret", DeviceProfileProvisionType.ALLOW_CREATE_NEW_DEVICES, false, false);
    CredentialsDataProto requestCredentials = CredentialsDataProto.newBuilder().setValidateDeviceTokenRequestMsg(ValidateDeviceTokenRequestMsg.newBuilder().setToken("test_token").build()).build();
    ProvisionDeviceResponseMsg response = ProvisionDeviceResponseMsg.parseFrom(createMqttClientAndPublish(createTestsProvisionMessage(CredentialsType.ACCESS_TOKEN, requestCredentials)).getPayloadBytes());
    Device createdDevice = deviceService.findDeviceByTenantIdAndName(savedTenant.getTenantId(), "Test Provision device");
    Assert.assertNotNull(createdDevice);
    DeviceCredentials deviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(savedTenant.getTenantId(), createdDevice.getId());
    Assert.assertEquals(deviceCredentials.getCredentialsType().name(), response.getCredentialsType().toString());
    Assert.assertEquals(deviceCredentials.getCredentialsType(), DeviceCredentialsType.ACCESS_TOKEN);
    Assert.assertEquals(deviceCredentials.getCredentialsId(), "test_token");
    Assert.assertEquals(ProvisionResponseStatus.SUCCESS.name(), response.getStatus().toString());
}
Also used : CredentialsDataProto(org.thingsboard.server.gen.transport.TransportProtos.CredentialsDataProto) ProvisionDeviceResponseMsg(org.thingsboard.server.gen.transport.TransportProtos.ProvisionDeviceResponseMsg) Device(org.thingsboard.server.common.data.Device) DeviceCredentials(org.thingsboard.server.common.data.security.DeviceCredentials)

Aggregations

ProvisionDeviceResponseMsg (org.thingsboard.server.gen.transport.TransportProtos.ProvisionDeviceResponseMsg)13 DeviceCredentials (org.thingsboard.server.common.data.security.DeviceCredentials)9 Device (org.thingsboard.server.common.data.Device)7 CredentialsDataProto (org.thingsboard.server.gen.transport.TransportProtos.CredentialsDataProto)5 BasicMqttCredentials (org.thingsboard.server.common.data.device.credentials.BasicMqttCredentials)1