use of com.microsoft.azure.sdk.iot.service.auth.SymmetricKey in project azure-iot-sdk-java by Azure.
the class SymmetricKeyTest method setSecondaryKey_length_good_case_max.
// 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]
@Test
public void setSecondaryKey_length_good_case_max() {
// Arrange
String key = "0123456789012345678901234567890123456789012345678901234567890123";
SymmetricKey symmetricKey = new SymmetricKey();
// Act
symmetricKey.setSecondaryKey(key);
// Assert
assertEquals(key, Deencapsulation.getField(symmetricKey, "secondaryKey"));
}
use of com.microsoft.azure.sdk.iot.service.auth.SymmetricKey in project azure-iot-sdk-java by Azure.
the class SymmetricKeyTest method setSecondaryKey_length_good_case_min.
// 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]
@Test
public void setSecondaryKey_length_good_case_min() {
// Arrange
String key = "0123456789012345";
SymmetricKey symmetricKey = new SymmetricKey();
// Act
symmetricKey.setSecondaryKey(key);
// Assert
assertEquals(key, Deencapsulation.getField(symmetricKey, "secondaryKey"));
}
use of com.microsoft.azure.sdk.iot.service.auth.SymmetricKey in project azure-iot-sdk-java by Azure.
the class DeviceDeserializer method deserialize.
@Override
public Device deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
// CODES_SRS_SERVICE_SDK_JAVA_DEVICE_DESERIALIZER_15_001: The function shall deserialize the JSON into a Device object
JsonElement deviceElement = jsonElement.getAsJsonObject();
device = gson.fromJson(deviceElement, Device.class);
JsonElement authenticationElement = jsonElement.getAsJsonObject().get("authentication");
JsonElement symmetricKeyElement = authenticationElement.getAsJsonObject().get("symmetricKey");
SymmetricKey symmetricKey = gson.fromJson(symmetricKeyElement, SymmetricKey.class);
device.symmetricKey = symmetricKey;
return device;
}
use of com.microsoft.azure.sdk.iot.service.auth.SymmetricKey in project azure-iot-sdk-java by Azure.
the class SymmetricKeyTest method setPrimaryKey_length_less_than_16.
// 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_less_than_16() {
// Arrange
String key = "012345678901234";
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 setPrimaryKey_length_good_case_min.
// 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_min() {
// Arrange
String key = "0123456789012345";
SymmetricKey symmetricKey = new SymmetricKey();
// Act
symmetricKey.setPrimaryKey(key);
// Assert
assertEquals(key, Deencapsulation.getField(symmetricKey, "primaryKey"));
}
Aggregations