Search in sources :

Example 1 with ProvisionDeviceResponseMsg

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

the class AbstractCoapProvisionProtoDeviceTest method processTestProvisioningCreateNewDeviceWithAccessToken.

private void processTestProvisioningCreateNewDeviceWithAccessToken() throws Exception {
    super.processBeforeTest("Test Provision device3", CoapDeviceType.DEFAULT, TransportPayloadType.PROTOBUF, null, null, null, null, "testProvisionKey", "testProvisionSecret", DeviceProfileProvisionType.ALLOW_CREATE_NEW_DEVICES);
    CredentialsDataProto requestCredentials = CredentialsDataProto.newBuilder().setValidateDeviceTokenRequestMsg(ValidateDeviceTokenRequestMsg.newBuilder().setToken("test_token").build()).build();
    ProvisionDeviceResponseMsg response = ProvisionDeviceResponseMsg.parseFrom(createCoapClientAndPublish(createTestsProvisionMessage(CredentialsType.ACCESS_TOKEN, requestCredentials)).getPayload());
    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)

Example 2 with ProvisionDeviceResponseMsg

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

the class AbstractCoapProvisionProtoDeviceTest method processTestProvisioningWithBadKeyDevice.

private void processTestProvisioningWithBadKeyDevice() throws Exception {
    super.processBeforeTest("Test Provision device", CoapDeviceType.DEFAULT, TransportPayloadType.PROTOBUF, null, null, null, null, "testProvisionKeyOrig", "testProvisionSecret", DeviceProfileProvisionType.CHECK_PRE_PROVISIONED_DEVICES);
    ProvisionDeviceResponseMsg response = ProvisionDeviceResponseMsg.parseFrom(createCoapClientAndPublish().getPayload());
    Assert.assertEquals(ProvisionResponseStatus.NOT_FOUND.name(), response.getStatus().toString());
}
Also used : ProvisionDeviceResponseMsg(org.thingsboard.server.gen.transport.TransportProtos.ProvisionDeviceResponseMsg)

Example 3 with ProvisionDeviceResponseMsg

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

the class AbstractCoapProvisionProtoDeviceTest method processTestProvisioningDisabledDevice.

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

Example 4 with ProvisionDeviceResponseMsg

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

the class AbstractMqttProvisionProtoDeviceTest method processTestProvisioningCreateNewDeviceWithCert.

protected void processTestProvisioningCreateNewDeviceWithCert() 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().setValidateDeviceX509CertRequestMsg(ValidateDeviceX509CertRequestMsg.newBuilder().setHash("testHash").build()).build();
    ProvisionDeviceResponseMsg response = ProvisionDeviceResponseMsg.parseFrom(createMqttClientAndPublish(createTestsProvisionMessage(CredentialsType.X509_CERTIFICATE, 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.X509_CERTIFICATE);
    String cert = EncryptionUtil.certTrimNewLines(deviceCredentials.getCredentialsValue());
    String sha3Hash = EncryptionUtil.getSha3Hash(cert);
    Assert.assertEquals(deviceCredentials.getCredentialsId(), sha3Hash);
    Assert.assertEquals(deviceCredentials.getCredentialsValue(), "testHash");
    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)

Example 5 with ProvisionDeviceResponseMsg

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

the class AbstractMqttProvisionProtoDeviceTest method processTestProvisioningWithBadKeyDevice.

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

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