in src/Proton.TestPeer/Driver/AMQPTestDriver.cs [407:463]
public void HandleSaslPerformative(uint frameSize, SaslDescribedType sasl, ushort channel, byte[] payload)
{
mutex.WaitOne();
try
{
saslPerformativeCount++;
if (!script.TryDequeue(out IScriptedElement scriptEntry))
{
SignalFailure(new AssertionError("Received SASL performative when not expecting any input."));
}
else if (scriptEntry is ScriptedExpectation expectation)
{
try
{
// When the outcome of SASL is read the decoder should revert to initial state
// as the only valid next incoming value is an AMQP header.
if (sasl is SaslOutcome)
{
frameParser.ResetToExpectingHeader();
}
sasl.Invoke(expectation, frameSize, payload, channel, this);
}
catch (UnexpectedPerformativeError unexpected)
{
if (expectation.IsOptional)
{
HandleSaslPerformative(frameSize, sasl, channel, payload);
}
else
{
logger.LogWarning(unexpected.Message);
SignalFailure(unexpected);
throw;
}
}
catch (Exception assertion)
{
logger.LogWarning(assertion.Message);
SignalFailure(assertion);
throw;
}
}
else
{
SignalFailure(new AssertionError(
"Received SASL performative when not expecting to perform some action or other script item."));
}
ProcessScript(scriptEntry);
}
finally
{
mutex.ReleaseMutex();
}
}