Search in sources :

Example 11 with AuthenticationMechanism

use of com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism in project azure-iot-sdk-java by Azure.

the class AuthenticationMechanismTest method testGetAuthenticationType.

// Tests_SRS_AUTHENTICATION_MECHANISM_34_009: [This function shall return the AuthenticationType of this object.]
@Test
public void testGetAuthenticationType() {
    // arrange
    AuthenticationMechanism authenticationWithSymmetricKey = new AuthenticationMechanism(expectedSymmetricKey);
    AuthenticationMechanism authenticationCASigned = new AuthenticationMechanism(AuthenticationType.CERTIFICATE_AUTHORITY);
    AuthenticationMechanism authenticationSelfSigned = new AuthenticationMechanism(expectedPrimaryThumbprint, expectedSecondaryThumbprint);
    // assert
    assertEquals(AuthenticationType.SAS, authenticationWithSymmetricKey.getAuthenticationType());
    assertEquals(AuthenticationType.CERTIFICATE_AUTHORITY, authenticationCASigned.getAuthenticationType());
    assertEquals(AuthenticationType.SELF_SIGNED, authenticationSelfSigned.getAuthenticationType());
}
Also used : AuthenticationMechanism(com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism) Test(org.junit.Test)

Example 12 with AuthenticationMechanism

use of com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism in project azure-iot-sdk-java by Azure.

the class AuthenticationMechanismTest method setAuthenticationTypeThrowsForNullType.

// Tests_SRS_AUTHENTICATION_MECHANISM_34_014: [If the provided type is null, this function shall throw an IllegalArgumentException.]
@Test(expected = IllegalArgumentException.class)
public void setAuthenticationTypeThrowsForNullType() {
    // arrange
    AuthenticationMechanism authentication = new AuthenticationMechanism(expectedSymmetricKey);
    // act
    authentication.setAuthenticationType(null);
}
Also used : AuthenticationMechanism(com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism) Test(org.junit.Test)

Example 13 with AuthenticationMechanism

use of com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism in project azure-iot-sdk-java by Azure.

the class AuthenticationMechanismTest method testSymmetricKeyConstructor.

// Tests_SRS_AUTHENTICATION_MECHANISM_34_003: [This constructor shall save the provided symmetricKey to the returned instance.]
@Test
public void testSymmetricKeyConstructor() {
    // act
    AuthenticationMechanism authenticationWithSymmetricKey = new AuthenticationMechanism(expectedSymmetricKey);
    // assert
    assertEquals(expectedSymmetricKey, authenticationWithSymmetricKey.getSymmetricKey());
}
Also used : AuthenticationMechanism(com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism) Test(org.junit.Test)

Example 14 with AuthenticationMechanism

use of com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism in project azure-iot-sdk-java by Azure.

the class AuthenticationMechanismTest method setSymmetricKeyThrowsForNullSymmetricKey.

// Tests_SRS_AUTHENTICATION_MECHANISM_34_013: [If the provided symmetricKey is null, this function shall throw an IllegalArgumentException.]
@Test(expected = IllegalArgumentException.class)
public void setSymmetricKeyThrowsForNullSymmetricKey() {
    // arrange
    AuthenticationMechanism authentication = new AuthenticationMechanism(expectedSymmetricKey);
    // act
    authentication.setSymmetricKey(null);
}
Also used : AuthenticationMechanism(com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism) Test(org.junit.Test)

Example 15 with AuthenticationMechanism

use of com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism in project azure-iot-sdk-java by Azure.

the class AuthenticationMechanismTest method authenticationTypePropertyWorks.

// Tests_SRS_AUTHENTICATION_MECHANISM_34_009: [This function shall return the AuthenticationType of this object.]
// Tests_SRS_AUTHENTICATION_MECHANISM_34_011: [This function shall set this object's authentication type to the provided value.]
@Test
public void authenticationTypePropertyWorks() {
    // arrange
    AuthenticationMechanism actualAuthentication = new AuthenticationMechanism(AuthenticationType.CERTIFICATE_AUTHORITY);
    // act
    actualAuthentication.setAuthenticationType(AuthenticationType.CERTIFICATE_AUTHORITY);
    // assert
    assertEquals(AuthenticationType.CERTIFICATE_AUTHORITY, actualAuthentication.getAuthenticationType());
}
Also used : AuthenticationMechanism(com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism) Test(org.junit.Test)

Aggregations

AuthenticationMechanism (com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism)29 Test (org.junit.Test)25 ExportImportDevice (com.microsoft.azure.sdk.iot.service.ExportImportDevice)8 SymmetricKey (com.microsoft.azure.sdk.iot.service.auth.SymmetricKey)5 BaseDevice (com.microsoft.azure.sdk.iot.service.BaseDevice)4 X509Thumbprint (com.microsoft.azure.sdk.iot.service.auth.X509Thumbprint)3 TwinCollection (com.microsoft.azure.sdk.iot.deps.twin.TwinCollection)1 Device (com.microsoft.azure.sdk.iot.service.Device)1 DeviceStatus (com.microsoft.azure.sdk.iot.service.DeviceStatus)1 ImportMode (com.microsoft.azure.sdk.iot.service.ImportMode)1 CloudStorageAccount (com.microsoft.azure.storage.CloudStorageAccount)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1