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());
}
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);
}
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());
}
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);
}
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());
}
Aggregations