Search in sources :

Example 6 with SymmetricKey

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"));
}
Also used : SymmetricKey(com.microsoft.azure.sdk.iot.service.auth.SymmetricKey) Test(org.junit.Test)

Example 7 with SymmetricKey

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"));
}
Also used : SymmetricKey(com.microsoft.azure.sdk.iot.service.auth.SymmetricKey) Test(org.junit.Test)

Example 8 with SymmetricKey

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;
}
Also used : SymmetricKey(com.microsoft.azure.sdk.iot.service.auth.SymmetricKey)

Example 9 with SymmetricKey

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);
}
Also used : SymmetricKey(com.microsoft.azure.sdk.iot.service.auth.SymmetricKey) Test(org.junit.Test)

Example 10 with SymmetricKey

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"));
}
Also used : SymmetricKey(com.microsoft.azure.sdk.iot.service.auth.SymmetricKey) Test(org.junit.Test)

Aggregations

SymmetricKey (com.microsoft.azure.sdk.iot.service.auth.SymmetricKey)11 Test (org.junit.Test)10 Device (com.microsoft.azure.sdk.iot.service.Device)2 DeviceStatus (com.microsoft.azure.sdk.iot.service.DeviceStatus)1 NonStrictExpectations (mockit.NonStrictExpectations)1