Struct testcontainers_modules::openldap::OpenLDAP
source · pub struct OpenLDAP { /* private fields */ }openldap only.Expand description
Module to work with OpenLDAP inside of tests.
Starts an instance of OpenLDAP.
This module is based on the bitnami/openldap docker image.
See the OpenLDAP configuration guide for further configuration options.
§Example
use testcontainers_modules::{openldap, testcontainers::runners::SyncRunner};
let openldap_instance = openldap::OpenLDAP::default().start().unwrap();
let connection_string = format!(
"ldap://{}:{}",
openldap_instance.get_host().unwrap(),
openldap_instance.get_host_port_ipv4(1389).unwrap(),
);
let mut conn = ldap3::LdapConn::new(&connection_string).unwrap();
let ldap3::SearchResult(rs, _) = conn
.search(
"ou=users,dc=example,dc=org",
ldap3::Scope::Subtree,
"(cn=ma*)",
vec!["cn"],
)
.unwrap();
let results: Vec<_> = rs.into_iter().map(ldap3::SearchEntry::construct).collect();
assert_eq!(results.len(), 0);Implementations§
source§impl OpenLDAP
impl OpenLDAP
sourcepub fn with_base_dn(self, base_dn: impl ToString) -> Self
pub fn with_base_dn(self, base_dn: impl ToString) -> Self
Sets the LDAP baseDN (or suffix) of the LDAP tree.
Default: "dc=example,dc=org"
sourcepub fn with_admin(
self,
username: impl ToString,
password: impl ToString,
) -> Self
pub fn with_admin( self, username: impl ToString, password: impl ToString, ) -> Self
Sets an admin account (there can only be one)
Default username: "admin" => dn: cn=admin,dc=example,dc=org if using the default base_dn instead of overriding via OpenLDAP::with_base_dn.
Default password: "adminpassword"
sourcepub fn with_config_admin(
self,
username: impl ToString,
password: impl ToString,
) -> Self
pub fn with_config_admin( self, username: impl ToString, password: impl ToString, ) -> Self
Sets a configuration admin user (there can only be one)
Default: None
sourcepub fn with_accesslog_settings(self, _: AccesslogSettings) -> Self
pub fn with_accesslog_settings(self, _: AccesslogSettings) -> Self
Sets an accesslog admin user up (there can only be one)
Configuring the admin for the access log can be done via OpenLDAP::with_accesslog_admin
Default: None
sourcepub fn with_accesslog_admin(
self,
username: impl ToString,
password: impl ToString,
) -> Self
pub fn with_accesslog_admin( self, username: impl ToString, password: impl ToString, ) -> Self
Activates the access log and sets the admin user up (there can only be one)
Configuring how OpenLDAP logs can be done via OpenLDAP::with_accesslog_settings
Default: None
sourcepub fn with_user(self, username: impl ToString, password: impl ToString) -> Self
pub fn with_user(self, username: impl ToString, password: impl ToString) -> Self
Adds a user (can be called multiple times)
Default: []
Alternatively, users can be added via OpenLDAP::with_users.
sourcepub fn with_users<Username: ToString, Password: ToString>(
self,
user_password: impl IntoIterator<Item = (Username, Password)>,
) -> Self
pub fn with_users<Username: ToString, Password: ToString>( self, user_password: impl IntoIterator<Item = (Username, Password)>, ) -> Self
Add users (can be called multiple times)
Default: []
Alternatively, users can be added via OpenLDAP::with_user.
sourcepub fn with_users_dc(self, user_dc: impl ToString) -> Self
pub fn with_users_dc(self, user_dc: impl ToString) -> Self
Sets the users’ dc
Default: "users"
sourcepub fn with_users_group(self, users_group: impl ToString) -> Self
pub fn with_users_group(self, users_group: impl ToString) -> Self
Sets the users’ group
Default: "readers"
sourcepub fn with_extra_schemas<S: ToString>(
self,
extra_schemas: impl IntoIterator<Item = S>,
) -> Self
pub fn with_extra_schemas<S: ToString>( self, extra_schemas: impl IntoIterator<Item = S>, ) -> Self
Extra schemas to add, among OpenLDAP’s distributed schemas.
Default: ["cosine", "inetorgperson", "nis"]
sourcepub fn with_allow_anon_binding(self, allow_anon_binding: bool) -> Self
pub fn with_allow_anon_binding(self, allow_anon_binding: bool) -> Self
Allow anonymous bindings to the LDAP server.
Default: true
sourcepub fn with_ldap_password_hash(self, password_hash: PasswordHash) -> Self
pub fn with_ldap_password_hash(self, password_hash: PasswordHash) -> Self
Set hash to be used in generation of user passwords.
Default: PasswordHash::SSHA.
Trait Implementations§
source§impl Image for OpenLDAP
impl Image for OpenLDAP
source§fn tag(&self) -> &str
fn tag(&self) -> &str
source§fn ready_conditions(&self) -> Vec<WaitFor>
fn ready_conditions(&self) -> Vec<WaitFor>
source§fn env_vars(
&self,
) -> impl IntoIterator<Item = (impl Into<Cow<'_, str>>, impl Into<Cow<'_, str>>)>
fn env_vars( &self, ) -> impl IntoIterator<Item = (impl Into<Cow<'_, str>>, impl Into<Cow<'_, str>>)>
source§fn expose_ports(&self) -> &[ContainerPort]
fn expose_ports(&self) -> &[ContainerPort]
source§fn mounts(&self) -> impl IntoIterator<Item = &Mount>
fn mounts(&self) -> impl IntoIterator<Item = &Mount>
source§fn entrypoint(&self) -> Option<&str>
fn entrypoint(&self) -> Option<&str>
source§fn cmd(&self) -> impl IntoIterator<Item = impl Into<Cow<'_, str>>>
fn cmd(&self) -> impl IntoIterator<Item = impl Into<Cow<'_, str>>>
CMD this image needs to be created with.source§fn exec_after_start(
&self,
cs: ContainerState,
) -> Result<Vec<ExecCommand>, TestcontainersError>
fn exec_after_start( &self, cs: ContainerState, ) -> Result<Vec<ExecCommand>, TestcontainersError>
Auto Trait Implementations§
impl Freeze for OpenLDAP
impl RefUnwindSafe for OpenLDAP
impl Send for OpenLDAP
impl Sync for OpenLDAP
impl Unpin for OpenLDAP
impl UnwindSafe for OpenLDAP
Blanket Implementations§
source§impl<T, I> AsyncRunner<I> for T
impl<T, I> AsyncRunner<I> for T
source§fn start<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<ContainerAsync<I>, TestcontainersError>> + Send + 'async_trait>>where
T: 'async_trait,
fn start<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<ContainerAsync<I>, TestcontainersError>> + Send + 'async_trait>>where
T: 'async_trait,
ContainerAsync.source§fn pull_image<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<ContainerRequest<I>, TestcontainersError>> + Send + 'async_trait>>where
T: 'async_trait,
fn pull_image<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<ContainerRequest<I>, TestcontainersError>> + Send + 'async_trait>>where
T: 'async_trait,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<RI, I> ImageExt<I> for RI
impl<RI, I> ImageExt<I> for RI
source§fn with_cmd(
self,
cmd: impl IntoIterator<Item = impl Into<String>>,
) -> ContainerRequest<I>
fn with_cmd( self, cmd: impl IntoIterator<Item = impl Into<String>>, ) -> ContainerRequest<I>
source§fn with_name(self, name: impl Into<String>) -> ContainerRequest<I>
fn with_name(self, name: impl Into<String>) -> ContainerRequest<I>
{domain}/{owner}/{image}).
Can be used to specify a custom registry or owner.source§fn with_tag(self, tag: impl Into<String>) -> ContainerRequest<I>
fn with_tag(self, tag: impl Into<String>) -> ContainerRequest<I>
source§fn with_container_name(self, name: impl Into<String>) -> ContainerRequest<I>
fn with_container_name(self, name: impl Into<String>) -> ContainerRequest<I>
source§fn with_network(self, network: impl Into<String>) -> ContainerRequest<I>
fn with_network(self, network: impl Into<String>) -> ContainerRequest<I>
source§fn with_env_var(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> ContainerRequest<I>
fn with_env_var( self, name: impl Into<String>, value: impl Into<String>, ) -> ContainerRequest<I>
source§fn with_host(
self,
key: impl Into<String>,
value: impl Into<Host>,
) -> ContainerRequest<I>
fn with_host( self, key: impl Into<String>, value: impl Into<Host>, ) -> ContainerRequest<I>
source§fn with_mount(self, mount: impl Into<Mount>) -> ContainerRequest<I>
fn with_mount(self, mount: impl Into<Mount>) -> ContainerRequest<I>
source§fn with_mapped_port(
self,
host_port: u16,
container_port: ContainerPort,
) -> ContainerRequest<I>
fn with_mapped_port( self, host_port: u16, container_port: ContainerPort, ) -> ContainerRequest<I>
source§fn with_ulimit(
self,
name: &str,
soft: i64,
hard: Option<i64>,
) -> ContainerRequest<I>
fn with_ulimit( self, name: &str, soft: i64, hard: Option<i64>, ) -> ContainerRequest<I>
source§fn with_privileged(self, privileged: bool) -> ContainerRequest<I>
fn with_privileged(self, privileged: bool) -> ContainerRequest<I>
source§fn with_cgroupns_mode(self, cgroupns_mode: CgroupnsMode) -> ContainerRequest<I>
fn with_cgroupns_mode(self, cgroupns_mode: CgroupnsMode) -> ContainerRequest<I>
source§fn with_userns_mode(self, userns_mode: &str) -> ContainerRequest<I>
fn with_userns_mode(self, userns_mode: &str) -> ContainerRequest<I>
source§fn with_shm_size(self, bytes: u64) -> ContainerRequest<I>
fn with_shm_size(self, bytes: u64) -> ContainerRequest<I>
source§fn with_startup_timeout(self, timeout: Duration) -> ContainerRequest<I>
fn with_startup_timeout(self, timeout: Duration) -> ContainerRequest<I>
source§fn with_working_dir(self, working_dir: impl Into<String>) -> ContainerRequest<I>
fn with_working_dir(self, working_dir: impl Into<String>) -> ContainerRequest<I>
/.source§fn with_log_consumer(
self,
log_consumer: impl LogConsumer + 'static,
) -> ContainerRequest<I>
fn with_log_consumer( self, log_consumer: impl LogConsumer + 'static, ) -> ContainerRequest<I>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
source§impl<T, I> SyncRunner<I> for T
impl<T, I> SyncRunner<I> for T
source§fn start(self) -> Result<Container<I>, TestcontainersError>
fn start(self) -> Result<Container<I>, TestcontainersError>
Container.