diff --git a/Cargo.lock b/Cargo.lock index 8375d1e47..274e5ad3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1073,7 +1073,7 @@ checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "cli" -version = "0.4.1" +version = "0.5.0" dependencies = [ "anyhow", "clap", @@ -4256,7 +4256,7 @@ dependencies = [ [[package]] name = "server" -version = "0.4.1" +version = "0.4.2" dependencies = [ "anyhow", "async-stream", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 95640168f..f531ad3d5 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cli" -version = "0.4.1" +version = "0.5.0" edition = "2021" authors = ["bartosz.ciesla@gmail.com"] repository = "https://github.com/iggy-rs/iggy" diff --git a/integration/tests/cli/common/mod.rs b/integration/tests/cli/common/mod.rs index 91b80e900..cd94ea508 100644 --- a/integration/tests/cli/common/mod.rs +++ b/integration/tests/cli/common/mod.rs @@ -215,8 +215,8 @@ impl IggyCmdTest { test_case.verify_command(assert); } - pub(crate) fn get_sever_ip_address(&self) -> Option { - self.server.get_server_ip_addr() + pub(crate) fn get_tcp_server_address(&self) -> Option { + self.server.get_raw_tcp_addr() } } diff --git a/integration/tests/cli/personal_access_token/test_pat_login_options.rs b/integration/tests/cli/personal_access_token/test_pat_login_options.rs index d4c564123..b01ae3a34 100644 --- a/integration/tests/cli/personal_access_token/test_pat_login_options.rs +++ b/integration/tests/cli/personal_access_token/test_pat_login_options.rs @@ -8,7 +8,7 @@ use predicates::str::{contains, starts_with}; use serial_test::parallel; use std::fmt::{Display, Formatter, Result}; -const IGGY_SERVICE: &str = "iggy:127.0.0.1"; +const IGGY_SERVICE: &str = "iggy"; #[derive(Debug)] enum UsingToken { @@ -34,12 +34,16 @@ struct TestLoginOptions { } impl TestLoginOptions { - fn new(token_name: String, using_token: UsingToken) -> Self { + fn new(token_name: String, using_token: UsingToken, server_address: String) -> Self { Self { token_name: token_name.clone(), token_value: None, using_token, - keyring: Entry::new(IGGY_SERVICE, &token_name).unwrap_or_else(|_| { + keyring: Entry::new( + format!("{IGGY_SERVICE}:{server_address}").as_str(), + &token_name, + ) + .unwrap_or_else(|_| { panic!( "Failed to get keyring service data for {} service and {} token name", IGGY_SERVICE, token_name @@ -101,16 +105,21 @@ pub async fn should_be_successful() { let mut iggy_cmd_test = IggyCmdTest::default(); iggy_cmd_test.setup().await; + let server_address = iggy_cmd_test.get_tcp_server_address(); + assert!(server_address.is_some()); + let server_address = server_address.unwrap(); iggy_cmd_test .execute_test(TestLoginOptions::new( String::from("sample-token"), UsingToken::Value, + server_address.clone(), )) .await; iggy_cmd_test .execute_test(TestLoginOptions::new( String::from("access-token"), UsingToken::Name, + server_address, )) .await; } diff --git a/integration/tests/cli/system/test_cli_session_scenario.rs b/integration/tests/cli/system/test_cli_session_scenario.rs index fa6575532..84f678797 100644 --- a/integration/tests/cli/system/test_cli_session_scenario.rs +++ b/integration/tests/cli/system/test_cli_session_scenario.rs @@ -10,7 +10,7 @@ pub async fn should_be_successful() { let mut iggy_cmd_test = IggyCmdTest::default(); iggy_cmd_test.setup().await; - let server_address = iggy_cmd_test.get_sever_ip_address(); + let server_address = iggy_cmd_test.get_tcp_server_address(); assert!(server_address.is_some()); let server_address = server_address.unwrap(); @@ -72,7 +72,7 @@ pub async fn should_be_successful() { iggy_cmd_test .execute_test(TestMeCmd::new( Protocol::Tcp, - Scenario::FailureDueToSessionTimeout, + Scenario::FailureDueToSessionTimeout(server_address), )) .await; } diff --git a/integration/tests/cli/system/test_me_command.rs b/integration/tests/cli/system/test_me_command.rs index d339d92fb..b8b2bd7d2 100644 --- a/integration/tests/cli/system/test_me_command.rs +++ b/integration/tests/cli/system/test_me_command.rs @@ -20,7 +20,7 @@ pub(super) enum Scenario { SuccessWithCredentials, SuccessWithoutCredentials, FailureWithoutCredentials, - FailureDueToSessionTimeout, + FailureDueToSessionTimeout(String), } impl Protocol { @@ -63,7 +63,7 @@ impl IggyCmdTestCase for TestMeCmd { match &self.scenario { Scenario::SuccessWithCredentials => command.with_env_credentials(), Scenario::FailureWithoutCredentials => command.disable_backtrace(), - Scenario::FailureDueToSessionTimeout => command.disable_backtrace(), + Scenario::FailureDueToSessionTimeout(_) => command.disable_backtrace(), _ => command, } } @@ -81,8 +81,8 @@ impl IggyCmdTestCase for TestMeCmd { .failure() .stderr(diff("Error: CommandError(Iggy command line tool error\n\nCaused by:\n Missing iggy server credentials)\n")); } - Scenario::FailureDueToSessionTimeout => { - command_state.failure().stderr(diff("Error: CommandError(Login session expired for Iggy server: 127.0.0.1, please login again or use other authentication method)\n")); + Scenario::FailureDueToSessionTimeout(server_address) => { + command_state.failure().stderr(diff(format!("Error: CommandError(Login session expired for Iggy server: {server_address}, please login again or use other authentication method)\n"))); } } } diff --git a/sdk/src/args.rs b/sdk/src/args.rs index 228d7b845..62d59f1d2 100644 --- a/sdk/src/args.rs +++ b/sdk/src/args.rs @@ -280,18 +280,14 @@ const TCP_TRANSPORT: &str = "tcp"; impl Args { pub fn get_server_address(&self) -> Option { match self.transport.as_str() { - QUIC_TRANSPORT => Some(self.quic_server_address.split(':').next().unwrap().into()), + QUIC_TRANSPORT => Some(self.quic_server_address.replace("localhost", "127.0.0.1")), HTTP_TRANSPORT => Some( self.http_api_url .clone() .replace("http://", "") - .replace("localhost", "127.0.0.1") - .split(':') - .next() - .unwrap() - .into(), + .replace("localhost", "127.0.0.1"), ), - TCP_TRANSPORT => Some(self.tcp_server_address.split(':').next().unwrap().into()), + TCP_TRANSPORT => Some(self.tcp_server_address.replace("localhost", "127.0.0.1")), _ => None, } } diff --git a/server/Cargo.toml b/server/Cargo.toml index 3a16ccf41..a04ecaaeb 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "server" -version = "0.4.1" +version = "0.4.2" edition = "2021" build = "src/build.rs"