Search in sources :

Example 11 with UrlPathBuilder

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.UrlPathBuilder in project azure-iot-sdk-java by Azure.

the class UrlPathBuilderTest method generateSasTokenUrlThrowsOnNullRegID.

// SRS_UrlPathBuilder_25_005: [ This method shall throw IllegalArgumentException if the registration id is null or empty. ]
@Test(expected = IllegalArgumentException.class)
public void generateSasTokenUrlThrowsOnNullRegID() throws IOException {
    // arrange
    UrlPathBuilder urlPathBuilder = new UrlPathBuilder(TEST_HOST_NAME, TEST_SCOPE, ProvisioningDeviceClientTransportProtocol.HTTPS);
    // act
    urlPathBuilder.generateSasTokenUrl(null);
}
Also used : UrlPathBuilder(com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.UrlPathBuilder) Test(org.junit.Test)

Example 12 with UrlPathBuilder

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.UrlPathBuilder in project azure-iot-sdk-java by Azure.

the class UrlPathBuilderTest method generateSasTokenUrlThrowsOnEmptyRegID.

@Test(expected = IllegalArgumentException.class)
public void generateSasTokenUrlThrowsOnEmptyRegID() throws IOException {
    // arrange
    UrlPathBuilder urlPathBuilder = new UrlPathBuilder(TEST_HOST_NAME, TEST_SCOPE, ProvisioningDeviceClientTransportProtocol.HTTPS);
    // act
    urlPathBuilder.generateSasTokenUrl("");
}
Also used : UrlPathBuilder(com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.UrlPathBuilder) Test(org.junit.Test)

Example 13 with UrlPathBuilder

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.UrlPathBuilder in project azure-iot-sdk-java by Azure.

the class UrlPathBuilderTest method generateRegisterUrlHttpSucceeds.

// SRS_UrlPathBuilder_25_008: [ This method shall create a String using the following format: HTTP - https://<HostName>/<Scope>/registrations/<Registration ID>/register?api-version=<Service API Version> MQTT - TBD AMQP - TBD ]
@Test
public void generateRegisterUrlHttpSucceeds() throws IOException {
    // arrange
    // https://testHostName/testScope/registrations/testRegistrationId/register?api-version=2017-08-31-preview
    final String expectedUrl = "https://" + TEST_HOST_NAME + "/" + TEST_SCOPE + "/registrations/" + TEST_REGISTRATION_ID + "/register?api-version=" + SERVICE_API_VERSION;
    UrlPathBuilder urlPathBuilder = new UrlPathBuilder(TEST_HOST_NAME, TEST_SCOPE, ProvisioningDeviceClientTransportProtocol.HTTPS);
    // act
    String generateRequestUrl = urlPathBuilder.generateRegisterUrl(TEST_REGISTRATION_ID);
    // assert
    assertEquals(expectedUrl, generateRequestUrl);
}
Also used : UrlPathBuilder(com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.UrlPathBuilder) Test(org.junit.Test)

Example 14 with UrlPathBuilder

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.UrlPathBuilder in project azure-iot-sdk-java by Azure.

the class UrlPathBuilderTest method generateSasTokenUrlSucceeds.

// SRS_UrlPathBuilder_25_006: [ This method shall create a String using the following format after Url Encoding: <scopeid>/registrations/<registrationId> ]
@Test
public void generateSasTokenUrlSucceeds() throws IOException {
    // arrange
    // testScope/registrations/testRegistrationId
    final String expectedSasTokenUrl = TEST_SCOPE + "/registrations/" + TEST_REGISTRATION_ID;
    UrlPathBuilder urlPathBuilder = new UrlPathBuilder(TEST_HOST_NAME, TEST_SCOPE, ProvisioningDeviceClientTransportProtocol.HTTPS);
    // act
    String sastokenUrl = urlPathBuilder.generateSasTokenUrl(TEST_REGISTRATION_ID);
    // assert
    assertEquals(expectedSasTokenUrl, sastokenUrl);
}
Also used : UrlPathBuilder(com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.UrlPathBuilder) Test(org.junit.Test)

Example 15 with UrlPathBuilder

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.UrlPathBuilder in project azure-iot-sdk-java by Azure.

the class UrlPathBuilderTest method generateRequestUrlHttpThrowsOnEmptyOpID.

@Test(expected = IllegalArgumentException.class)
public void generateRequestUrlHttpThrowsOnEmptyOpID() throws IOException {
    // arrange
    UrlPathBuilder urlPathBuilder = new UrlPathBuilder(TEST_HOST_NAME, TEST_SCOPE, ProvisioningDeviceClientTransportProtocol.HTTPS);
    // act
    urlPathBuilder.generateRequestUrl(TEST_REGISTRATION_ID, "");
}
Also used : UrlPathBuilder(com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.UrlPathBuilder) Test(org.junit.Test)

Aggregations

UrlPathBuilder (com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.UrlPathBuilder)29 Test (org.junit.Test)25 ContractAPIHttp (com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.http.ContractAPIHttp)12 DeviceRegistrationParser (com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.DeviceRegistrationParser)7 IOException (java.io.IOException)6 HttpRequest (com.microsoft.azure.sdk.iot.deps.transport.http.HttpRequest)3 HttpResponse (com.microsoft.azure.sdk.iot.deps.transport.http.HttpResponse)3 ResponseData (com.microsoft.azure.sdk.iot.provisioning.device.internal.task.ResponseData)3 URL (java.net.URL)3 ProvisioningDeviceClientException (com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceClientException)1 ProvisioningDeviceSecurityException (com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceSecurityException)1 TpmRegistrationResultParser (com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.TpmRegistrationResultParser)1 SecurityProviderSymmetricKey (com.microsoft.azure.sdk.iot.provisioning.security.SecurityProviderSymmetricKey)1 SecurityProviderTpm (com.microsoft.azure.sdk.iot.provisioning.security.SecurityProviderTpm)1 Base64.encodeBase64String (org.apache.commons.codec.binary.Base64.encodeBase64String)1