use of com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism in project azure-iot-sdk-java by Azure.
the class AuthenticationMechanismTest method constructorThrowsIllegalArgumentExceptionForNullSymmetricKey.
// Tests_SRS_AUTHENTICATION_MECHANISM_34_012: [This constructor shall throw an IllegalArgumentException if the provided symmetricKey is null.]
@Test(expected = IllegalArgumentException.class)
public void constructorThrowsIllegalArgumentExceptionForNullSymmetricKey() {
// arrange
SymmetricKey key = null;
// act
new AuthenticationMechanism(key);
}
use of com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism in project azure-iot-sdk-java by Azure.
the class AuthenticationMechanismTest method testSelfSignedAuthenticationTypeConstructor.
// Tests_SRS_AUTHENTICATION_MECHANISM_34_023: [If the provided authentication type is self signed, a thumbprint will be generated, but no symmetric key will be generated.]
@Test
public void testSelfSignedAuthenticationTypeConstructor() {
// act
AuthenticationMechanism selfSignedAuth = new AuthenticationMechanism(AuthenticationType.SELF_SIGNED);
// assert
assertNotNull(selfSignedAuth.getPrimaryThumbprint());
assertNotNull(selfSignedAuth.getSecondaryThumbprint());
assertNull(selfSignedAuth.getSymmetricKey());
}
use of com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism in project azure-iot-sdk-java by Azure.
the class AuthenticationMechanismTest method testThumbprintConstructor.
// Tests_SRS_AUTHENTICATION_MECHANISM_34_004: [This constructor shall save the provided thumbprint to the returned instance.]
@Test
public void testThumbprintConstructor() {
// act
AuthenticationMechanism authenticationSelfSigned = new AuthenticationMechanism(expectedPrimaryThumbprint, expectedSecondaryThumbprint);
// assert
assertEquals(expectedPrimaryThumbprint, authenticationSelfSigned.getPrimaryThumbprint());
assertEquals(expectedSecondaryThumbprint, authenticationSelfSigned.getSecondaryThumbprint());
}
use of com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism in project azure-iot-sdk-java by Azure.
the class ExportImportTests method createListofDevices.
private static List<ExportImportDevice> createListofDevices() {
// Creating the list of devices to be created, then deleted
Integer numberOfDevices = 10;
List<ExportImportDevice> devicesForImport = new ArrayList<>(numberOfDevices);
for (int i = 0; i < numberOfDevices; i++) {
String deviceId = "java-bulk-test-" + UUID.randomUUID().toString();
Device device = Device.createFromId(deviceId, null, null);
AuthenticationMechanism authentication = new AuthenticationMechanism(device.getSymmetricKey());
ExportImportDevice deviceToAdd = new ExportImportDevice();
deviceToAdd.setId(deviceId);
deviceToAdd.setAuthentication(authentication);
deviceToAdd.setStatus(DeviceStatus.Enabled);
TwinCollection tags = new TwinCollection();
tags.putFinal("test01", "firstvalue");
deviceToAdd.setTags(tags);
devicesForImport.add(deviceToAdd);
}
return devicesForImport;
}
use of com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism 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);
}
Aggregations