Skip to content

Commit 58f7f0b

Browse files
committed
refactor: replace SSH fields in Environment with SshCredentials type
- Replace individual SSH fields (ssh_username, ssh_private_key_path, ssh_public_key_path) with single ssh_credentials field - Update Environment constructor to accept SshCredentials instead of individual parameters - Add ssh_credentials() accessor method for direct access to SSH credentials - Update all SSH-related accessor methods to delegate to ssh_credentials fields - Add required traits (Debug, Serialize, Deserialize) to SshCredentials struct - Update all tests and documentation examples to use new constructor pattern - Update E2E test binaries to use new SshCredentials pattern This refactoring improves encapsulation by grouping SSH-related configuration into a cohesive type that can be reused across the codebase.
1 parent edf82f3 commit 58f7f0b

File tree

7 files changed

+90
-97
lines changed

7 files changed

+90
-97
lines changed

src/bin/e2e_config_tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use torrust_tracker_deploy::e2e::tasks::{
5858
run_configuration_validation::run_configuration_validation,
5959
};
6060
use torrust_tracker_deploy::logging::{self, LogFormat};
61-
use torrust_tracker_deploy::shared::Username;
61+
use torrust_tracker_deploy::shared::{ssh::SshCredentials, Username};
6262

6363
#[derive(Parser)]
6464
#[command(name = "e2e-config-tests")]
@@ -114,14 +114,14 @@ pub async fn main() -> Result<()> {
114114
let ssh_private_key_path = project_root.join("fixtures/testing_rsa");
115115
let ssh_public_key_path = project_root.join("fixtures/testing_rsa.pub");
116116
let ssh_user = Username::new("torrust").expect("Valid hardcoded username");
117-
118-
let environment = Environment::new(
119-
env_name,
120-
ssh_user.clone(),
117+
let ssh_credentials = SshCredentials::new(
121118
ssh_private_key_path.clone(),
122119
ssh_public_key_path.clone(),
120+
ssh_user.clone(),
123121
);
124122

123+
let environment = Environment::new(env_name, ssh_credentials);
124+
125125
// Create and initialize TestContext
126126
let test_context =
127127
TestContext::from_environment(false, environment, TestContextType::Container)?.init()?;

src/bin/e2e_provision_tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use torrust_tracker_deploy::e2e::tasks::virtual_machine::{
5050
run_provision_command::run_provision_command,
5151
};
5252
use torrust_tracker_deploy::logging::{self, LogFormat};
53-
use torrust_tracker_deploy::shared::Username;
53+
use torrust_tracker_deploy::shared::{ssh::SshCredentials, Username};
5454

5555
#[derive(Parser)]
5656
#[command(name = "e2e-provision-tests")]
@@ -115,14 +115,14 @@ pub async fn main() -> Result<()> {
115115
let ssh_private_key_path = project_root.join("fixtures/testing_rsa");
116116
let ssh_public_key_path = project_root.join("fixtures/testing_rsa.pub");
117117
let ssh_user = Username::new("torrust").expect("Valid hardcoded username");
118-
119-
let environment = Environment::new(
120-
environment_name,
121-
ssh_user.clone(),
118+
let ssh_credentials = SshCredentials::new(
122119
ssh_private_key_path.clone(),
123120
ssh_public_key_path.clone(),
121+
ssh_user.clone(),
124122
);
125123

124+
let environment = Environment::new(environment_name, ssh_credentials);
125+
126126
let test_context =
127127
TestContext::from_environment(cli.keep, environment, TestContextType::VirtualMachine)?
128128
.init()?;

src/bin/e2e_tests_full.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use torrust_tracker_deploy::e2e::tasks::{
6363
},
6464
};
6565
use torrust_tracker_deploy::logging::{self, LogFormat};
66-
use torrust_tracker_deploy::shared::Username;
66+
use torrust_tracker_deploy::shared::{ssh::SshCredentials, Username};
6767

6868
#[derive(Parser)]
6969
#[command(name = "e2e-tests")]
@@ -123,14 +123,14 @@ pub async fn main() -> Result<()> {
123123
let ssh_private_key_path = project_root.join("fixtures/testing_rsa");
124124
let ssh_public_key_path = project_root.join("fixtures/testing_rsa.pub");
125125
let ssh_user = Username::new("torrust").expect("Valid hardcoded username");
126-
127-
let environment = Environment::new(
128-
environment_name,
129-
ssh_user.clone(),
126+
let ssh_credentials = SshCredentials::new(
130127
ssh_private_key_path.clone(),
131128
ssh_public_key_path.clone(),
129+
ssh_user.clone(),
132130
);
133131

132+
let environment = Environment::new(environment_name, ssh_credentials);
133+
134134
let test_context =
135135
TestContext::from_environment(cli.keep, environment, TestContextType::VirtualMachine)?
136136
.init()?;

0 commit comments

Comments
 (0)