Skip to main content

SshServerContainer

Trait SshServerContainer 

Source
pub trait SshServerContainer {
    // Required methods
    fn ssh_port(&self) -> u16;
    fn host_ip(&self) -> IpAddr;
    fn username(&self) -> &str;
    fn password(&self) -> &str;
}
Expand description

Common interface for SSH server containers (mock and real)

This trait defines the standard interface that all SSH server container implementations must provide. It enables polymorphic code that works with both mock and real containers.

§Example

use torrust_tracker_deployer_lib::testing::integration::ssh_server::{
    SshServerContainer, MockSshServerContainer, RealSshServerContainer
};

async fn test_with_container<C: SshServerContainer>(container: &C) {
    let port = container.ssh_port();
    let ip = container.host_ip();
    println!("SSH available at {}:{}", ip, port);
}

Required Methods§

Source

fn ssh_port(&self) -> u16

Get the SSH port mapped by the container

Returns the host port that maps to the container’s SSH port (22).

Source

fn host_ip(&self) -> IpAddr

Get the container’s host IP address

Returns the IP address to connect to the container from the host.

Source

fn username(&self) -> &str

Get the test username configured in the container

Source

fn password(&self) -> &str

Get the test password configured in the container

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§