예제 #1
0
        public static void EventSource_SuccessfulHandshake_LogsStartStop()
        {
            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_StreamToStream_Authentication_Success();
                    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[] stops = events.Where(e => e.EventName == "HandshakeStop").ToArray();
                Assert.Equal(2, stops.Length);
                Assert.All(stops, s => ValidateHandshakeStopEventPayload(s, failure: false));

                Assert.DoesNotContain(events, e => e.EventName == "HandshakeFailed");

                VerifyEventCounters(events, shouldHaveFailures: false);
            }).Dispose();
        }
예제 #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();
예제 #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();
 }
예제 #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();
 }
예제 #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();
 }
예제 #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();
 }
예제 #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();
        }