Beispiel #1
0
        public static void EventSource_UnsuccessfulHandshake_LogsStartFailureStop()
        {
            RemoteExecutor.Invoke(async() =>
            {
                using var listener = new TestEventListener("System.Net.Security", EventLevel.Verbose, eventCounterInterval: 0.1d);

                var events = new ConcurrentQueue <EventWrittenEventArgs>();
                await listener.RunWithCallbackAsync(events.Enqueue, async() =>
                {
                    // Invoke tests that'll cause some events to be generated
                    var test = new SslStreamStreamToStreamTest_Async();
                    await test.SslStream_ServerLocalCertificateSelectionCallbackReturnsNull_Throw();
                    await Task.Delay(300);
                });
                Assert.DoesNotContain(events, ev => ev.EventId == 0); // errors from the EventSource itself

                EventWrittenEventArgs[] starts = events.Where(e => e.EventName == "HandshakeStart").ToArray();
                Assert.Equal(2, starts.Length);
                Assert.All(starts, s => Assert.Equal(2, s.Payload.Count));
                Assert.Single(starts, s => s.Payload[0] is bool isServer && isServer);
                Assert.Single(starts, s => s.Payload[1] is string targetHost && targetHost.Length == 0);

                EventWrittenEventArgs[] failures = events.Where(e => e.EventName == "HandshakeFailed").ToArray();
                Assert.Equal(2, failures.Length);
                Assert.All(failures, f => Assert.Equal(3, f.Payload.Count));
                Assert.Single(failures, f => f.Payload[0] is bool isServer && isServer);
                Assert.All(failures, f => Assert.NotEmpty(f.Payload[2] as string)); // exceptionMessage

                EventWrittenEventArgs[] stops = events.Where(e => e.EventName == "HandshakeStop").ToArray();
                Assert.Equal(2, stops.Length);
                Assert.All(stops, s => ValidateHandshakeStopEventPayload(s, failure: true));

                VerifyEventCounters(events, shouldHaveFailures: true);
            }).Dispose();
        }
