Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add connection::Builder::auth_mechansim & deprecate connection::Builder::auth_mechansims #742

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions zbus/src/blocking/connection/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,15 @@ impl<'a> Builder<'a> {
Self(crate::connection::Builder::socket(socket))
}

/// Specify the mechanism to use during authentication.
pub fn auth_mechanism(self, auth_mechanism: AuthMechanism) -> Self {
Self(self.0.auth_mechanism(auth_mechanism))
}

/// Specify the mechanisms to use during authentication.
#[deprecated(since = "4.1.3", note = "Use `auth_mechanism` instead.")]
pub fn auth_mechanisms(self, auth_mechanisms: &[AuthMechanism]) -> Self {
#[allow(deprecated)]
Self(self.0.auth_mechanisms(auth_mechanisms))
}

Expand Down
7 changes: 7 additions & 0 deletions zbus/src/connection/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,14 @@ impl<'a> Builder<'a> {
Ok(builder)
}

/// Specify the mechanism to use during authentication.
pub fn auth_mechanism(self, auth_mechanism: AuthMechanism) -> Self {
#[allow(deprecated)]
self.auth_mechanisms(&[auth_mechanism])
}

/// Specify the mechanisms to use during authentication.
#[deprecated(since = "4.1.3", note = "Use `auth_mechanism` instead.")]
pub fn auth_mechanisms(mut self, auth_mechanisms: &[AuthMechanism]) -> Self {
self.auth_mechanisms = Some(VecDeque::from(auth_mechanisms.to_vec()));

Expand Down
10 changes: 5 additions & 5 deletions zbus/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ mod p2p_tests {
.server(guid)
.unwrap()
.p2p()
.auth_mechanisms(&[AuthMechanism::Anonymous]),
.auth_mechanism(AuthMechanism::Anonymous),
Builder::tcp_stream(p1).p2p(),
)
};
Expand All @@ -1489,7 +1489,7 @@ mod p2p_tests {
.server(guid)
.unwrap()
.p2p()
.auth_mechanisms(&[AuthMechanism::Anonymous]),
.auth_mechanism(AuthMechanism::Anonymous),
Builder::tcp_stream(p1).p2p(),
)
};
Expand Down Expand Up @@ -1568,7 +1568,7 @@ mod p2p_tests {
.server(guid)
.unwrap()
.p2p()
.auth_mechanisms(&[AuthMechanism::Anonymous])
.auth_mechanism(AuthMechanism::Anonymous)
.build(),
Builder::vsock_stream(client).p2p().build(),
)
Expand All @@ -1587,7 +1587,7 @@ mod p2p_tests {
.server(guid)
.unwrap()
.p2p()
.auth_mechanisms(&[AuthMechanism::Anonymous])
.auth_mechanism(AuthMechanism::Anonymous)
.build(),
Builder::vsock_stream(client).p2p().build(),
)
Expand Down Expand Up @@ -1655,7 +1655,7 @@ mod p2p_tests {
.server(guid)
.unwrap()
.p2p()
.auth_mechanisms(&[AuthMechanism::Cookie])
.auth_mechanism(AuthMechanism::Cookie)
.cookie_context(cookie_context)
.unwrap();
if let Some(cookie_id) = cookie_id {
Expand Down