1- using Microsoft . Extensions . Configuration ;
1+ using Microsoft . Extensions . Configuration ;
22using Microsoft . Extensions . DependencyInjection ;
33using Microsoft . Extensions . Logging ;
44using AM . Extensions . Logging . ElasticSearch ;
1010using Nest ;
1111using Xunit . Abstractions ;
1212using LogLevel = Microsoft . Extensions . Logging . LogLevel ;
13+ using ElasticLogger . Test . Entities ;
14+ using ElasticLogger . Test . Fixture ;
1315
1416namespace ElasticLogger . Test
1517{
16- public class ElasticsearchLoggerFilterTests : IClassFixture < ESFixture >
18+ public class ElasticsearchLoggerFilterTests : IClassFixture < ElasticsearchFixture >
1719 {
1820 private readonly ITestOutputHelper _output ;
19- private readonly ESFixture _fixture ;
21+ private readonly ElasticsearchFixture _fixture ;
2022
21- public ElasticsearchLoggerFilterTests ( ESFixture fixture , ITestOutputHelper output )
23+ public ElasticsearchLoggerFilterTests ( ElasticsearchFixture fixture , ITestOutputHelper output )
2224 {
2325 _fixture = fixture ;
2426 _output = output ;
2527 }
2628
29+ private ConnectionSettings connectionSettings ( Uri endpoint )
30+ {
31+ var connSettings = new ConnectionSettings ( endpoint ) ;
32+ connSettings . ServerCertificateValidationCallback ( ( obj , cert , chain , policyerrors ) => true ) ;
33+ return connSettings ;
34+ }
35+
2736 [ Fact ]
2837 public async Task No_categories_for_es_should_use_default ( )
2938 {
@@ -62,7 +71,7 @@ public async Task No_categories_for_es_should_use_default()
6271 logger . LogTrace ( "bananas taste yucky" ) ;
6372
6473 var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
65- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
74+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
6675 await client . PingAsync ( ) ;
6776 await delayTask ;
6877
@@ -123,7 +132,7 @@ public async Task Configured_categories_dont_log_for_config()
123132 logger . LogTrace ( "bananas taste yucky" ) ;
124133
125134 var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
126- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
135+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
127136 await client . PingAsync ( ) ;
128137 await delayTask ;
129138
@@ -179,7 +188,7 @@ public async Task No_elasticsearch_section_should_use_default_log_level()
179188 logger . LogTrace ( "bananas taste yucky" ) ;
180189
181190 var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
182- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
191+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
183192 await client . PingAsync ( ) ;
184193 await delayTask ;
185194
@@ -285,7 +294,7 @@ private async Task LevelTesterPositive(string source, LogLevel logLevel)
285294 logger . Log ( logLevel , new EventId ( ) , circularRefObj , null , ( circle , exception ) => "" ) ;
286295
287296 var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
288- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
297+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
289298 await client . PingAsync ( ) ;
290299 await delayTask ;
291300
@@ -335,7 +344,7 @@ private async Task LevelTesterNegative(string source, LogLevel logLevel)
335344 logger . Log ( logLevel , new EventId ( ) , circularRefObj , null , ( circle , exception ) => "" ) ;
336345
337346 var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
338- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
347+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
339348 await client . PingAsync ( ) ;
340349 await delayTask ;
341350
@@ -357,7 +366,7 @@ private async Task LevelTesterNegative(string source, LogLevel logLevel)
357366 public async Task Load_ES_with_explicit_type_write_and_search ( )
358367 {
359368 await _fixture . ReadyAsync ( ) ;
360- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
369+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
361370 await client . PingAsync ( ) ;
362371
363372 var tweet = new Tweet
@@ -418,7 +427,7 @@ public async Task Missing_ElasticSearch_Section_In_Config_Should_Use_Logging_Def
418427 logger . LogTrace ( "bananas taste yucky" ) ;
419428
420429 var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
421- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
430+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
422431 await client . PingAsync ( ) ;
423432 await delayTask ;
424433
@@ -470,7 +479,8 @@ public async Task Missing_ElasticSearch_Section_In_Config_Should_Use_Logging_Def
470479 logger . LogError ( "bananas taste yucky" ) ;
471480
472481 var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
473- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
482+
483+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
474484 await client . PingAsync ( ) ;
475485 await delayTask ;
476486
@@ -487,6 +497,8 @@ public async Task Missing_ElasticSearch_Section_In_Config_Should_Use_Logging_Def
487497 Assert . Single ( dyndocs . Documents ) ;
488498 }
489499
500+
501+
490502 [ Fact ]
491503 public async Task Existing_ElasticSearch_Section_In_Config_Should_Be_Used_For_Log_Levels_Positive_Match ( )
492504 {
@@ -523,7 +535,7 @@ public async Task Existing_ElasticSearch_Section_In_Config_Should_Be_Used_For_Lo
523535 logger . LogTrace ( "bananas taste yucky" ) ;
524536
525537 var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
526- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
538+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
527539 await client . PingAsync ( ) ;
528540 await delayTask ;
529541
@@ -576,7 +588,7 @@ public async Task Existing_ElasticSearch_Section_In_Config_Should_Be_Used_For_Lo
576588 logger . LogCritical ( "bananas taste yucky" ) ;
577589
578590 var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
579- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
591+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
580592 await client . PingAsync ( ) ;
581593 await delayTask ;
582594
@@ -630,7 +642,7 @@ public async Task Existing_ElasticSearch_Section_With_Category_Should_Match_Top_
630642 logger . LogInformation ( "bananas taste yucky" ) ;
631643
632644 var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
633- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
645+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
634646 await client . PingAsync ( ) ;
635647 await delayTask ;
636648
@@ -684,7 +696,7 @@ public async Task Existing_ElasticSearch_Section_With_Category_Should_Match_Top_
684696 logger . LogInformation ( "bananas taste yucky" ) ;
685697
686698 var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
687- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
699+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
688700 await client . PingAsync ( ) ;
689701 await delayTask ;
690702
@@ -738,7 +750,7 @@ public async Task Existing_ElasticSearch_Section_With_Category_Should_Match_Bott
738750 logger . LogCritical ( "bananas taste yucky" ) ;
739751
740752 var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
741- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
753+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
742754 await client . PingAsync ( ) ;
743755 await delayTask ;
744756
@@ -792,7 +804,7 @@ public async Task Existing_ElasticSearch_Section_With_Category_Should_Match_Bott
792804 logger . LogInformation ( "bananas taste yucky" ) ;
793805
794806 var delayTask = Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) ;
795- var client = new ElasticClient ( new ConnectionSettings ( _fixture . Endpoint ) ) ;
807+ var client = new ElasticClient ( connectionSettings ( _fixture . Endpoint ) ) ;
796808 await client . PingAsync ( ) ;
797809 await delayTask ;
798810
0 commit comments