use wiremock::{
Mock, MockServer, ResponseTemplate,
matchers::{header, method, path_regex},
};
use crate::{event_factory::EventFactory, test_json};
pub async fn mock_encryption_state(server: &MockServer, is_encrypted: bool) {
let builder = Mock::given(method("GET"))
.and(path_regex(r"^/_matrix/client/r0/rooms/.*/state/m.*room.*encryption.?"))
.and(header("authorization", "Bearer 1234"));
if is_encrypted {
builder
.respond_with(
ResponseTemplate::new(200)
.set_body_json(EventFactory::new().room_encryption().into_content()),
)
.mount(server)
.await;
} else {
builder
.respond_with(ResponseTemplate::new(404).set_body_json(&*test_json::NOT_FOUND))
.mount(server)
.await;
}
}