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

Fix a bunch of clippy lints #183

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
10 changes: 5 additions & 5 deletions oxide-auth-actix/examples/actix-example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async fn index(
}
}

async fn start_browser() -> () {
async fn start_browser() {
let _ = thread::spawn(support::open_in_browser);
}

Expand Down Expand Up @@ -174,9 +174,9 @@ impl State {
}
}

pub fn with_solicitor<'a, S>(
&'a mut self, solicitor: S,
) -> impl Endpoint<OAuthRequest, Error = WebError> + 'a
pub fn with_solicitor<S>(
&mut self, solicitor: S,
) -> impl Endpoint<OAuthRequest, Error = WebError> + '_
where
S: OwnerSolicitor<OAuthRequest> + 'static,
{
Expand Down Expand Up @@ -213,7 +213,7 @@ where
OAuthResponse::ok()
.content_type("text/html")
.unwrap()
.body(&crate::support::consent_page_html("/authorize".into(), pre_grant)),
.body(&crate::support::consent_page_html("/authorize", pre_grant)),
)
});

Expand Down
11 changes: 4 additions & 7 deletions oxide-auth-actix/examples/actix-example/src/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod generic;

use std::collections::HashMap;

pub use self::generic::{consent_page_html, open_in_browser, Client, ClientConfig, ClientError};
pub use self::generic::{consent_page_html, open_in_browser, Client, ClientConfig};

