MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / parser_parses_authentication_messages

Function parser_parses_authentication_messages

src/protocol/tests.rs:353–422  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

351
352#[test]
353fn parser_parses_authentication_messages() -> Result<()> {
354 match parse_single(buffers::authentication_ok())? {
355 BackendMessage::Authentication(AuthenticationMessage::Ok(msg)) => {
356 assert_eq!(msg.length, 8);
357 }
358 other => panic!("unexpected message: {:?}", other.name()),
359 }
360
361 match parse_single(buffers::authentication_cleartext_password())? {
362 BackendMessage::Authentication(AuthenticationMessage::Cleartext(msg)) => {
363 assert_eq!(msg.length, 8);
364 }
365 other => panic!("unexpected message: {:?}", other.name()),
366 }
367
368 match parse_single(buffers::authentication_md5_password())? {
369 BackendMessage::Authentication(AuthenticationMessage::Md5(msg)) => {
370 assert_eq!(msg.length, 12);
371 assert_eq!(msg.salt, vec![1, 2, 3, 4]);
372 }
373 other => panic!("unexpected message: {:?}", other.name()),
374 }
375
376 match parse_single(buffers::authentication_sasl())? {
377 BackendMessage::Authentication(AuthenticationMessage::Sasl(msg)) => {
378 assert_eq!(msg.length, buffers::authentication_sasl().len() - 1);
379 assert_eq!(msg.mechanisms, vec!["SCRAM-SHA-256".to_string()]);
380 }
381 other => panic!("unexpected message: {:?}", other.name()),
382 }
383
384 match parse_single(buffers::authentication_sasl_continue())? {
385 BackendMessage::Authentication(AuthenticationMessage::SaslContinue(msg)) => {
386 assert_eq!(
387 msg.length,
388 buffers::authentication_sasl_continue().len() - 1
389 );
390 assert_eq!(msg.data, "data");
391 }
392 other => panic!("unexpected message: {:?}", other.name()),
393 }
394
395 let mut extended_continue = buffers::authentication_sasl_continue();
396 extended_continue.extend_from_slice(&[1, 2, 3, 4]);
397 match parse_single(extended_continue)? {
398 BackendMessage::Authentication(AuthenticationMessage::SaslContinue(msg)) => {
399 assert_eq!(msg.data, "data");
400 }
401 other => panic!("unexpected message: {:?}", other.name()),
402 }
403
404 match parse_single(buffers::authentication_sasl_final())? {
405 BackendMessage::Authentication(AuthenticationMessage::SaslFinal(msg)) => {
406 assert_eq!(msg.length, buffers::authentication_sasl_final().len() - 1);
407 assert_eq!(msg.data, "data");
408 }
409 other => panic!("unexpected message: {:?}", other.name()),
410 }

Callers

nothing calls this directly

Calls 7

parse_singleFunction · 0.85
authentication_okFunction · 0.85
authentication_saslFunction · 0.85

Tested by

no test coverage detected