use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.AmqpsProvisioningSaslHandler in project azure-iot-sdk-java by Azure.
the class AmqpsProvisioningSaslHandlerTest method choseSaslMechanismThrowsIfNotWaitingToChooseMechanism.
// Tests_SRS_AMQPSPROVISIONINGSASLHANDLER_34_003: [If this handler is not in the state where it is expecting to choose a sasl mechanism, this function shall throw in IllegalStateException.]
@Test(expected = IllegalStateException.class)
public void choseSaslMechanismThrowsIfNotWaitingToChooseMechanism() throws ProvisioningDeviceSecurityException {
// arrange
AmqpsProvisioningSaslHandler handler = Deencapsulation.newInstance(AmqpsProvisioningSaslHandler.class, idScope, registrationId, endorsementKey, storageRootKey, mockedResponseCallback, new Object());
handler.chooseSaslMechanism(new String[] { "NotTPM", "TPM" });
// act
handler.chooseSaslMechanism(new String[] { "NotTPM", "TPM" });
}
use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.AmqpsProvisioningSaslHandler in project azure-iot-sdk-java by Azure.
the class AmqpsProvisioningSaslHandlerTest method handleOutcomeAuthThrowsProvisioningDeviceSecurityException.
// Tests_SRS_AMQPSPROVISIONINGSASLHANDLER_34_022: [If the sasl outcome is not OK, this function shall throw a ProvisioningDeviceSecurityException.]
@Test(expected = ProvisioningDeviceSecurityException.class)
public void handleOutcomeAuthThrowsProvisioningDeviceSecurityException() throws ProvisioningDeviceClientException {
// arrange
AmqpsProvisioningSaslHandler handler = Deencapsulation.newInstance(AmqpsProvisioningSaslHandler.class, idScope, registrationId, endorsementKey, storageRootKey, mockedResponseCallback, new Object());
handler.chooseSaslMechanism(new String[] { "TPM", "notTPM" });
handler.getInitPayload("TPM");
handler.handleChallenge(validFirstChallenge);
handler.handleChallenge(validSecondChallenge);
Deencapsulation.setField(handler, "sasToken", sasToken);
handler.handleChallenge(validThirdChallenge);
// act
handler.handleOutcome(SaslHandler.SaslOutcome.AUTH);
}
Aggregations