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
.
Sourcepub fn with_ldif_file(self, source: impl Into<CopyDataSource>) -> Self
pub fn with_ldif_file(self, source: impl Into<CopyDataSource>) -> Self
Sets a custom ldif file (content) which should be used.
Default: []
Sourcepub fn with_tls(
self,
cert: impl Into<CopyDataSource>,
key: impl Into<CopyDataSource>,
) -> Self
pub fn with_tls( self, cert: impl Into<CopyDataSource>, key: impl Into<CopyDataSource>, ) -> Self
Set all necessary certificate artifacts to build up a secure communication.
Default: []
Sourcepub fn with_cert_ca(self, ca: impl Into<CopyDataSource>) -> Self
pub fn with_cert_ca(self, ca: impl Into<CopyDataSource>) -> Self
Sets the root certificate used for signing the tls certificate.
Default: []
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 copy_to_sources(&self) -> impl IntoIterator<Item = &CopyToContainer>
fn copy_to_sources(&self) -> impl IntoIterator<Item = &CopyToContainer>
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>
Source§fn exec_before_ready(
&self,
cs: ContainerState,
) -> Result<Vec<ExecCommand>, TestcontainersError>
fn exec_before_ready( &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§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_label(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> ContainerRequest<I>
fn with_label( self, key: impl Into<String>, value: impl Into<String>, ) -> ContainerRequest<I>
Source§fn with_labels(
self,
labels: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>,
) -> ContainerRequest<I>
fn with_labels( self, labels: impl IntoIterator<Item = (impl Into<String>, 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_copy_to(
self,
target: impl Into<String>,
source: impl Into<CopyDataSource>,
) -> ContainerRequest<I>
fn with_copy_to( self, target: impl Into<String>, source: impl Into<CopyDataSource>, ) -> 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_cap_add(self, capability: impl Into<String>) -> ContainerRequest<I>
fn with_cap_add(self, capability: impl Into<String>) -> ContainerRequest<I>
Source§fn with_cap_drop(self, capability: impl Into<String>) -> ContainerRequest<I>
fn with_cap_drop(self, capability: impl Into<String>) -> 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§fn with_user(self, user: impl Into<String>) -> ContainerRequest<I>
fn with_user(self, user: impl Into<String>) -> ContainerRequest<I>
Source§fn with_readonly_rootfs(self, readonly_rootfs: bool) -> ContainerRequest<I>
fn with_readonly_rootfs(self, readonly_rootfs: bool) -> ContainerRequest<I>
Source§fn with_security_opt(
self,
security_opt: impl Into<String>,
) -> ContainerRequest<I>
fn with_security_opt( self, security_opt: impl Into<String>, ) -> 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> 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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
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
.