Search in sources :

Example 1 with IotHubX509HardwareAuthenticationProvider

use of com.microsoft.azure.sdk.iot.device.auth.IotHubX509HardwareAuthenticationProvider in project azure-iot-sdk-java by Azure.

the class IotHubX509HardwareIotHubAuthenticationProviderTest method getSSLContextThrowsIOExceptionIfExceptionEncountered.

// Tests_SRS_IOTHUBX509HARDWAREAUTHENTICATION_34_004: [If the security provider throws a SecurityProviderException while generating an SSLContext, this function shall throw an IOException.]
@Test(expected = IOException.class)
public void getSSLContextThrowsIOExceptionIfExceptionEncountered() throws SecurityProviderException, IOException, TransportException {
    // arrange
    IotHubAuthenticationProvider authentication = new IotHubX509HardwareAuthenticationProvider(hostname, gatewayHostname, deviceId, moduleId, mockSecurityProviderX509);
    new NonStrictExpectations() {

        {
            mockSecurityProviderX509.getSSLContext();
            result = new SecurityProviderException("");
        }
    };
    // act
    authentication.getSSLContext();
}
Also used : IotHubAuthenticationProvider(com.microsoft.azure.sdk.iot.device.auth.IotHubAuthenticationProvider) IotHubX509HardwareAuthenticationProvider(com.microsoft.azure.sdk.iot.device.auth.IotHubX509HardwareAuthenticationProvider) SecurityProviderException(com.microsoft.azure.sdk.iot.provisioning.security.exceptions.SecurityProviderException) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Example 2 with IotHubX509HardwareAuthenticationProvider

use of com.microsoft.azure.sdk.iot.device.auth.IotHubX509HardwareAuthenticationProvider in project azure-iot-sdk-java by Azure.

the class IotHubX509HardwareIotHubAuthenticationProviderTest method setPathToCertificateThrows.

// Tests_SRS_IOTHUBX509HARDWAREAUTHENTICATION_34_006: [This function shall throw an UnsupportedOperationException.]
@Test(expected = UnsupportedOperationException.class)
public void setPathToCertificateThrows() {
    // arrange
    IotHubAuthenticationProvider auth = new IotHubX509HardwareAuthenticationProvider(hostname, gatewayHostname, deviceId, moduleId, mockSecurityProviderX509);
    // act
    auth.setPathToIotHubTrustedCert("any string");
}
Also used : IotHubAuthenticationProvider(com.microsoft.azure.sdk.iot.device.auth.IotHubAuthenticationProvider) IotHubX509HardwareAuthenticationProvider(com.microsoft.azure.sdk.iot.device.auth.IotHubX509HardwareAuthenticationProvider) Test(org.junit.Test)

Example 3 with IotHubX509HardwareAuthenticationProvider

use of com.microsoft.azure.sdk.iot.device.auth.IotHubX509HardwareAuthenticationProvider in project azure-iot-sdk-java by Azure.

the class IotHubX509HardwareIotHubAuthenticationProviderTest method constructorSuccess.

// Tests_SRS_IOTHUBX509HARDWAREAUTHENTICATION_34_001: [This function shall save the provided security provider.]
@Test
public void constructorSuccess() {
    // act
    IotHubAuthenticationProvider authentication = new IotHubX509HardwareAuthenticationProvider(hostname, gatewayHostname, deviceId, moduleId, mockSecurityProviderX509);
    // assert
    SecurityProvider actualSecurityProvider = Deencapsulation.getField(authentication, "securityProviderX509");
    assertEquals(mockSecurityProviderX509, actualSecurityProvider);
}
Also used : IotHubAuthenticationProvider(com.microsoft.azure.sdk.iot.device.auth.IotHubAuthenticationProvider) IotHubX509HardwareAuthenticationProvider(com.microsoft.azure.sdk.iot.device.auth.IotHubX509HardwareAuthenticationProvider) SecurityProvider(com.microsoft.azure.sdk.iot.provisioning.security.SecurityProvider) Test(org.junit.Test)

Example 4 with IotHubX509HardwareAuthenticationProvider

use of com.microsoft.azure.sdk.iot.device.auth.IotHubX509HardwareAuthenticationProvider in project azure-iot-sdk-java by Azure.

the class IotHubX509HardwareIotHubAuthenticationProviderTest method cannotSetNewDefaultCertIfConstructedWithSSLContext.

// Tests_SRS_IOTHUBX509AUTHENTICATION_34_033: [If this object was created using a constructor that takes an SSLContext, this function shall throw an UnsupportedOperationException.]
@Test(expected = UnsupportedOperationException.class)
public void cannotSetNewDefaultCertIfConstructedWithSSLContext() {
    // arrange
    IotHubAuthenticationProvider authentication = new IotHubX509HardwareAuthenticationProvider(hostname, gatewayHostname, deviceId, moduleId, mockSecurityProviderX509);
    // act
    authentication.setIotHubTrustedCert("any string");
}
Also used : IotHubAuthenticationProvider(com.microsoft.azure.sdk.iot.device.auth.IotHubAuthenticationProvider) IotHubX509HardwareAuthenticationProvider(com.microsoft.azure.sdk.iot.device.auth.IotHubX509HardwareAuthenticationProvider) Test(org.junit.Test)

Example 5 with IotHubX509HardwareAuthenticationProvider

use of com.microsoft.azure.sdk.iot.device.auth.IotHubX509HardwareAuthenticationProvider in project azure-iot-sdk-java by Azure.

the class IotHubX509HardwareIotHubAuthenticationProviderTest method setCertificateThrows.

// Tests_SRS_IOTHUBX509HARDWAREAUTHENTICATION_34_007: [This function shall throw an UnsupportedOperationException.]
@Test(expected = UnsupportedOperationException.class)
public void setCertificateThrows() {
    // arrange
    IotHubAuthenticationProvider auth = new IotHubX509HardwareAuthenticationProvider(hostname, gatewayHostname, deviceId, moduleId, mockSecurityProviderX509);
    // act
    auth.setIotHubTrustedCert("any string");
}
Also used : IotHubAuthenticationProvider(com.microsoft.azure.sdk.iot.device.auth.IotHubAuthenticationProvider) IotHubX509HardwareAuthenticationProvider(com.microsoft.azure.sdk.iot.device.auth.IotHubX509HardwareAuthenticationProvider) Test(org.junit.Test)

Aggregations

IotHubAuthenticationProvider (com.microsoft.azure.sdk.iot.device.auth.IotHubAuthenticationProvider)7 IotHubX509HardwareAuthenticationProvider (com.microsoft.azure.sdk.iot.device.auth.IotHubX509HardwareAuthenticationProvider)7 Test (org.junit.Test)7 NonStrictExpectations (mockit.NonStrictExpectations)2 IotHubSSLContext (com.microsoft.azure.sdk.iot.deps.auth.IotHubSSLContext)1 SecurityProvider (com.microsoft.azure.sdk.iot.provisioning.security.SecurityProvider)1 SecurityProviderException (com.microsoft.azure.sdk.iot.provisioning.security.exceptions.SecurityProviderException)1 SSLContext (javax.net.ssl.SSLContext)1