Search in sources :

Example 46 with ProvisioningConnectionString

use of com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString in project azure-iot-sdk-java by Azure.

the class ProvisioningConnectionStringTest method buildProvisioningConnectionString.

ProvisioningConnectionString buildProvisioningConnectionString() {
    ProvisioningConnectionString provisioningConnectionString = Deencapsulation.newInstance(ProvisioningConnectionString.class);
    Deencapsulation.setField(provisioningConnectionString, "hostName", VALID_HOST_NAME_PROPERTY_NAME);
    Deencapsulation.setField(provisioningConnectionString, "sharedAccessKeyName", VALID_SHARED_ACCESS_KEY_NAME_PROPERTY_NAME);
    Deencapsulation.setField(provisioningConnectionString, "sharedAccessKey", VALID_SHARED_ACCESS_KEY_PROPERTY_NAME);
    Deencapsulation.setField(provisioningConnectionString, "sharedAccessSignature", VALID_SHARED_ACCESS_SIGNATURE_PROPERTY_NAME);
    Deencapsulation.setField(provisioningConnectionString, "deviceProvisioningServiceName", VALID_DEVICE_PROVISIONING_SERVICE_NAME);
    Deencapsulation.setField(provisioningConnectionString, "authenticationMethod", mockedAuthenticationMethod);
    return provisioningConnectionString;
}
Also used : ProvisioningConnectionString(com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString)

Example 47 with ProvisioningConnectionString

use of com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString in project azure-iot-sdk-java by Azure.

the class ProvisioningConnectionStringTest method getSharedAccessSignatureSucceeded.

/* Tests_SRS_PROVISIONINGCONNECTIONSTRING_21_007: [The getSharedAccessSignature shall return the stored sharedAccessSignature.] */
@Test
public void getSharedAccessSignatureSucceeded() {
    // arrange
    ProvisioningConnectionString provisioningConnectionString = buildProvisioningConnectionString();
    // act
    String result = provisioningConnectionString.getSharedAccessSignature();
    // assert
    assertEquals(VALID_SHARED_ACCESS_SIGNATURE_PROPERTY_NAME, result);
}
Also used : ProvisioningConnectionString(com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString) ProvisioningConnectionString(com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString) Test(org.junit.Test)

Example 48 with ProvisioningConnectionString

use of com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString in project azure-iot-sdk-java by Azure.

the class ProvisioningConnectionStringTest method toStringSucceeded.

/* Tests_SRS_PROVISIONINGCONNECTIONSTRING_21_002: [The toString shall serialize the object to a string using the following format: HostName=HOSTNAME.b.c.d;SharedAccessKeyName=ACCESSKEYNAME;SharedAccessKey=1234567890abcdefghijklmnopqrstvwxyz=;SharedAccessSignature=] */
@Test
public void toStringSucceeded() {
    // arrange
    ProvisioningConnectionString provisioningConnectionString = buildProvisioningConnectionString();
    // act
    String result = provisioningConnectionString.toString();
    // assert
    assertEquals("HostName=" + VALID_HOST_NAME_PROPERTY_NAME + ";SharedAccessKeyName=" + VALID_SHARED_ACCESS_KEY_NAME_PROPERTY_NAME + ";SharedAccessKey=" + VALID_SHARED_ACCESS_KEY_PROPERTY_NAME + ";SharedAccessSignature=" + VALID_SHARED_ACCESS_SIGNATURE_PROPERTY_NAME, result);
}
Also used : ProvisioningConnectionString(com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString) ProvisioningConnectionString(com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString) Test(org.junit.Test)

Aggregations

ProvisioningConnectionString (com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString)48 Test (org.junit.Test)47 Expectations (mockit.Expectations)7 AuthenticationMethod (com.microsoft.azure.sdk.iot.provisioning.service.auth.AuthenticationMethod)5 ProvisioningSasToken (com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningSasToken)4 Verifications (mockit.Verifications)4 Base64.encodeBase64String (org.apache.commons.codec.binary.Base64.encodeBase64String)3 ContractApiHttp (com.microsoft.azure.sdk.iot.provisioning.service.contract.ContractApiHttp)1 URLEncoder (java.net.URLEncoder)1 Mac (javax.crypto.Mac)1 SecretKeySpec (javax.crypto.spec.SecretKeySpec)1