use of com.microsoft.azure.sdk.iot.service.ExportImportDevice in project azure-iot-sdk-java by Azure.
the class ExportImportDeviceTest method toParserIllegalStateThrownWhenUsingSelfSignedAuthenticationWithoutThumbprintSaved.
// Tests_SRS_SERVICE_SDK_JAVA_IMPORT_EXPORT_DEVICE_34_061: [If this device uses self signed authentication, but does not have a primary and secondary thumbprint saved, an IllegalStateException shall be thrown.]
@Test(expected = IllegalStateException.class)
public void toParserIllegalStateThrownWhenUsingSelfSignedAuthenticationWithoutThumbprintSaved() {
// arrange
ExportImportDevice device = new ExportImportDevice();
device.setId("someDevice");
AuthenticationMechanism authentication = new AuthenticationMechanism(AuthenticationType.SELF_SIGNED);
Deencapsulation.setField(authentication, "thumbprint", null);
device.setAuthentication(authentication);
// act
reflectivelyInvokeToExportImportDeviceParser(device);
}
use of com.microsoft.azure.sdk.iot.service.ExportImportDevice in project azure-iot-sdk-java by Azure.
the class ExportImportDeviceTest method constructorWithParserGeneratesMissingSecondaryThumbprintsWhenSelfSigned.
// Tests_SRS_SERVICE_SDK_JAVA_IMPORT_EXPORT_DEVICE_34_059: [If the provided parser uses self signed authentication and is missing one or both thumbprints, two new thumbprints will be generated.]
@Test
public void constructorWithParserGeneratesMissingSecondaryThumbprintsWhenSelfSigned() {
// arrange
ExportImportDeviceParser parser = new ExportImportDeviceParser();
parser.setId("someDevice");
parser.setAuthentication(new AuthenticationParser());
parser.getAuthenticationFinal().setType(AuthenticationTypeParser.SELF_SIGNED);
parser.getAuthenticationFinal().setThumbprint(new X509ThumbprintParser());
parser.getAuthenticationFinal().getThumbprint().setPrimaryThumbprint(SAMPLE_THUMBPRINT);
// act
ExportImportDevice device = reflectivelyInvokeExportImportDeviceParserConstructor(parser);
// assert
assertNotNull(device.getAuthenticationFinal());
assertNotNull(device.getAuthenticationFinal().getPrimaryThumbprint());
assertNotNull(device.getAuthenticationFinal().getSecondaryThumbprint());
assertNotEquals(SAMPLE_THUMBPRINT, device.getAuthenticationFinal().getPrimaryThumbprint());
}
use of com.microsoft.azure.sdk.iot.service.ExportImportDevice in project azure-iot-sdk-java by Azure.
the class ExportImportDeviceTest method createTestDevice.
/**
* Uses reflection to create an ExportImportDevice and sets the provided properties
* @param authentication the authentication the device uses
* @param importMode the import mode the device uses
* @param status the status of the device
* @return the created ExportImportDevice object
*/
private ExportImportDevice createTestDevice(AuthenticationMechanism authentication, ImportMode importMode, DeviceStatus status) {
ExportImportDevice device = Deencapsulation.newInstance(ExportImportDevice.class);
device.setAuthentication(authentication);
device.setImportMode(importMode);
device.setStatus(status);
return device;
}
use of com.microsoft.azure.sdk.iot.service.ExportImportDevice in project azure-iot-sdk-java by Azure.
the class ExportImportDeviceTest method toParserIllegalStateThrownWhenUsingSASAuthenticationWithoutPrimaryKeySaved.
// Tests_SRS_SERVICE_SDK_JAVA_IMPORT_EXPORT_DEVICE_34_060: [If this device uses sas authentication, but does not have a primary and secondary symmetric key saved, an IllegalStateException shall be thrown.]
@Test(expected = IllegalStateException.class)
public void toParserIllegalStateThrownWhenUsingSASAuthenticationWithoutPrimaryKeySaved() {
// arrange
ExportImportDevice device = new ExportImportDevice();
device.setId("someDevice");
AuthenticationMechanism authentication = new AuthenticationMechanism(AuthenticationType.SAS);
SymmetricKey symmetricKey = new SymmetricKey();
Deencapsulation.setField(symmetricKey, "primaryKey", null);
Deencapsulation.setField(authentication, "symmetricKey", symmetricKey);
device.setAuthentication(authentication);
// act
reflectivelyInvokeToExportImportDeviceParser(device);
}
use of com.microsoft.azure.sdk.iot.service.ExportImportDevice in project azure-iot-sdk-java by Azure.
the class ExportImportDeviceTest method emptyConstructorGeneratesDeviceIdSymmetricKeyAndAuthType.
// Tests_SRS_SERVICE_SDK_JAVA_IMPORT_EXPORT_DEVICE_34_050: [This constructor shall automatically set the authentication type of this object to be SAS, and shall generate a deviceId and symmetric key.]
@Test
public void emptyConstructorGeneratesDeviceIdSymmetricKeyAndAuthType() {
// act
ExportImportDevice device = new ExportImportDevice();
// assert
assertNotNull(device.getAuthenticationFinal());
assertNotNull(device.getAuthenticationFinal().getSymmetricKey());
assertEquals(AuthenticationType.SAS, device.getAuthenticationFinal().getAuthenticationType());
}
Aggregations