Search in sources :

Example 26 with AuthenticationMechanism

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

the class AuthenticationMechanismTest method secondaryThumbprintPropertyWorks.

// Tests_SRS_AUTHENTICATION_MECHANISM_34_016: [This function shall set this object's secondary thumbprint to the provided value.]
// Tests_SRS_AUTHENTICATION_MECHANISM_34_021: [This function shall return the secondary thumbprint of this object.]
// Tests_SRS_AUTHENTICATION_MECHANISM_34_018: [This function shall set this object's authentication type to SelfSigned.]
@Test
public void secondaryThumbprintPropertyWorks() {
    // arrange
    AuthenticationMechanism actualAuthentication = new AuthenticationMechanism(AuthenticationType.CERTIFICATE_AUTHORITY);
    // act
    actualAuthentication.setSecondaryThumbprint(expectedSecondaryThumbprint);
    // assert
    assertEquals(expectedSecondaryThumbprint, actualAuthentication.getSecondaryThumbprint());
    assertEquals(AuthenticationType.SELF_SIGNED, actualAuthentication.getAuthenticationType());
}
Also used : AuthenticationMechanism(com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism) Test(org.junit.Test)

Example 27 with AuthenticationMechanism

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

the class AuthenticationMechanismTest method primaryThumbprintPropertiesWorks.

// Tests_SRS_AUTHENTICATION_MECHANISM_34_015: [This function shall set this object's primary thumbprint to the provided value.]
// Tests_SRS_AUTHENTICATION_MECHANISM_34_020: [This function shall return the primary thumbprint of this object.]
// Tests_SRS_AUTHENTICATION_MECHANISM_34_017: [This function shall set this object's authentication type to SelfSigned.]
@Test
public void primaryThumbprintPropertiesWorks() {
    // arrange
    AuthenticationMechanism actualAuthentication = new AuthenticationMechanism(AuthenticationType.CERTIFICATE_AUTHORITY);
    // act
    actualAuthentication.setPrimaryThumbprint(expectedPrimaryThumbprint);
    actualAuthentication.setSecondaryThumbprint(expectedSecondaryThumbprint);
    // assert
    assertEquals(expectedSecondaryThumbprint, actualAuthentication.getSecondaryThumbprint());
    assertEquals(expectedPrimaryThumbprint, actualAuthentication.getPrimaryThumbprint());
    assertEquals(AuthenticationType.SELF_SIGNED, actualAuthentication.getAuthenticationType());
}
Also used : AuthenticationMechanism(com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism) Test(org.junit.Test)

Example 28 with AuthenticationMechanism

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

the class AuthenticationMechanismTest method testSASAuthenticationTypeConstructor.

// Tests_SRS_AUTHENTICATION_MECHANISM_34_024: [If the provided authentication type is SAS, a symmetric key will be generated, but no thumbprint will be generated.]
@Test
public void testSASAuthenticationTypeConstructor() {
    // act
    AuthenticationMechanism sasAuth = new AuthenticationMechanism(AuthenticationType.SAS);
    // assert
    assertNotNull(sasAuth.getSymmetricKey());
    assertNull(sasAuth.getPrimaryThumbprint());
    assertNull(sasAuth.getSecondaryThumbprint());
}
Also used : AuthenticationMechanism(com.microsoft.azure.sdk.iot.service.auth.AuthenticationMechanism) Test(org.junit.Test)

Example 29 with AuthenticationMechanism

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

the class AuthenticationMechanismTest method testCertificateAuthorityAuthenticationTypeConstructor.

// Tests_SRS_AUTHENTICATION_MECHANISM_34_022: [If the provided authentication type is certificate authority signed, no thumbprint or symmetric key will be generated.]
@Test
public void testCertificateAuthorityAuthenticationTypeConstructor() {
    // act
    AuthenticationMechanism authenticationCASigned = new AuthenticationMechanism(AuthenticationType.CERTIFICATE_AUTHORITY);
    // assert
    assertNull(authenticationCASigned.getSymmetricKey());
    assertNull(authenticationCASigned.getPrimaryThumbprint());
    assertNull(authenticationCASigned.getSecondaryThumbprint());
    assertEquals(AuthenticationType.CERTIFICATE_AUTHORITY, authenticationCASigned.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