use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.http.ContractAPIHttp in project azure-iot-sdk-java by Azure.
the class ContractAPIHttpTest method constructorThrowsOnEmptyHostName.
@Test(expected = ProvisioningDeviceClientException.class)
public void constructorThrowsOnEmptyHostName() throws ProvisioningDeviceClientException {
// arrange
new NonStrictExpectations() {
{
mockedProvisioningDeviceClientConfig.getIdScope();
result = TEST_SCOPE_ID;
mockedProvisioningDeviceClientConfig.getProvisioningServiceGlobalEndpoint();
result = "";
}
};
// act
ContractAPIHttp contractAPIHttp = new ContractAPIHttp(mockedProvisioningDeviceClientConfig);
// assert
}
use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.http.ContractAPIHttp in project azure-iot-sdk-java by Azure.
the class ContractAPIHttpTest method constructorThrowsOnNullScopeID.
// SRS_ContractAPIHttp_25_002: [The constructor shall throw ProvisioningDeviceClientException if either idScope and hostName are null or empty.]
@Test(expected = ProvisioningDeviceClientException.class)
public void constructorThrowsOnNullScopeID() throws ProvisioningDeviceClientException {
// arrange
new NonStrictExpectations() {
{
mockedProvisioningDeviceClientConfig.getIdScope();
result = null;
}
};
// act
ContractAPIHttp contractAPIHttp = new ContractAPIHttp(mockedProvisioningDeviceClientConfig);
// assert
}
use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.http.ContractAPIHttp in project azure-iot-sdk-java by Azure.
the class ContractAPIHttpTest method authenticateWithDPSThrowsOnNullRegistrationId.
// SRS_ContractAPIHttp_25_011: [If either registrationId, sslcontext or restResponseCallback is null or if registrationId is empty then this method shall throw ProvisioningDeviceClientException.]
@Test(expected = ProvisioningDeviceClientException.class)
public void authenticateWithDPSThrowsOnNullRegistrationId() throws ProvisioningDeviceClientException {
// arrange
final byte[] expectedPayload = "testByte".getBytes(StandardCharsets.UTF_8);
ContractAPIHttp contractAPIHttp = createContractClass();
new NonStrictExpectations() {
{
mockedRequestData.getRegistrationId();
result = null;
mockedRequestData.getSslContext();
result = mockedSslContext;
mockedRequestData.getSasToken();
result = null;
}
};
// act
contractAPIHttp.authenticateWithProvisioningService(mockedRequestData, mockedResponseCallback, null);
}
use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.http.ContractAPIHttp in project azure-iot-sdk-java by Azure.
the class ContractAPIHttpTest method prepareRequestThrowsOnNullPayload.
@Test(expected = IllegalArgumentException.class)
public void prepareRequestThrowsOnNullPayload() throws Exception {
// arrange
final byte[] expectedPayload = null;
final String expectedUserAgentValue = "TestUserAgent";
ContractAPIHttp contractAPIHttp = createContractClass();
// act
Deencapsulation.invoke(contractAPIHttp, "prepareRequest", new Class[] { URL.class, HttpMethod.class, byte[].class, Integer.class, Map.class, String.class }, mockedUrl, HttpMethod.PUT, expectedPayload, 0, null, expectedUserAgentValue);
// assert
}
use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.http.ContractAPIHttp in project azure-iot-sdk-java by Azure.
the class ContractAPIHttpTest method requestNonceWithDPSTPMThrowsTransportExceptionIfAnyOfTheTransportCallsFails.
@Test(expected = ProvisioningDeviceTransportException.class)
public void requestNonceWithDPSTPMThrowsTransportExceptionIfAnyOfTheTransportCallsFails() throws IOException, ProvisioningDeviceClientException {
final byte[] expectedPayload = "testByte".getBytes(StandardCharsets.UTF_8);
ContractAPIHttp contractAPIHttp = createContractClass();
new NonStrictExpectations() {
{
mockedRequestData.getRegistrationId();
result = TEST_REGISTRATION_ID;
mockedRequestData.getEndorsementKey();
result = TEST_EK;
mockedRequestData.getStorageRootKey();
result = TEST_SRK;
mockedRequestData.getSslContext();
result = mockedSslContext;
new UrlPathBuilder(TEST_HOST_NAME, TEST_SCOPE_ID, ProvisioningDeviceClientTransportProtocol.HTTPS);
result = new IOException("test IOException");
}
};
// act
try {
contractAPIHttp.requestNonceForTPM(mockedRequestData, mockedResponseCallback, null);
} finally {
// assert
new Verifications() {
{
mockedResponseCallback.run((ResponseData) any, any);
times = 0;
}
};
}
}
Aggregations