bitwarden_test/api.rs
1use bitwarden_api_api::Configuration;
2
3/// Helper for testing the Bitwarden API using wiremock.
4///
5/// Warning: when using `Mock::expected` ensure `server` is not dropped before the test completes,
6pub async fn start_api_mock(mocks: Vec<wiremock::Mock>) -> (wiremock::MockServer, Configuration) {
7 let server = wiremock::MockServer::start().await;
8
9 for mock in mocks {
10 server.register(mock).await;
11 }
12
13 let config = Configuration {
14 base_path: server.uri(),
15 user_agent: Some("test-agent".to_string()),
16 client: reqwest::Client::new().into(),
17 oauth_access_token: None,
18 };
19
20 (server, config)
21}