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 getRegistrationStatusThrowsOnNullSSLContext.
@Test(expected = ProvisioningDeviceClientException.class)
public void getRegistrationStatusThrowsOnNullSSLContext() throws ProvisioningDeviceClientException {
// arrange
ContractAPIHttp contractAPIHttp = createContractClass();
new NonStrictExpectations() {
{
mockedRequestData.getOperationId();
result = TEST_OPERATION_ID;
mockedRequestData.getRegistrationId();
result = TEST_REGISTRATION_ID;
mockedRequestData.getSslContext();
result = null;
mockedRequestData.getSasToken();
result = null;
}
};
// act
contractAPIHttp.getRegistrationStatus(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 prepareRequestThrowsOnNullMethod.
@Test(expected = IllegalArgumentException.class)
public void prepareRequestThrowsOnNullMethod() throws Exception {
// arrange
final byte[] expectedPayload = "TestBytes".getBytes(StandardCharsets.UTF_8);
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, null, 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 requestNonceWithDPSTPMThrowsOnNullEk.
@Test(expected = ProvisioningDeviceClientException.class)
public void requestNonceWithDPSTPMThrowsOnNullEk() throws ProvisioningDeviceClientException {
// arrange
final byte[] expectedPayload = "testByte".getBytes(StandardCharsets.UTF_8);
ContractAPIHttp contractAPIHttp = createContractClass();
new NonStrictExpectations() {
{
mockedRequestData.getRegistrationId();
result = TEST_REGISTRATION_ID;
mockedRequestData.getEndorsementKey();
result = null;
mockedRequestData.getStorageRootKey();
result = TEST_SRK;
mockedRequestData.getSslContext();
result = mockedSslContext;
}
};
// act
contractAPIHttp.requestNonceForTPM(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 requestNonceWithDPSTPMThrowsOnNullSRk.
@Test(expected = ProvisioningDeviceClientException.class)
public void requestNonceWithDPSTPMThrowsOnNullSRk() throws ProvisioningDeviceClientException {
// arrange
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 = null;
mockedRequestData.getSslContext();
result = mockedSslContext;
}
};
// act
contractAPIHttp.requestNonceForTPM(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 authenticateWithDPSForTPMSucceeds.
// SRS_ContractAPIHttp_25_026: [ This method shall build the required Json input using parser. ]
@Test
public void authenticateWithDPSForTPMSucceeds() throws IOException, ProvisioningDeviceClientException {
// arrange
final byte[] expectedPayload = "testByte".getBytes(StandardCharsets.UTF_8);
ContractAPIHttp contractAPIHttp = createContractClass();
prepareRequestExpectations();
new NonStrictExpectations() {
{
mockedHttpRequest.send();
result = mockedHttpResponse;
mockedRequestData.getEndorsementKey();
result = TEST_EK;
mockedRequestData.getStorageRootKey();
result = TEST_SRK;
mockedRequestData.getRegistrationId();
result = TEST_REGISTRATION_ID;
mockedRequestData.getSslContext();
result = mockedSslContext;
mockedRequestData.getSasToken();
result = null;
Deencapsulation.newInstance(DeviceRegistrationParser.class, new Class[] { String.class, String.class, String.class, String.class }, anyString, anyString, anyString, anyString);
result = mockedDeviceRegistrationParser;
mockedDeviceRegistrationParser.toJson();
result = "some json";
}
};
// act
contractAPIHttp.authenticateWithProvisioningService(mockedRequestData, mockedResponseCallback, null);
// assert
prepareRequestVerifications(HttpMethod.PUT, 0);
new Verifications() {
{
new UrlPathBuilder(TEST_HOST_NAME, TEST_SCOPE_ID, ProvisioningDeviceClientTransportProtocol.HTTPS);
times = 1;
mockedUrlPathBuilder.generateRegisterUrl(TEST_REGISTRATION_ID);
times = 1;
mockedHttpRequest.setSSLContext(mockedSslContext);
times = 1;
mockedResponseCallback.run((ResponseData) any, null);
times = 1;
}
};
}
Aggregations