Search in sources :

Example 6 with SymmetricKeyParser

use of com.microsoft.azure.sdk.iot.deps.serializer.SymmetricKeyParser in project azure-iot-sdk-java by Azure.

the class SymmetricKeyParserTest method testConstructorWithKeys.

// Tests_SRS_SymmetricKeyParser_34_008: [This constructor shall create and return an instance of a SymmetricKeyParser object that holds the provided primary and secondary keys.]
@Test
public void testConstructorWithKeys() {
    // act
    SymmetricKeyParser parser = new SymmetricKeyParser(TEST_KEY1, TEST_KEY2);
    // assert
    String actualPrimaryKey = Deencapsulation.getField(parser, "primaryKey");
    String actualSecondaryKey = Deencapsulation.getField(parser, "secondaryKey");
    assertEquals(TEST_KEY1, actualPrimaryKey);
    assertEquals(TEST_KEY2, actualSecondaryKey);
}
Also used : SymmetricKeyParser(com.microsoft.azure.sdk.iot.deps.serializer.SymmetricKeyParser) Test(org.junit.Test)

Example 7 with SymmetricKeyParser

use of com.microsoft.azure.sdk.iot.deps.serializer.SymmetricKeyParser in project azure-iot-sdk-java by Azure.

the class SymmetricKeyParserTest method testConstructorWithJson.

// Tests_SRS_SymmetricKeyParser_34_009: [This constructor shall create and return an instance of a SymmetricKeyParser object based off the provided json.]
@Test
public void testConstructorWithJson() {
    // arrange
    String json = "{\"primaryKey\":\"" + TEST_KEY1 + "\",\"secondaryKey\":\"" + TEST_KEY2 + "\"}";
    // act
    SymmetricKeyParser parser = new SymmetricKeyParser(json);
    // assert
    assertEquals(TEST_KEY1, parser.getPrimaryKeyFinal());
    assertEquals(TEST_KEY2, parser.getSecondaryKeyFinal());
}
Also used : SymmetricKeyParser(com.microsoft.azure.sdk.iot.deps.serializer.SymmetricKeyParser) Test(org.junit.Test)

Example 8 with SymmetricKeyParser

use of com.microsoft.azure.sdk.iot.deps.serializer.SymmetricKeyParser in project azure-iot-sdk-java by Azure.

the class SymmetricKeyParserTest method setPrimaryKeyNullValueThrowsIllegalArgumentException.

// Tests_SRS_SymmetricKeyParser_34_002: [If the provided primaryKey value is null, an IllegalArgumentException shall be thrown.]
@Test(expected = IllegalArgumentException.class)
public void setPrimaryKeyNullValueThrowsIllegalArgumentException() {
    // arrange
    SymmetricKeyParser parser = new SymmetricKeyParser("", "");
    // act
    parser.setPrimaryKey(null);
}
Also used : SymmetricKeyParser(com.microsoft.azure.sdk.iot.deps.serializer.SymmetricKeyParser) Test(org.junit.Test)

Example 9 with SymmetricKeyParser

use of com.microsoft.azure.sdk.iot.deps.serializer.SymmetricKeyParser in project azure-iot-sdk-java by Azure.

the class AuthenticationParserTest method testSymmetricKeyParserProperty.

// Tests_SRS_AUTHENTICATION_PARSER_34_006: [This method shall return the value of this object's symmetricKey.]
// Tests_SRS_AUTHENTICATION_PARSER_34_007: [This method shall set the value of symmetricKey equal to the provided value.]
@Test
public void testSymmetricKeyParserProperty() {
    // arrange
    AuthenticationParser parser = new AuthenticationParser();
    SymmetricKeyParser symmetricKeyParser = new SymmetricKeyParser();
    symmetricKeyParser.setPrimaryKey("1234");
    symmetricKeyParser.setPrimaryKey("5678");
    // act
    parser.setSymmetricKey(symmetricKeyParser);
    // assert
    assertEquals(symmetricKeyParser, parser.getSymmetricKey());
}
Also used : AuthenticationParser(com.microsoft.azure.sdk.iot.deps.serializer.AuthenticationParser) SymmetricKeyParser(com.microsoft.azure.sdk.iot.deps.serializer.SymmetricKeyParser) Test(org.junit.Test)

Aggregations

SymmetricKeyParser (com.microsoft.azure.sdk.iot.deps.serializer.SymmetricKeyParser)9 Test (org.junit.Test)7 AuthenticationParser (com.microsoft.azure.sdk.iot.deps.serializer.AuthenticationParser)3 ExportImportDeviceParser (com.microsoft.azure.sdk.iot.deps.serializer.ExportImportDeviceParser)2 X509ThumbprintParser (com.microsoft.azure.sdk.iot.deps.serializer.X509ThumbprintParser)2 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 Device (com.microsoft.azure.sdk.iot.service.Device)1 Module (com.microsoft.azure.sdk.iot.service.Module)1