Search in sources :

Example 26 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 getSharedAccessKeySucceeded.

/* Tests_SRS_PROVISIONINGCONNECTIONSTRING_21_006: [The getSharedAccessKey shall return the stored sharedAccessKey.] */
@Test
public void getSharedAccessKeySucceeded() {
    // arrange
    ProvisioningConnectionString provisioningConnectionString = buildProvisioningConnectionString();
    // act
    String result = provisioningConnectionString.getSharedAccessKey();
    // assert
    assertEquals(VALID_SHARED_ACCESS_KEY_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 27 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 setSharedAccessKeySucceeded.

/* Tests_SRS_PROVISIONINGCONNECTIONSTRING_21_010: [The setSharedAccessKey shall update the sharedAccessKey by the provided one.] */
@Test
public void setSharedAccessKeySucceeded() {
    // arrange
    ProvisioningConnectionString provisioningConnectionString = buildProvisioningConnectionString();
    final String newValue = "newSharedAccessKey";
    // act
    Deencapsulation.invoke(provisioningConnectionString, "setSharedAccessKey", newValue);
    // assert
    assertEquals(newValue, provisioningConnectionString.getSharedAccessKey());
}
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 28 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 getAuthenticationMethodSucceeded.

/* Tests_SRS_PROVISIONINGCONNECTIONSTRING_21_004: [The getAuthenticationMethod shall return the stored authenticationMethod.] */
@Test
public void getAuthenticationMethodSucceeded() {
    // arrange
    ProvisioningConnectionString provisioningConnectionString = buildProvisioningConnectionString();
    // act
    AuthenticationMethod result = provisioningConnectionString.getAuthenticationMethod();
    // assert
    assertEquals(mockedAuthenticationMethod, result);
}
Also used : ProvisioningConnectionString(com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString) AuthenticationMethod(com.microsoft.azure.sdk.iot.provisioning.service.auth.AuthenticationMethod) Test(org.junit.Test)

Example 29 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 setSharedAccessSignatureSucceeded.

/* Tests_SRS_PROVISIONINGCONNECTIONSTRING_21_011: [The setSharedAccessSignature shall update the sharedAccessSignature by the provided one.] */
@Test
public void setSharedAccessSignatureSucceeded() {
    // arrange
    ProvisioningConnectionString provisioningConnectionString = buildProvisioningConnectionString();
    final String newValue = "newSharedAccessSignature";
    // act
    Deencapsulation.invoke(provisioningConnectionString, "setSharedAccessSignature", newValue);
    // assert
    assertEquals(newValue, provisioningConnectionString.getSharedAccessSignature());
}
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 30 with ProvisioningConnectionString

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

the class ServiceAuthenticationWithSharedAccessPolicyKeyTest method populateSetTokenToNull.

/* Tests_SRS_SERVICE_AUTHENTICATION_WITH_SHARED_ACCESS_POLICY_KEY_21_006: [The populateWithAuthenticationProperties shall set the access token to null.] */
@Test
public void populateSetTokenToNull() {
    // arrange
    final String policyName = "validPolicyName";
    final String key = "validKey";
    final ProvisioningConnectionString provisioningConnectionString = mockedProvisioningConnectionString;
    Object authenticationMethodResult = Deencapsulation.newInstance("com.microsoft.azure.sdk.iot.provisioning.service.auth.ServiceAuthenticationWithSharedAccessPolicyKey", new Class[] { String.class, String.class }, policyName, key);
    // act
    Deencapsulation.invoke(authenticationMethodResult, "populateWithAuthenticationProperties", new Class[] { ProvisioningConnectionString.class }, provisioningConnectionString);
    // assert
    new Verifications() {

        {
            Deencapsulation.invoke(mockedProvisioningConnectionString, "setSharedAccessSignature", new Class[] { String.class }, (String) null);
            times = 1;
        }
    };
}
Also used : ProvisioningConnectionString(com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString) ProvisioningConnectionString(com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString) Verifications(mockit.Verifications) 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