Example #1
0
        protected override void OnWaitForServerConnectionCompleted(TestContext ctx, Task task)
        {
            if (Type == SignatureInstrumentType.ClientProvidesNoSupportedSignatureAlgorithms)
            {
                // FIXME: we allow both successful completion with the default signature algorithm of {SHA-1,RSA} and
                //        a fatal HandshakeFailure alert.
                if (task.IsFaulted)
                {
                    MonoConnectionHelper.ExpectAlert(ctx, task, Parameters.ExpectServerAlert.Value, "expect server alert");
                    throw new ConnectionFinishedException();
                }
                else
                {
                    ctx.Assert(task.Status, Is.EqualTo(TaskStatus.RanToCompletion), "successful completion");
                    return;
                }
            }
            else if (Type == SignatureInstrumentType.ServerSendsCertificateParametersWithNoSupportedAlgorithms)
            {
                if (task.IsFaulted)
                {
                    throw new ConnectionFinishedException();
                }
            }

            base.OnWaitForServerConnectionCompleted(ctx, task);
        }
        public async Task ExpectAlert(TestContext ctx, AlertDescription alert, CancellationToken cancellationToken)
        {
            var serverTask = Server.WaitForConnection(ctx, cancellationToken);
            var clientTask = Client.WaitForConnection(ctx, cancellationToken);

            var t1 = clientTask.ContinueWith(t => MonoConnectionHelper.ExpectAlert(ctx, t, alert, "client"));
            var t2 = serverTask.ContinueWith(t => MonoConnectionHelper.ExpectAlert(ctx, t, alert, "server"));

            await Task.WhenAll(t1, t2);
        }
        protected override void OnWaitForClientConnectionCompleted(TestContext ctx, Task task)
        {
            if (Parameters.ExpectClientAlert != null)
            {
                MonoConnectionHelper.ExpectAlert(ctx, task, Parameters.ExpectClientAlert.Value, "expect client alert");
                throw new ConnectionFinishedException();
            }

            base.OnWaitForClientConnectionCompleted(ctx, task);
        }
        protected override void OnWaitForServerConnectionCompleted(TestContext ctx, Task task)
        {
            if (Parameters.ExpectClientAlert != null)
            {
                ctx.Assert(task.IsFaulted, "expecting exception");
                throw new ConnectionFinishedException();
            }

            if (Parameters.ExpectServerAlert != null)
            {
                MonoConnectionHelper.ExpectAlert(ctx, task, Parameters.ExpectServerAlert.Value, "expect server alert");
                throw new ConnectionFinishedException();
            }

            base.OnWaitForServerConnectionCompleted(ctx, task);
        }