use of com.microsoft.azure.sdk.iot.device.IotHubSSLContext in project azure-iot-sdk-java by Azure.
the class IotHubSSLContextTest method constructorWithParamsCreatesSSLContext.
//Tests_SRS_IOTHUBSSLCONTEXT_25_010: [**The constructor shall create a certificate with 'cert' if it were a not a path by calling setValidCert.**]**
@Test
public void constructorWithParamsCreatesSSLContext() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException, CertificateException {
//arrange
testCollection.add(mockedCertificate);
generateSSLContextExpectations();
//act
IotHubSSLContext testContext = Deencapsulation.newInstance(IotHubSSLContext.class, "TestCertString", false);
//assert
generateSSLContextVerifications();
new Verifications() {
{
Deencapsulation.invoke(mockedDefaultCert, "setValidCert", anyString);
times = 1;
}
};
assertNotNull(Deencapsulation.invoke(testContext, "getIotHubSSlContext"));
testCollection.remove(mockedCertificate);
}
use of com.microsoft.azure.sdk.iot.device.IotHubSSLContext in project azure-iot-sdk-java by Azure.
the class IotHubSSLContextTest method constructorCreatesSSLContext.
//Tests_SRS_IOTHUBSSLCONTEXT_25_001: [**The constructor shall create a default certificate to be used with IotHub.**]**
//Tests_SRS_IOTHUBSSLCONTEXT_25_002: [**The constructor shall create default SSL context for TLSv1.2.**]**
//Tests_SRS_IOTHUBSSLCONTEXT_25_003: [**The constructor shall create default TrustManagerFactory with the default algorithm.**]**
//Tests_SRS_IOTHUBSSLCONTEXT_25_004: [**The constructor shall create default KeyStore instance with the default type and initialize it.**]**
//Tests_SRS_IOTHUBSSLCONTEXT_25_005: [**The constructor shall set the above created certificate into a keystore.**]**
//Tests_SRS_IOTHUBSSLCONTEXT_25_006: [**The constructor shall initialize TrustManagerFactory with the above initialized keystore.**]**
//Tests_SRS_IOTHUBSSLCONTEXT_25_007: [**The constructor shall initialize SSL context with the above initialized TrustManagerFactory and a new secure random.**]**
@Test
public void constructorCreatesSSLContext() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException, CertificateException {
//arrange
testCollection.add(mockedCertificate);
generateSSLContextExpectations();
//act
IotHubSSLContext testContext = Deencapsulation.newInstance(IotHubSSLContext.class);
//assert
generateSSLContextVerifications();
assertNotNull(Deencapsulation.invoke(testContext, "getIotHubSSlContext"));
testCollection.remove(mockedCertificate);
}
use of com.microsoft.azure.sdk.iot.device.IotHubSSLContext in project azure-iot-sdk-java by Azure.
the class IotHubSSLContextTest method constructorWithParamsAsPathCreatesSSLContext.
//Tests_SRS_IOTHUBSSLCONTEXT_25_009: [**The constructor shall create a certificate to be used with IotHub with cert only if it were a path by calling setValidCertPath**]**
@Test
public void constructorWithParamsAsPathCreatesSSLContext() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException, CertificateException {
//arrange
testCollection.add(mockedCertificate);
generateSSLContextExpectations();
//act
IotHubSSLContext testContext = Deencapsulation.newInstance(IotHubSSLContext.class, "Test/Cert/Path", true);
//assert
generateSSLContextVerifications();
new Verifications() {
{
Deencapsulation.invoke(mockedDefaultCert, "setValidCertPath", anyString);
times = 1;
}
};
assertNotNull(Deencapsulation.invoke(testContext, "getIotHubSSlContext"));
testCollection.remove(mockedCertificate);
}
use of com.microsoft.azure.sdk.iot.device.IotHubSSLContext in project azure-iot-sdk-java by Azure.
the class DeviceClientConfigTest method setIotHubSSLContextSets.
//Tests_SRS_DEVICECLIENTCONFIG_25_031: [**The function shall set IotHub SSL Context**] **
@Test
public void setIotHubSSLContextSets(@Mocked final IotHubSSLContext mockedContext) throws URISyntaxException {
final String iotHubHostname = "test.iothubhostname";
final String deviceId = "test-deviceid";
final String deviceKey = "test-devicekey";
final String sharedAccessToken = null;
final String cert = "ValidCertString";
final IotHubConnectionString iotHubConnectionString = Deencapsulation.newInstance(IotHubConnectionString.class, new Class[] { String.class, String.class, String.class, String.class }, iotHubHostname, deviceId, deviceKey, sharedAccessToken);
DeviceClientConfig config = new DeviceClientConfig(iotHubConnectionString);
config.setIotHubSSLContext(mockedContext);
IotHubSSLContext testContext = config.getIotHubSSLContext();
assertNotNull(testContext);
assertEquals(testContext, mockedContext);
}
use of com.microsoft.azure.sdk.iot.device.IotHubSSLContext in project azure-iot-sdk-java by Azure.
the class IotHubSSLContextTest method getterGetsContext.
//Tests_SRS_IOTHUBSSLCONTEXT_25_017: [*This method shall return the value of sslContext.**]**
@Test
public void getterGetsContext() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException, CertificateException {
//arrange
testCollection.add(mockedCertificate);
generateSSLContextExpectations();
IotHubSSLContext testContext = Deencapsulation.newInstance(IotHubSSLContext.class, "Test/Cert/Path", true);
//act
SSLContext testSSLContext = Deencapsulation.invoke(testContext, "getIotHubSSlContext");
//assert
generateSSLContextVerifications();
new Verifications() {
{
Deencapsulation.invoke(mockedDefaultCert, "setValidCertPath", anyString);
times = 1;
}
};
assertNotNull(testSSLContext);
testCollection.remove(mockedCertificate);
}
Aggregations