Beispiel #2
0
        public static void EventSource_SuccessfulHandshake_LogsStartStop()
        {
            RemoteExecutor.Invoke(async() =>
            {
                using var listener = new TestEventListener("System.Net.Security", EventLevel.Verbose, eventCounterInterval: 0.1d);
                listener.AddActivityTracking();

                var events = new ConcurrentQueue <(EventWrittenEventArgs Event, Guid ActivityId)>();
                await listener.RunWithCallbackAsync(e => events.Enqueue((e, e.ActivityId)), async() =>
                {
                    // Invoke tests that'll cause some events to be generated
                    var test = new SslStreamStreamToStreamTest_Async();
                    await test.SslStream_StreamToStream_Authentication_Success();
                    await WaitForEventCountersAsync(events);
                });
                Assert.DoesNotContain(events, ev => ev.Event.EventId == 0); // errors from the EventSource itself

                (EventWrittenEventArgs Event, Guid ActivityId)[] starts = events.Where(e => e.Event.EventName == "HandshakeStart").ToArray();
                Assert.Equal(2, starts.Length);
                Assert.All(starts, s => Assert.Equal(2, s.Event.Payload.Count));
                Assert.All(starts, s => Assert.NotEqual(Guid.Empty, s.ActivityId));

                // isServer
                (EventWrittenEventArgs Event, Guid ActivityId)serverStart = Assert.Single(starts, s => (bool)s.Event.Payload[0]);
                (EventWrittenEventArgs Event, Guid ActivityId)clientStart = Assert.Single(starts, s => !(bool)s.Event.Payload[0]);

                // targetHost
                Assert.Empty(Assert.IsType <string>(serverStart.Event.Payload[1]));
                Assert.NotEmpty(Assert.IsType <string>(clientStart.Event.Payload[1]));

                Assert.NotEqual(serverStart.ActivityId, clientStart.ActivityId);

                (EventWrittenEventArgs Event, Guid ActivityId)[] stops = events.Where(e => e.Event.EventName == "HandshakeStop").ToArray();
Beispiel #3
0
 public void EventSource_EventsRaisedAsExpected()
 {
     RemoteExecutor.Invoke(() =>
     {
         using (var listener = new TestEventListener("Private.InternalDiagnostics.System.Net.Security", EventLevel.Verbose))
         {
             var events = new ConcurrentQueue <EventWrittenEventArgs>();
             listener.RunWithCallback(events.Enqueue, () =>
             {
                 // Invoke tests that'll cause some events to be generated
                 var test = new SslStreamStreamToStreamTest_Async();
                 test.SslStream_StreamToStream_Authentication_Success().GetAwaiter().GetResult();
             });
             Assert.DoesNotContain(events, ev => ev.EventId == 0); // errors from the EventSource itself
             Assert.InRange(events.Count, 1, int.MaxValue);
         }
     }).Dispose();
 }
Beispiel #4
0
 public void EventSource_EventsRaisedAsExpected()
 {
     RemoteInvoke(() =>
     {
         using (var listener = new TestEventListener("Microsoft-System-Net-Security", EventLevel.Verbose))
         {
             var events = new ConcurrentQueue <EventWrittenEventArgs>();
             listener.RunWithCallback(events.Enqueue, () =>
             {
                 // Invoke tests that'll cause some events to be generated
                 var test = new SslStreamStreamToStreamTest_Async();
                 test.SslStream_StreamToStream_Authentication_Success();
                 test.SslStream_StreamToStream_Successive_ClientWrite_Sync_Success();
             });
             Assert.DoesNotContain(events, ev => ev.EventId == 0); // errors from the EventSource itself
             Assert.InRange(events.Count, 1, int.MaxValue);
         }
         return(SuccessExitCode);
     }).Dispose();
 }
Beispiel #5
0
 public void EventSource_EventsRaisedAsExpected()
 {
     RemoteInvoke(() =>
     {
         using (var listener = new TestEventListener("Microsoft-System-Net-Security", EventLevel.Verbose))
         {
             var events = new ConcurrentQueue<EventWrittenEventArgs>();
             listener.RunWithCallback(events.Enqueue, () =>
             {
                 // Invoke tests that'll cause some events to be generated
                 var test = new SslStreamStreamToStreamTest_Async();
                 test.SslStream_StreamToStream_Authentication_Success();
                 test.SslStream_StreamToStream_Successive_ClientWrite_Sync_Success();
             });
             Assert.DoesNotContain(events, ev => ev.EventId == 0); // errors from the EventSource itself
             Assert.InRange(events.Count, 1, int.MaxValue);
         }
         return SuccessExitCode;
     }).Dispose();
 }
Beispiel #6
0
 [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "X509 certificate store is not supported on iOS or tvOS.")] // Match SslStream_StreamToStream_Authentication_Success
 public void EventSource_EventsRaisedAsExpected()
 {
     RemoteExecutor.Invoke(async() =>
     {
         try
         {
             using var listener = new TestEventListener("Private.InternalDiagnostics.System.Net.Security", EventLevel.Verbose);
             var events         = new ConcurrentQueue <EventWrittenEventArgs>();
             await listener.RunWithCallbackAsync(events.Enqueue, async() =>
             {
                 // Invoke tests that'll cause some events to be generated
                 var test = new SslStreamStreamToStreamTest_Async();
                 await test.SslStream_StreamToStream_Authentication_Success();
             });
             Assert.DoesNotContain(events, ev => ev.EventId == 0); // errors from the EventSource itself
             Assert.InRange(events.Count, 1, int.MaxValue);
         }
         catch (SkipTestException)
         {
             // Don't throw inside RemoteExecutor if SslStream_StreamToStream_Authentication_Success chose to skip the test
         }
     }).Dispose();
 }
Beispiel #7
0
        public void EventSource_EventsRaisedAsExpected()
        {
            if (PlatformDetection.IsWindows10Version22000OrGreater)
            {
                // [ActiveIssue("https://github.com/dotnet/runtime/issues/58927")]
                throw new SkipTestException("Unstable on Windows 11");
            }

            RemoteExecutor.Invoke(() =>
            {
                using (var listener = new TestEventListener("Private.InternalDiagnostics.System.Net.Security", EventLevel.Verbose))
                {
                    var events = new ConcurrentQueue <EventWrittenEventArgs>();
                    listener.RunWithCallback(events.Enqueue, () =>
                    {
                        // Invoke tests that'll cause some events to be generated
                        var test = new SslStreamStreamToStreamTest_Async();
                        test.SslStream_StreamToStream_Authentication_Success().GetAwaiter().GetResult();
                    });
                    Assert.DoesNotContain(events, ev => ev.EventId == 0); // errors from the EventSource itself
                    Assert.InRange(events.Count, 1, int.MaxValue);
                }
            }).Dispose();
        }