use of com.microsoft.azure.sdk.iot.service.auth.SymmetricKey in project azure-iot-sdk-java by Azure.
the class DeviceTest method constructor_create_symmetrickey.
// Tests_SRS_SERVICE_SDK_JAVA_DEVICE_12_005: [If the input symmetric key is empty, the constructor shall create
// a new SymmetricKey instance using AES encryption and store it into a member variable]
@Test
public void constructor_create_symmetrickey() throws NoSuchAlgorithmException {
// Arrange
String encryptionMethod = "AES";
String deviceId = "xxx-device";
new NonStrictExpectations() {
{
SymmetricKey symmetricKey = new SymmetricKey();
KeyGenerator.getInstance(encryptionMethod);
}
};
// Act
Device device = Deencapsulation.newInstance(Device.class, deviceId, DeviceStatus.class, SymmetricKey.class);
// Assert
assertNotEquals(device.getSymmetricKey(), null);
}
use of com.microsoft.azure.sdk.iot.service.auth.SymmetricKey in project azure-iot-sdk-java by Azure.
the class DeviceTest method constructor_sets_status_and_symmetrickey.
// Tests_SRS_SERVICE_SDK_JAVA_DEVICE_15_007: [The constructor shall store
// the input device status and symmetric key into a member variable]
@Test
public void constructor_sets_status_and_symmetrickey() throws NoSuchAlgorithmException {
// Arrange
String deviceId = "xxx-device";
DeviceStatus expectedDeviceStatus = DeviceStatus.Disabled;
SymmetricKey expectedSymmetricKey = new SymmetricKey();
// Act
Device device = Deencapsulation.newInstance(Device.class, deviceId, expectedDeviceStatus, expectedSymmetricKey);
// Assert
assertEquals(expectedDeviceStatus, device.getStatus());
assertEquals(expectedSymmetricKey, device.getSymmetricKey());
}
use of com.microsoft.azure.sdk.iot.service.auth.SymmetricKey in project azure-iot-sdk-java by Azure.
the class SymmetricKeyTest method setPrimaryKey_length_good_case_max.
// Tests_SRS_SERVICE_SDK_JAVA_SYMMETRICKEY_12_002: [The function shall set the private primaryKey member to the given value if the length validation passed]
@Test
public void setPrimaryKey_length_good_case_max() {
// Arrange
String key = "0123456789012345678901234567890123456789012345678901234567890123";
SymmetricKey symmetricKey = new SymmetricKey();
// Act
symmetricKey.setPrimaryKey(key);
// Assert
assertEquals(key, Deencapsulation.getField(symmetricKey, "primaryKey"));
}
use of com.microsoft.azure.sdk.iot.service.auth.SymmetricKey in project azure-iot-sdk-java by Azure.
the class SymmetricKeyTest method setPrimaryKey_length_greater_than_64.
// Tests_SRS_SERVICE_SDK_JAVA_SYMMETRICKEY_12_001: [The function shall throw IllegalArgumentException if the length of the key less than 16 or greater than 64]
// Assert
@Test(expected = IllegalArgumentException.class)
public void setPrimaryKey_length_greater_than_64() {
// Arrange
String key = "01234567890123456789012345678901234567890123456789012345678901234";
SymmetricKey symmetricKey = new SymmetricKey();
// Act
symmetricKey.setPrimaryKey(key);
}
use of com.microsoft.azure.sdk.iot.service.auth.SymmetricKey in project azure-iot-sdk-java by Azure.
the class SymmetricKeyTest method setSecondaryKey_length_less_than_16.
// Tests_SRS_SERVICE_SDK_JAVA_SYMMETRICKEY_12_003: [The function shall throw IllegalArgumentException if the length of the key less than 16 or greater than 64]
// Assert
@Test(expected = IllegalArgumentException.class)
public void setSecondaryKey_length_less_than_16() {
// Arrange
String key = "012345678901234";
SymmetricKey symmetricKey = new SymmetricKey();
// Act
symmetricKey.setSecondaryKey(key);
}
Aggregations