use of com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString in project azure-iot-sdk-java by Azure.
the class ServiceAuthenticationWithSharedAccessPolicyTokenTest method populateStorePolicyNameAndToken.
/* Tests_SRS_SERVICE_AUTHENTICATION_WITH_SHARED_ACCESS_POLICY_TOKEN_21_005: [The populateWithAuthenticationProperties shall save the policyName and token to the target object.] */
@Test
public void populateStorePolicyNameAndToken() {
// arrange
final String policyName = "validPolicyName";
final String token = "validToken";
final ProvisioningConnectionString provisioningConnectionString = mockedProvisioningConnectionString;
Object authenticationMethodResult = Deencapsulation.newInstance("com.microsoft.azure.sdk.iot.provisioning.service.auth.ServiceAuthenticationWithSharedAccessPolicyToken", new Class[] { String.class, String.class }, policyName, token);
// act
Deencapsulation.invoke(authenticationMethodResult, "populateWithAuthenticationProperties", new Class[] { ProvisioningConnectionString.class }, provisioningConnectionString);
// assert
new Verifications() {
{
Deencapsulation.invoke(mockedProvisioningConnectionString, "setSharedAccessKeyName", policyName);
times = 1;
Deencapsulation.invoke(mockedProvisioningConnectionString, "setSharedAccessSignature", token);
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString in project azure-iot-sdk-java by Azure.
the class ServiceAuthenticationWithSharedAccessPolicyTokenTest method populateSetKeyToNull.
/* Tests_SRS_SERVICE_AUTHENTICATION_WITH_SHARED_ACCESS_POLICY_TOKEN_21_006: [The populateWithAuthenticationProperties shall set the access key to null.] */
@Test
public void populateSetKeyToNull() {
// arrange
final String policyName = "validPolicyName";
final String token = "validToken";
final ProvisioningConnectionString provisioningConnectionString = mockedProvisioningConnectionString;
Object authenticationMethodResult = Deencapsulation.newInstance("com.microsoft.azure.sdk.iot.provisioning.service.auth.ServiceAuthenticationWithSharedAccessPolicyToken", new Class[] { String.class, String.class }, policyName, token);
// act
Deencapsulation.invoke(authenticationMethodResult, "populateWithAuthenticationProperties", new Class[] { ProvisioningConnectionString.class }, provisioningConnectionString);
// assert
new Verifications() {
{
Deencapsulation.invoke(mockedProvisioningConnectionString, "setSharedAccessKey", new Class[] { String.class }, (String) null);
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString in project azure-iot-sdk-java by Azure.
the class ContractApiHttpTest method createFromConnectionStringThrowsOnNullConnectionString.
/* SRS_HTTP_DEVICE_REGISTRATION_CLIENT_21_003: [The createFromConnectionString shall throw IllegalArgumentException if the input string is null, threw by the constructor.] */
@Test(expected = IllegalArgumentException.class)
public void createFromConnectionStringThrowsOnNullConnectionString() throws ProvisioningServiceClientException {
// arrange
final ProvisioningConnectionString provisioningConnectionString = null;
// act
ContractApiHttp.createFromConnectionString(provisioningConnectionString);
// assert
}
use of com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString in project azure-iot-sdk-java by Azure.
the class ServiceAuthenticationWithSharedAccessPolicyKeyTest method populateStorePolicyNameAndKey.
/* Tests_SRS_SERVICE_AUTHENTICATION_WITH_SHARED_ACCESS_POLICY_KEY_21_005: [The populateWithAuthenticationProperties shall save the policyName and key to the target object.] */
@Test
public void populateStorePolicyNameAndKey() {
// 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, "setSharedAccessKeyName", policyName);
times = 1;
Deencapsulation.invoke(mockedProvisioningConnectionString, "setSharedAccessKey", key);
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString in project azure-iot-sdk-java by Azure.
the class ServiceAuthenticationWithSharedAccessPolicyKeyTest method populateThrowsOnNullConnectionString.
/* Tests_SRS_SERVICE_AUTHENTICATION_WITH_SHARED_ACCESS_POLICY_KEY_21_004: [If the provided provisioningConnectionString is null, the populateWithAuthenticationProperties shall throw IllegalArgumentException.] */
@Test(expected = IllegalArgumentException.class)
public void populateThrowsOnNullConnectionString() {
// arrange
final String policyName = "validPolicyName";
final String key = "validKey";
final ProvisioningConnectionString provisioningConnectionString = null;
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
}
Aggregations