use of org.thingsboard.server.common.data.security.DeviceCredentials in project thingsboard by thingsboard.
the class BaseDeviceCredentialsCacheTest method createDummyDeviceCredentialsEntity.
private DeviceCredentials createDummyDeviceCredentialsEntity(String deviceCredentialsId) {
DeviceCredentials result = new DeviceCredentials(new DeviceCredentialsId(UUID.randomUUID()));
result.setCredentialsId(deviceCredentialsId);
return result;
}
use of org.thingsboard.server.common.data.security.DeviceCredentials in project thingsboard by thingsboard.
the class BaseDeviceCredentialsServiceTest method testSaveDeviceCredentialsWithEmptyCredentialsId.
@Test(expected = DataValidationException.class)
public void testSaveDeviceCredentialsWithEmptyCredentialsId() {
Device device = new Device();
device.setName("My device");
device.setType("default");
device.setTenantId(tenantId);
device = deviceService.saveDevice(device);
DeviceCredentials deviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(device.getId());
deviceCredentials.setCredentialsId(null);
try {
deviceCredentialsService.updateDeviceCredentials(deviceCredentials);
} finally {
deviceService.deleteDevice(device.getId());
}
}
use of org.thingsboard.server.common.data.security.DeviceCredentials in project thingsboard by thingsboard.
the class BaseDeviceCredentialsServiceTest method testSaveDeviceCredentials.
@Test
public void testSaveDeviceCredentials() {
Device device = new Device();
device.setTenantId(tenantId);
device.setName("My device");
device.setType("default");
Device savedDevice = deviceService.saveDevice(device);
DeviceCredentials deviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(savedDevice.getId());
Assert.assertEquals(savedDevice.getId(), deviceCredentials.getDeviceId());
deviceCredentials.setCredentialsType(DeviceCredentialsType.ACCESS_TOKEN);
deviceCredentials.setCredentialsId("access_token");
deviceCredentialsService.updateDeviceCredentials(deviceCredentials);
DeviceCredentials foundDeviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(savedDevice.getId());
Assert.assertEquals(deviceCredentials, foundDeviceCredentials);
deviceService.deleteDevice(savedDevice.getId());
}
use of org.thingsboard.server.common.data.security.DeviceCredentials in project thingsboard by thingsboard.
the class BaseDeviceCredentialsServiceTest method testCreateDeviceCredentials.
@Test(expected = DataValidationException.class)
public void testCreateDeviceCredentials() {
DeviceCredentials deviceCredentials = new DeviceCredentials();
deviceCredentialsService.updateDeviceCredentials(deviceCredentials);
}
use of org.thingsboard.server.common.data.security.DeviceCredentials in project thingsboard by thingsboard.
the class BaseDeviceCredentialsServiceTest method testSaveDeviceCredentialsWithEmptyDevice.
@Test(expected = DataValidationException.class)
public void testSaveDeviceCredentialsWithEmptyDevice() {
Device device = new Device();
device.setName("My device");
device.setType("default");
device.setTenantId(tenantId);
device = deviceService.saveDevice(device);
DeviceCredentials deviceCredentials = deviceCredentialsService.findDeviceCredentialsByDeviceId(device.getId());
deviceCredentials.setDeviceId(null);
try {
deviceCredentialsService.updateDeviceCredentials(deviceCredentials);
} finally {
deviceService.deleteDevice(device.getId());
}
}
Aggregations