2021-04-14 17:32:15 +00:00
|
|
|
use std::time::Duration;
|
|
|
|
|
2021-04-02 12:44:42 +00:00
|
|
|
use librespot_core::authentication::Credentials;
|
|
|
|
use librespot_core::config::SessionConfig;
|
|
|
|
use librespot_core::session::Session;
|
2021-01-21 20:56:23 +00:00
|
|
|
|
2021-04-14 17:32:15 +00:00
|
|
|
use tokio::time::timeout;
|
|
|
|
|
2021-04-02 12:44:42 +00:00
|
|
|
#[tokio::test]
|
|
|
|
async fn test_connection() {
|
2021-04-14 17:32:15 +00:00
|
|
|
timeout(Duration::from_secs(30), async {
|
|
|
|
let result = Session::connect(
|
|
|
|
SessionConfig::default(),
|
|
|
|
Credentials::with_password("test", "test"),
|
|
|
|
None,
|
|
|
|
)
|
|
|
|
.await;
|
2021-01-21 20:56:23 +00:00
|
|
|
|
2021-04-14 17:32:15 +00:00
|
|
|
match result {
|
|
|
|
Ok(_) => panic!("Authentication succeeded despite of bad credentials."),
|
|
|
|
Err(e) => assert_eq!(e.to_string(), "Login failed with reason: Bad credentials"),
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2021-04-02 12:44:42 +00:00
|
|
|
}
|