|
18 | 18 |
|
19 | 19 | namespace Tests.ClientConcepts.Troubleshooting |
20 | 20 | { |
21 | | - /** |
22 | | - * === Debug information |
23 | | - * |
24 | | - * Every response from Elasticsearch.Net and NEST contains a `DebugInformation` property |
25 | | - * that provides a human readable description of what happened during the request for both successful and |
26 | | - * failed requests |
27 | | - */ |
28 | | - public class DebugInformation : IntegrationDocumentationTestBase, IClusterFixture<ReadOnlyCluster> |
29 | | - { |
30 | | - public DebugInformation(ReadOnlyCluster cluster) : base(cluster) {} |
| 21 | + /** |
| 22 | + * === Debug information |
| 23 | + * |
| 24 | + * Every response from Elasticsearch.Net and NEST contains a `DebugInformation` property |
| 25 | + * that provides a human readable description of what happened during the request for both successful and |
| 26 | + * failed requests |
| 27 | + */ |
| 28 | + public class DebugInformation : IntegrationDocumentationTestBase, IClusterFixture<ReadOnlyCluster> |
| 29 | + { |
| 30 | + public DebugInformation(ReadOnlyCluster cluster) : base(cluster) {} |
31 | 31 |
|
32 | | - [I] public void DefaultDebug() |
33 | | - { |
34 | | - // hide |
35 | | - var client = this.Client; |
| 32 | + [I] public void DefaultDebug() |
| 33 | + { |
| 34 | + // hide |
| 35 | + var client = this.Client; |
36 | 36 |
|
37 | | - var response = client.Search<Project>(s => s |
38 | | - .Query(q => q |
39 | | - .MatchAll() |
40 | | - ) |
41 | | - ); |
| 37 | + var response = client.Search<Project>(s => s |
| 38 | + .Query(q => q |
| 39 | + .MatchAll() |
| 40 | + ) |
| 41 | + ); |
42 | 42 |
|
43 | | - response.DebugInformation.Should().Contain("Valid NEST response"); |
44 | | - } |
| 43 | + response.DebugInformation.Should().Contain("Valid NEST response"); |
| 44 | + } |
45 | 45 | //hide |
46 | | - [U] public void PasswordIsNotExposedInDebugInformation() |
47 | | - { |
48 | | - // hide |
49 | | - var client = new ElasticClient(new AlwaysInMemoryConnectionSettings() |
| 46 | + [U] public void PasswordIsNotExposedInDebugInformation() |
| 47 | + { |
| 48 | + // hide |
| 49 | + var client = new ElasticClient(new AlwaysInMemoryConnectionSettings() |
50 | 50 | .DefaultIndex("index") |
51 | 51 | .BasicAuthentication("user1", "pass2") |
52 | 52 | ); |
53 | 53 |
|
54 | | - var response = client.Search<Project>(s => s |
55 | | - .Query(q => q |
56 | | - .MatchAll() |
57 | | - ) |
58 | | - ); |
| 54 | + var response = client.Search<Project>(s => s |
| 55 | + .Query(q => q |
| 56 | + .MatchAll() |
| 57 | + ) |
| 58 | + ); |
59 | 59 |
|
60 | | - response.DebugInformation.Should().NotContain("pass2"); |
61 | | - } |
| 60 | + response.DebugInformation.Should().NotContain("pass2"); |
| 61 | + } |
62 | 62 |
|
63 | 63 | //hide |
64 | | - [U] public void PasswordIsNotExposedInDebugInformationWhenPartOfUrl() |
65 | | - { |
66 | | - // hide |
| 64 | + [U] public void PasswordIsNotExposedInDebugInformationWhenPartOfUrl() |
| 65 | + { |
| 66 | + // hide |
67 | 67 | var pool = new SingleNodeConnectionPool(new Uri("http://user1:pass2@localhost:9200")); |
68 | | - var client = new ElasticClient(new ConnectionSettings(pool, new InMemoryConnection()) |
| 68 | + var client = new ElasticClient(new ConnectionSettings(pool, new InMemoryConnection()) |
69 | 69 | .DefaultIndex("index") |
70 | 70 | ); |
71 | 71 |
|
72 | | - var response = client.Search<Project>(s => s |
73 | | - .Query(q => q |
74 | | - .MatchAll() |
75 | | - ) |
76 | | - ); |
| 72 | + var response = client.Search<Project>(s => s |
| 73 | + .Query(q => q |
| 74 | + .MatchAll() |
| 75 | + ) |
| 76 | + ); |
77 | 77 |
|
78 | | - response.DebugInformation.Should().NotContain("pass2"); |
79 | | - } |
80 | | - /** |
81 | | - * This can be useful in tracking down numerous problems and can also be useful when filing an |
82 | | - * {github}/issues[issue] on our github repository. |
83 | | - * |
84 | | - * By default, the request and response bytes are not available within the debug information, but |
85 | | - * can be enabled globally on Connection Settings |
86 | | - * |
87 | | - */ |
88 | | - public void DisableDirectStreaming() |
89 | | - { |
90 | | - var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200")); |
| 78 | + response.DebugInformation.Should().NotContain("pass2"); |
| 79 | + } |
| 80 | + /** |
| 81 | + * This can be useful in tracking down numerous problems and can also be useful when filing an |
| 82 | + * {github}/issues[issue] on our github repository. |
| 83 | + * |
| 84 | + * By default, the request and response bytes are not available within the debug information, but |
| 85 | + * can be enabled globally on Connection Settings |
| 86 | + * |
| 87 | + */ |
| 88 | + public void DisableDirectStreaming() |
| 89 | + { |
| 90 | + var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200")); |
91 | 91 |
|
92 | | - var settings = new ConnectionSettings(connectionPool) |
93 | | - .DisableDirectStreaming(); // <1> disable direct streaming for *all* requests |
| 92 | + var settings = new ConnectionSettings(connectionPool) |
| 93 | + .DisableDirectStreaming(); // <1> disable direct streaming for *all* requests |
94 | 94 |
|
95 | | - var client = new ElasticClient(settings); |
96 | | - } |
| 95 | + var client = new ElasticClient(settings); |
| 96 | + } |
97 | 97 |
|
98 | | - /** |
99 | | - * or on a _per request_ basis |
100 | | - */ |
101 | | - [I] public void DisableDirectStreamingPerRequest() |
102 | | - { |
103 | | - // hide |
104 | | - var client = TestClient.DefaultInMemoryClient; |
| 98 | + /** |
| 99 | + * or on a _per request_ basis |
| 100 | + */ |
| 101 | + [I] public void DisableDirectStreamingPerRequest() |
| 102 | + { |
| 103 | + // hide |
| 104 | + var client = TestClient.DefaultInMemoryClient; |
105 | 105 |
|
106 | | - var response = client.Search<Project>(s => s |
107 | | - .RequestConfiguration(r => r |
108 | | - .DisableDirectStreaming() // <1> disable direct streaming for *this* request |
109 | | - ) |
110 | | - .Query(q => q |
111 | | - .MatchAll() |
112 | | - ) |
113 | | - ); |
| 106 | + var response = client.Search<Project>(s => s |
| 107 | + .RequestConfiguration(r => r |
| 108 | + .DisableDirectStreaming() // <1> disable direct streaming for *this* request |
| 109 | + ) |
| 110 | + .Query(q => q |
| 111 | + .MatchAll() |
| 112 | + ) |
| 113 | + ); |
114 | 114 |
|
115 | | - response.DebugInformation.Should().Contain("\"match_all\":"); |
116 | | - } |
117 | | - } |
| 115 | + response.DebugInformation.Should().Contain("\"match_all\":"); |
| 116 | + } |
| 117 | + } |
118 | 118 | } |
0 commit comments