Skip to content

Commit ccb7966

Browse files
Fix unresolved merge conflicts (#1076)
1 parent d38c513 commit ccb7966

File tree

2 files changed

+55
-84
lines changed

2 files changed

+55
-84
lines changed

src/test/spec/oidc.rs

Lines changed: 55 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use bson::doc;
2-
31
use crate::{
42
client::{
53
auth::{oidc, AuthMechanism, Credential},
@@ -107,7 +105,7 @@ async fn machine_1_1_callback_is_called() -> anyhow::Result<()> {
107105
client
108106
.database("test")
109107
.collection::<Document>("test")
110-
.find_one(None, None)
108+
.find_one(doc! {})
111109
.await?;
112110
assert_eq!(1, *(*call_count).lock().await);
113111
Ok(())
@@ -146,7 +144,7 @@ async fn machine_1_2_callback_is_called_only_once_for_multiple_connections() ->
146144
client
147145
.database("test")
148146
.collection::<Document>("test")
149-
.find_one(None, None)
147+
.find_one(doc! {})
150148
.await
151149
.unwrap();
152150
}
@@ -227,7 +225,7 @@ async fn machine_2_3_oidc_callback_return_missing_data() -> anyhow::Result<()> {
227225
let res = client
228226
.database("test")
229227
.collection::<Document>("test")
230-
.find_one(None, None)
228+
.find_one(doc! {})
231229
.await;
232230

233231
assert!(res.is_err());
@@ -270,7 +268,7 @@ async fn machine_2_4_invalid_client_configuration_with_callback() -> anyhow::Res
270268
let res = client
271269
.database("test")
272270
.collection::<Document>("test")
273-
.find_one(None, None)
271+
.find_one(doc! {})
274272
.await;
275273

276274
assert!(res.is_err());
@@ -323,7 +321,7 @@ async fn machine_3_1_failure_with_cached_tokens_fetch_a_new_token_and_retry_auth
323321
client
324322
.database("test")
325323
.collection::<Document>("test")
326-
.find_one(None, None)
324+
.find_one(doc! {})
327325
.await?;
328326
assert_eq!(1, *(*call_count).lock().await);
329327
Ok(())
@@ -357,7 +355,7 @@ async fn machine_3_2_auth_failures_without_cached_tokens_returns_an_error() -> a
357355
let res = client
358356
.database("test")
359357
.collection::<Document>("test")
360-
.find_one(None, None)
358+
.find_one(doc! {})
361359
.await;
362360

363361
assert!(res.is_err());
@@ -409,7 +407,7 @@ async fn machine_4_reauthentication() -> anyhow::Result<()> {
409407
client
410408
.database("test")
411409
.collection::<Document>("test")
412-
.find_one(None, None)
410+
.find_one(doc! {})
413411
.await?;
414412
assert_eq!(2, *(*call_count).lock().await);
415413
Ok(())
@@ -479,7 +477,7 @@ async fn human_1_2_single_principal_explicit_username() -> anyhow::Result<()> {
479477
client
480478
.database("test")
481479
.collection::<Document>("test")
482-
.find_one(None, None)
480+
.find_one(doc! {})
483481
.await?;
484482
assert_eq!(1, *(*call_count).lock().await);
485483
Ok(())
@@ -514,7 +512,7 @@ async fn human_1_3_multiple_principal_user_1() -> anyhow::Result<()> {
514512
client
515513
.database("test")
516514
.collection::<Document>("test")
517-
.find_one(None, None)
515+
.find_one(doc! {})
518516
.await?;
519517
assert_eq!(1, *(*call_count).lock().await);
520518
Ok(())
@@ -549,7 +547,7 @@ async fn human_1_4_multiple_principal_user_2() -> anyhow::Result<()> {
549547
client
550548
.database("test")
551549
.collection::<Document>("test")
552-
.find_one(None, None)
550+
.find_one(doc! {})
553551
.await?;
554552
assert_eq!(1, *(*call_count).lock().await);
555553
Ok(())
@@ -583,7 +581,7 @@ async fn human_1_5_multiple_principal_no_user() -> anyhow::Result<()> {
583581
let res = client
584582
.database("test")
585583
.collection::<Document>("test")
586-
.find_one(None, None)
584+
.find_one(doc! {})
587585
.await;
588586

589587
assert!(res.is_err());
@@ -628,7 +626,7 @@ async fn human_1_6_allowed_hosts_blocked() -> anyhow::Result<()> {
628626
let res = client
629627
.database("test")
630628
.collection::<Document>("test")
631-
.find_one(None, None)
629+
.find_one(doc! {})
632630
.await;
633631

634632
assert!(res.is_err());
@@ -669,7 +667,7 @@ async fn human_1_6_allowed_hosts_blocked() -> anyhow::Result<()> {
669667
let res = client
670668
.database("test")
671669
.collection::<Document>("test")
672-
.find_one(None, None)
670+
.find_one(doc! {})
673671
.await;
674672

675673
assert!(res.is_err());
@@ -716,7 +714,7 @@ async fn human_2_1_valid_callback_inputs() -> anyhow::Result<()> {
716714
client
717715
.database("test")
718716
.collection::<Document>("test")
719-
.find_one(None, None)
717+
.find_one(doc! {})
720718
.await?;
721719
assert_eq!(1, *(*call_count).lock().await);
722720
Ok(())
@@ -750,7 +748,7 @@ async fn human_2_2_callback_returns_missing_data() -> anyhow::Result<()> {
750748
let res = client
751749
.database("test")
752750
.collection::<Document>("test")
753-
.find_one(None, None)
751+
.find_one(doc! {})
754752
.await;
755753

756754
assert!(res.is_err());
@@ -825,7 +823,7 @@ async fn human_3_1_uses_speculative_authentication_if_there_is_a_cached_token()
825823
client
826824
.database("test")
827825
.collection::<Document>("test")
828-
.find_one(None, None)
826+
.find_one(doc! {})
829827
.await?;
830828

831829
// the callback should not have been called at all
@@ -874,7 +872,7 @@ async fn human_3_2_does_not_use_speculative_authentication_if_there_is_no_cached
874872
let res = client
875873
.database("test")
876874
.collection::<Document>("test")
877-
.find_one(None, None)
875+
.find_one(doc! {})
878876
.await;
879877

880878
assert!(res.is_err());
@@ -891,13 +889,8 @@ async fn human_3_2_does_not_use_speculative_authentication_if_there_is_no_cached
891889
async fn human_4_1_succeeds() -> anyhow::Result<()> {
892890
get_env_or_skip!("OIDC");
893891
use crate::{
894-
event::command::{
895-
CommandEvent,
896-
CommandFailedEvent,
897-
CommandStartedEvent,
898-
CommandSucceededEvent,
899-
},
900-
test::{Event, EventHandler},
892+
event::command::CommandEvent,
893+
test::{util::event_buffer::EventBuffer, Event},
901894
};
902895

903896
let admin_client = admin_client!();
@@ -924,15 +917,14 @@ async fn human_4_1_succeeds() -> anyhow::Result<()> {
924917
.build()
925918
.into();
926919

927-
let handler = Arc::new(EventHandler::new());
928-
let mut events = handler.subscribe();
929-
opts.command_event_handler = Some(handler.clone().into());
920+
let buffer = EventBuffer::new();
921+
opts.command_event_handler = Some(buffer.handler());
930922
let client = Client::with_options(opts)?;
931923

932924
client
933925
.database("test")
934926
.collection::<Document>("test")
935-
.find_one(None, None)
927+
.find_one(doc! {})
936928
.await?;
937929

938930
// Now set a failpoint for find with 391 error code
@@ -947,67 +939,47 @@ async fn human_4_1_succeeds() -> anyhow::Result<()> {
947939
client
948940
.database("test")
949941
.collection::<Document>("test")
950-
.find_one(None, None)
942+
.find_one(doc! {})
951943
.await?;
952944

953945
assert_eq!(2, *(*call_count).lock().await);
954-
let events = events
955-
.collect_events(Duration::from_secs(1), |e| {
956-
if let Some(e) = e.as_command_event() {
957-
e.command_name() == "find"
958-
} else {
959-
false
960-
}
961-
})
962-
.await;
963-
// assert the first command is find
946+
let find_events = buffer.filter_map(|e: &Event| match e.as_command_event() {
947+
Some(command_event) if command_event.command_name() == "find" => {
948+
Some(command_event.clone())
949+
}
950+
_ => None,
951+
});
952+
// assert the first find started
964953
assert!(matches!(
965-
events.first().unwrap(),
966-
Event::Command(CommandEvent::Started(CommandStartedEvent {
967-
command_name,
968-
..
969-
})) if command_name.as_str() == "find"
954+
find_events.first().unwrap(),
955+
CommandEvent::Started(_)
970956
));
971-
// assert the first command is find and succeeded
957+
// assert the first find succeeded
972958
assert!(matches!(
973-
events.get(1).unwrap(),
974-
Event::Command(CommandEvent::Succeeded(CommandSucceededEvent {
975-
command_name,
976-
..
977-
})) if command_name.as_str() == "find"
959+
find_events.get(1).unwrap(),
960+
CommandEvent::Succeeded(_)
978961
));
979-
// assert the second command is find
962+
// assert the second find started
980963
assert!(matches!(
981-
events.get(2).unwrap(),
982-
Event::Command(CommandEvent::Started(CommandStartedEvent {
983-
command_name,
984-
..
985-
})) if command_name.as_str() == "find"
964+
find_events.get(2).unwrap(),
965+
CommandEvent::Started(_)
986966
));
987-
// assert the second command is find and failed
967+
// assert the second find failed
988968
assert!(matches!(
989-
events.get(3).unwrap(),
990-
Event::Command(CommandEvent::Failed(CommandFailedEvent {
991-
command_name,
992-
..
993-
})) if command_name.as_str() == "find"
969+
find_events.get(3).unwrap(),
970+
CommandEvent::Failed(_)
994971
));
995-
// assert the third command is find
972+
// assert the first find started
996973
assert!(matches!(
997-
events.get(4).unwrap(),
998-
Event::Command(CommandEvent::Started(CommandStartedEvent {
999-
command_name,
1000-
..
1001-
})) if command_name.as_str() == "find"
974+
find_events.get(4).unwrap(),
975+
CommandEvent::Started(_)
1002976
));
1003-
// assert the third command is find and succeeded
977+
// assert the third find succeeded
1004978
assert!(matches!(
1005-
events.get(5).unwrap(),
1006-
Event::Command(CommandEvent::Succeeded(CommandSucceededEvent {
1007-
command_name,
1008-
..
1009-
})) if command_name.as_str() == "find"
979+
find_events.get(5).unwrap(),
980+
CommandEvent::Succeeded(_)
1010981
));
982+
1011983
Ok(())
1012984
}
1013985

@@ -1042,7 +1014,7 @@ async fn human_4_2_succeeds_no_refresh() -> anyhow::Result<()> {
10421014
client
10431015
.database("test")
10441016
.collection::<Document>("test")
1045-
.find_one(None, None)
1017+
.find_one(doc! {})
10461018
.await?;
10471019

10481020
// Now set a failpoint for find with 391 error code
@@ -1057,7 +1029,7 @@ async fn human_4_2_succeeds_no_refresh() -> anyhow::Result<()> {
10571029
client
10581030
.database("test")
10591031
.collection::<Document>("test")
1060-
.find_one(None, None)
1032+
.find_one(doc! {})
10611033
.await?;
10621034

10631035
assert_eq!(2, *(*call_count).lock().await);
@@ -1095,7 +1067,7 @@ async fn human_4_3_succeeds_after_refresh_fails() -> anyhow::Result<()> {
10951067
client
10961068
.database("test")
10971069
.collection::<Document>("test")
1098-
.find_one(None, None)
1070+
.find_one(doc! {})
10991071
.await?;
11001072

11011073
assert_eq!(1, *(*call_count).lock().await);
@@ -1112,7 +1084,7 @@ async fn human_4_3_succeeds_after_refresh_fails() -> anyhow::Result<()> {
11121084
client
11131085
.database("test")
11141086
.collection::<Document>("test")
1115-
.find_one(None, None)
1087+
.find_one(doc! {})
11161088
.await?;
11171089

11181090
assert_eq!(3, *(*call_count).lock().await);
@@ -1150,7 +1122,7 @@ async fn human_4_4_fails() -> anyhow::Result<()> {
11501122
client
11511123
.database("test")
11521124
.collection::<Document>("test")
1153-
.find_one(None, None)
1125+
.find_one(doc! {})
11541126
.await?;
11551127

11561128
assert_eq!(1, *(*call_count).lock().await);
@@ -1167,7 +1139,7 @@ async fn human_4_4_fails() -> anyhow::Result<()> {
11671139
let res = client
11681140
.database("test")
11691141
.collection::<Document>("test")
1170-
.find_one(None, None)
1142+
.find_one(doc! {})
11711143
.await;
11721144

11731145
assert!(res.is_err());
@@ -1229,7 +1201,7 @@ async fn human_4_5_refresh_token_flow() -> anyhow::Result<()> {
12291201
client
12301202
.database("test")
12311203
.collection::<Document>("test")
1232-
.find_one(None, None)
1204+
.find_one(doc! {})
12331205
.await?;
12341206

12351207
// the callback should have been called once

src/test/util/event_buffer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ impl<T> EventBuffer<T> {
6060
}
6161
}
6262

63-
#[allow(unused)]
6463
pub(crate) fn filter_map<R>(&self, f: impl Fn(&T) -> Option<R>) -> Vec<R> {
6564
self.inner
6665
.events

0 commit comments

Comments
 (0)