use of com.microsoft.azure.sdk.iot.device.auth.IotHubX509HardwareAuthenticationProvider in project azure-iot-sdk-java by Azure.
the class IotHubX509HardwareIotHubAuthenticationProviderTest method getSSLContextSuccess.
// Tests_SRS_IOTHUBX509HARDWAREAUTHENTICATION_34_003: [If this object's ssl context has not been generated yet, this function shall generate it from the saved security provider.]
// Tests_SRS_IOTHUBX509HARDWAREAUTHENTICATION_34_005: [This function shall return the saved IotHubSSLContext.]
@Test
public void getSSLContextSuccess() throws SecurityProviderException, IOException, TransportException {
// arrange
IotHubAuthenticationProvider authentication = new IotHubX509HardwareAuthenticationProvider(hostname, gatewayHostname, deviceId, moduleId, mockSecurityProviderX509);
new NonStrictExpectations() {
{
Deencapsulation.invoke(mockIotHubSSLContext, "getSSLContext");
result = mockSSLContext;
mockSecurityProviderX509.getSSLContext();
result = mockSSLContext;
Deencapsulation.newInstance(IotHubSSLContext.class, new Class[] { SSLContext.class }, mockSSLContext);
result = mockIotHubSSLContext;
Deencapsulation.invoke(mockIotHubSSLContext, "getSSLContext");
result = mockSSLContext;
}
};
Deencapsulation.setField(authentication, "iotHubSSLContext", null);
// act
SSLContext actualSSLContext = authentication.getSSLContext();
assertEquals(mockSSLContext, actualSSLContext);
}
use of com.microsoft.azure.sdk.iot.device.auth.IotHubX509HardwareAuthenticationProvider in project azure-iot-sdk-java by Azure.
the class IotHubX509HardwareIotHubAuthenticationProviderTest method cannotSetNewDefaultCertPathIfConstructedWithSSLContext.
// Tests_SRS_IOTHUBX509AUTHENTICATION_34_032: [If this object was created using a constructor that takes an SSLContext, this function shall throw an UnsupportedOperationException.]
@Test(expected = UnsupportedOperationException.class)
public void cannotSetNewDefaultCertPathIfConstructedWithSSLContext() {
// arrange
IotHubAuthenticationProvider authentication = new IotHubX509HardwareAuthenticationProvider(hostname, gatewayHostname, deviceId, moduleId, mockSecurityProviderX509);
// act
authentication.setPathToIotHubTrustedCert("any path");
}
Aggregations