You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Produces a human-readable string representation of the server's received-bytes buffer, interpreting embedded markers and formatting arrays and numeric values.
222
+
/// </summary>
223
+
/// <returns>The formatted textual representation of the received bytes buffer.</returns>
224
+
/// <exception cref="NotImplementedException">Thrown when the buffer contains an unsupported type code.</exception>
Copy file name to clipboardExpand all lines: src/net-questdb-client-tests/DummyIlpServer.cs
+51Lines changed: 51 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,11 @@ public class DummyIlpServer : IDisposable
49
49
privatestring?_publicKeyY;
50
50
privatevolatileint_totalReceived;
51
51
52
+
/// <summary>
53
+
/// Initializes the dummy ILP server and starts a TCP listener bound to the loopback interface.
54
+
/// </summary>
55
+
/// <param name="port">TCP port to listen on.</param>
56
+
/// <param name="tls">If true, enables TLS for incoming connections.</param>
52
57
publicDummyIlpServer(intport,booltls)
53
58
{
54
59
_tls=tls;
@@ -69,6 +74,12 @@ public void AcceptAsync()
69
74
Task.Run(AcceptConnections);
70
75
}
71
76
77
+
/// <summary>
78
+
/// Accepts a single incoming connection, optionally negotiates TLS and performs server authentication, then reads and saves data from the client.
79
+
/// </summary>
80
+
/// <remarks>
81
+
/// Handles one client socket from the listener, wraps the connection with TLS if configured, invokes server-auth when credentials are set, and delegates continuous data receipt to the save routine. Socket errors are caught and the client socket is disposed on exit.
/// Performs the server-side authentication handshake over the given stream using a challenge-response ECDSA verification.
123
+
/// </summary>
124
+
/// <param name="connection">Stream used for the authentication handshake; the method may write to it and will close it if the requested key id mismatches or the signature verification fails.</param>
125
+
/// <exception cref="InvalidOperationException">Thrown when the configured public key coordinates are not set.</exception>
@@ -173,6 +194,11 @@ public static byte[] FromBase64String(string encodedPrivateKey)
173
194
returnConvert.FromBase64String(Pad(replace));
174
195
}
175
196
197
+
/// <summary>
198
+
/// Reads bytes from the provided stream until a newline ('\n') byte is encountered, storing any bytes that follow the newline from the final read into the server's receive buffer.
199
+
/// </summary>
200
+
/// <param name="connection">The stream to read incoming bytes from.</param>
201
+
/// <returns>The index position of the newline byte within the internal read buffer.</returns>
/// Produces a human-readable representation of the data received from the connected client.
254
+
/// </summary>
255
+
/// <returns>A formatted string containing the contents of the server's received buffer.</returns>
226
256
publicstringGetTextReceived()
227
257
{
228
258
returnPrintBuffer();
229
259
}
230
260
261
+
/// <summary>
262
+
/// Gets a copy of all bytes received so far.
263
+
/// </summary>
264
+
/// <returns>A byte array containing the raw bytes received up to this point.</returns>
231
265
publicbyte[]GetReceivedBytes()
232
266
{
233
267
return_received.ToArray();
234
268
}
235
269
270
+
/// <summary>
271
+
/// Converts the server's accumulated receive buffer into a human-readable string by decoding UTF-8 text and expanding embedded binary markers into readable representations.
272
+
/// </summary>
273
+
/// <remarks>
274
+
/// The method scans the internal receive buffer for the marker sequence "==". After the marker a type byte determines how the following bytes are interpreted:
275
+
/// - type 14: formats a multi-dimensional array of doubles as "ARRAY<dim1,dim2,...>[v1,v2,...]".
276
+
/// - type 16: formats a single double value.
277
+
/// All bytes outside these marked sections are decoded as UTF-8 text and included verbatim.
278
+
/// </remarks>
279
+
/// <returns>A formatted string containing the decoded UTF-8 text and expanded representations of any detected binary markers.</returns>
280
+
/// <exception cref="NotImplementedException">Thrown when an unknown type marker is encountered after the marker sequence.</exception>
236
281
publicstringPrintBuffer()
237
282
{
238
283
varbytes=_received.ToArray();
@@ -317,6 +362,12 @@ public string PrintBuffer()
317
362
returnsb.ToString();
318
363
}
319
364
365
+
/// <summary>
366
+
/// Enables server-side authentication by configuring the expected key identifier and the ECDSA public key coordinates.
367
+
/// </summary>
368
+
/// <param name="keyId">The key identifier expected from the client during authentication.</param>
369
+
/// <param name="publicKeyX">Base64-encoded X coordinate of the ECDSA public key (secp256r1).</param>
370
+
/// <param name="publicKeyY">Base64-encoded Y coordinate of the ECDSA public key (secp256r1).</param>
/// Executes the provided test case by sending its configured table, symbols, and columns to a local TCP listener and asserting the listener's received output against the test case's expected result.
98
+
/// </summary>
99
+
/// <param name="testCase">The test case to run; provides table, symbols, columns to send and a Result describing the expected validation (Status, Line, AnyLines, or BinaryBase64).</param>
90
100
[TestCaseSource(nameof(TestCases))]
91
101
publicasyncTaskRunTcp(TestCasetestCase)
92
102
{
@@ -143,6 +153,10 @@ public async Task RunTcp(TestCase testCase)
143
153
}
144
154
}
145
155
156
+
/// <summary>
157
+
/// Executes the provided test case by sending data over HTTP to a dummy server using a QuestDB sender and validates the server's response according to the test case result.
158
+
/// </summary>
159
+
/// <param name="testCase">The test case describing table, symbols, columns, and expected result (status, line(s), or base64 binary) to execute and validate.</param>
0 commit comments