use actix_web::{
App, dev,
Expand Down Expand Up @@ -51,8 +51,7 @@ async fn endpoint_impl(
};

let auth_handle = tokio::task::spawn_blocking(move || {
let res = state.authorize(&code);
res
state.authorize(&code)
});
let auth_result = auth_handle.await.unwrap();

Expand All @@ -64,8 +63,7 @@ async fn endpoint_impl(

async fn refresh(state: web::Data<Client>) -> impl Responder {
let refresh_handle = tokio::task::spawn_blocking(move || {
let res = state.refresh();
res
state.refresh()
});
let refresh_result = refresh_handle.await.unwrap();

Expand All @@ -79,8 +77,7 @@ async fn get_with_token(state: web::Data<Client>) -> impl Responder {
let html = state.as_html();

let protected_page_handle = tokio::task::spawn_blocking(move || {
let res = state.retrieve_protected_page();
res
state.retrieve_protected_page()
});
let protected_page_result = protected_page_handle.await.unwrap();

Expand Down
11 changes: 4 additions & 7 deletions oxide-auth-async/src/endpoint/client_credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ where
let mut json = ErrorDescription::new(error);
let mut response = self.endpoint.inner.response(
&mut request,
Template::new_unauthorized(None, Some(json.description())).into(),
Template::new_unauthorized(None, Some(json.description())),
)?;

response
Expand All @@ -199,10 +199,7 @@ where
Ok(token) => token,
};

let mut response = self
.endpoint
.inner
.response(&mut request, Template::new_ok().into())?;
let mut response = self.endpoint.inner.response(&mut request, Template::new_ok())?;
response
.body_json(&token.to_json())
.map_err(|err| self.endpoint.inner.web_error(err))?;
Expand All @@ -217,7 +214,7 @@ fn client_credentials_error<E: Endpoint<R>, R: WebRequest>(
ClientCredentialsError::Ignore => return Err(endpoint.error(OAuthError::DenySilently)),
ClientCredentialsError::Invalid(mut json) => {
let mut response =
endpoint.response(request, Template::new_bad(Some(json.description())).into())?;
endpoint.response(request, Template::new_bad(Some(json.description())))?;

response.client_error().map_err(|err| endpoint.web_error(err))?;
response
Expand All @@ -228,7 +225,7 @@ fn client_credentials_error<E: Endpoint<R>, R: WebRequest>(
ClientCredentialsError::Unauthorized(mut json, scheme) => {
let mut response = endpoint.response(
request,
Template::new_unauthorized(None, Some(json.description())).into(),
Template::new_unauthorized(None, Some(json.description())),
)?;

response
Expand Down
40 changes: 20 additions & 20 deletions oxide-auth-async/src/tests/access_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ fn access_valid_public() {
let valid_public = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("client_id", EXAMPLE_CLIENT_ID),
("code", &setup.authtoken),
Expand All @@ -242,7 +242,7 @@ fn access_valid_private() {
let valid_public = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("code", &setup.authtoken),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand Down Expand Up @@ -292,7 +292,7 @@ fn access_equivalent_url() {
setup.test_success(CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("client_id", CLIENT_ID),
("code", &authtoken),
Expand All @@ -308,7 +308,7 @@ fn access_equivalent_url() {
setup.test_success(CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("client_id", CLIENT_ID),
("code", &authtoken),
Expand All @@ -328,7 +328,7 @@ fn access_request_unknown_client() {
let unknown_client = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("code", &setup.authtoken),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand All @@ -352,7 +352,7 @@ fn access_request_wrong_authentication() {
let wrong_authentication = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("code", &setup.authtoken),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand All @@ -373,7 +373,7 @@ fn access_request_wrong_password() {
let wrong_password = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("code", &setup.authtoken),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand All @@ -397,7 +397,7 @@ fn access_request_empty_password() {
let empty_password = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("code", &setup.authtoken),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand All @@ -418,7 +418,7 @@ fn access_request_multiple_client_indications() {
let multiple_client_indications = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("client_id", EXAMPLE_CLIENT_ID),
("code", &setup.authtoken),
Expand All @@ -440,7 +440,7 @@ fn access_request_public_authorization() {
let public_authorization = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("code", &setup.authtoken),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand All @@ -461,7 +461,7 @@ fn access_request_public_missing_client() {
let public_missing_client = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("code", &setup.authtoken),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand All @@ -482,7 +482,7 @@ fn access_request_invalid_basic() {
let invalid_basic = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("code", &setup.authtoken),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand All @@ -503,7 +503,7 @@ fn access_request_wrong_redirection() {
let wrong_redirection = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("code", &setup.authtoken),
("redirect_uri", "https://wrong.client.example/endpoint"),
Expand All @@ -524,7 +524,7 @@ fn access_request_invalid_redirection() {
let invalid_redirection = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("code", &setup.authtoken),
("redirect_uri", "\\://"),
Expand All @@ -545,7 +545,7 @@ fn access_request_no_code() {
let no_code = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("redirect_uri", EXAMPLE_REDIRECT_URI),
]
Expand All @@ -561,7 +561,7 @@ fn access_request_no_code() {
#[test]
fn access_request_multiple_codes() {
let mut setup = AccessTokenSetup::private_client();
let mut urlbody = vec![
let mut urlbody = [
("grant_type", "authorization_code"),
("code", &setup.authtoken),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand Down Expand Up @@ -589,7 +589,7 @@ fn access_request_wrong_grant_type() {
let wrong_grant_type = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "another_grant_type"),
("code", &setup.authtoken),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand Down Expand Up @@ -619,7 +619,7 @@ fn private_in_body() {
let valid_public = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("code", &setup.authtoken),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand All @@ -642,7 +642,7 @@ fn unwanted_private_in_body_fails() {
let valid_public = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("code", &setup.authtoken),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand All @@ -666,7 +666,7 @@ fn private_duplicate_authentication() {
let valid_public = CraftedRequest {
query: None,
urlbody: Some(
vec![
[
("grant_type", "authorization_code"),
("code", &setup.authtoken),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand Down
16 changes: 8 additions & 8 deletions oxide-auth-async/src/tests/authorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fn assert_send() {
fn auth_success() {
let success = CraftedRequest {
query: Some(
vec![
[
("response_type", "code"),
("client_id", EXAMPLE_CLIENT_ID),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand All @@ -180,7 +180,7 @@ fn auth_success() {
#[test]
fn auth_request_silent_missing_client() {
let missing_client = CraftedRequest {
query: Some(vec![("response_type", "code")].iter().to_single_value_query()),
query: Some([("response_type", "code")].iter().to_single_value_query()),
urlbody: None,
auth: None,
};
Expand All @@ -193,7 +193,7 @@ fn auth_request_silent_unknown_client() {
// The client_id is not registered
let unknown_client = CraftedRequest {
query: Some(
vec![
[
("response_type", "code"),
("client_id", "SomeOtherClient"),
("redirect_uri", "https://wrong.client.example/endpoint"),
Expand All @@ -213,7 +213,7 @@ fn auth_request_silent_mismatching_redirect() {
// The redirect_uri does not match
let mismatching_redirect = CraftedRequest {
query: Some(
vec![
[
("response_type", "code"),
("client_id", EXAMPLE_CLIENT_ID),
("redirect_uri", "https://wrong.client.example/endpoint"),
Expand All @@ -233,7 +233,7 @@ fn auth_request_silent_invalid_redirect() {
// The redirect_uri is not an uri ('\' is not allowed to appear in the scheme)
let invalid_redirect = CraftedRequest {
query: Some(
vec![
[
("response_type", "code"),
("client_id", EXAMPLE_CLIENT_ID),
("redirect_uri", "\\://"),
Expand All @@ -253,7 +253,7 @@ fn auth_request_error_denied() {
// Used in conjunction with a denying authorization handler below
let denied_request = CraftedRequest {
query: Some(
vec![
[
("response_type", "code"),
("client_id", EXAMPLE_CLIENT_ID),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand All @@ -273,7 +273,7 @@ fn auth_request_error_unsupported_method() {
// Requesting an authorization token for a method other than code
let unsupported_method = CraftedRequest {
query: Some(
vec![
[
("response_type", "other_method"),
("client_id", EXAMPLE_CLIENT_ID),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand All @@ -294,7 +294,7 @@ fn auth_request_error_malformed_scope() {
// A scope with malformed formatting
let malformed_scope = CraftedRequest {
query: Some(
vec![
[
("response_type", "code"),
("client_id", EXAMPLE_CLIENT_ID),
("redirect_uri", EXAMPLE_REDIRECT_URI),
Expand Down
Loading