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

chore: fix all warnings #276

Merged
merged 1 commit into from
Nov 13, 2023
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
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,19 @@ jobs:
os:
- ubuntu-latest
cargo:
- name: "Clippy"
- name: "Clippy default features"
cmd: clippy
args: --all-features --release -- -D clippy::all
args: --tests -- -D warnings
cache: {}
rustc: stable
- name: "Clippy multitenant feature, no analytics feature"
cmd: clippy
args: --features=multitenant --tests -- -D warnings
cache: {}
rustc: stable
- name: "Clippy all features"
cmd: clippy
args: --all-features --tests -- -D warnings
cache: {}
rustc: stable
- name: "Formatting"
Expand Down
2 changes: 2 additions & 0 deletions src/handlers/push_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ pub async fn handler_internal(
return Err((Error::MissmatchedTenantId, analytics));
}

#[cfg(not(feature = "analytics"))]
return Err((Error::MissmatchedTenantId, None));
}
}
Expand Down Expand Up @@ -453,5 +454,6 @@ pub async fn handler_internal(
return Ok(((StatusCode::ACCEPTED).into_response(), analytics));
}

#[cfg(not(feature = "analytics"))]
Ok(((StatusCode::ACCEPTED).into_response(), None))
}
2 changes: 1 addition & 1 deletion src/handlers/update_apns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use {
},
base64::Engine,
serde::{Deserialize, Serialize},
std::{io::BufReader, sync::Arc},
std::sync::Arc,
tracing::{error, warn},
};

Expand Down
4 changes: 4 additions & 0 deletions tests/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ impl AsyncTestContext for EchoServerContext {
let server = EchoServer::start(ConfigContext::setup().config).await;
Self { server, config }
}

async fn teardown(mut self) {
self.server.shutdown().await;
}
}

#[async_trait]
Expand Down
2 changes: 1 addition & 1 deletion tests/context/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async fn start_server(
bool,
) {
let rt = Handle::current();
let port = config.port.clone();
let port = config.port;
let public_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), port);

let (signal, shutdown) = broadcast::channel(1);
Expand Down
11 changes: 7 additions & 4 deletions tests/functional/multitenant/apns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use {
echo_server::handlers::create_tenant::TenantRegisterBody,
jsonwebtoken::{encode, EncodingKey, Header},
random_string::generate,
std::time::SystemTime,
std::{env, time::SystemTime},
test_context::test_context,
uuid::Uuid,
};
Expand Down Expand Up @@ -47,11 +47,14 @@ async fn tenant_update_apns_valid_token(ctx: &mut EchoServerContext) {
let form = reqwest::multipart::Form::new()
.text("apns_type", "token")
.text("apns_topic", "app.test")
.text("apns_key_id", env!("ECHO_TEST_APNS_P8_KEY_ID"))
.text("apns_team_id", env!("ECHO_TEST_APNS_P8_TEAM_ID"))
.text("apns_key_id", env::var("ECHO_TEST_APNS_P8_KEY_ID").unwrap())
.text(
"apns_team_id",
env::var("ECHO_TEST_APNS_P8_TEAM_ID").unwrap(),
)
.part(
"apns_pkcs8_pem",
reqwest::multipart::Part::text(env!("ECHO_TEST_APNS_P8_PEM"))
reqwest::multipart::Part::text(env::var("ECHO_TEST_APNS_P8_PEM").unwrap())
.file_name("apns.p8")
.mime_str("text/plain")
.expect("Error on passing multipart stream to the form request"),
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/multitenant/fcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use {
echo_server::handlers::create_tenant::TenantRegisterBody,
jsonwebtoken::{encode, EncodingKey, Header},
random_string::generate,
std::time::SystemTime,
std::{env, time::SystemTime},
test_context::test_context,
};

Expand Down Expand Up @@ -44,7 +44,7 @@ async fn tenant_update_fcm_valid(ctx: &mut EchoServerContext) {
assert_eq!(register_response.status(), reqwest::StatusCode::OK);

// Send valid API Key
let api_key = env!("ECHO_TEST_FCM_KEY");
let api_key = env::var("ECHO_TEST_FCM_KEY").unwrap();
let form = reqwest::multipart::Form::new().text("api_key", api_key);

let response_fcm_update = client
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn check_payload_not_encrypted() {
blob: EXAMPLE_CLEARTEXT_ENCODED_BLOB.to_string(),
};

assert_eq!(payload.is_encrypted(), false)
assert!(!payload.is_encrypted());
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/middleware/validate_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub async fn invalid_signature_not_hex() {
// Should error
assert!(res.is_err());

let error = res.err().expect("Couldn't unwrap error");
let error = res.expect_err("Couldn't unwrap error");
assert!(error.is_hex());
}

Expand All @@ -67,7 +67,7 @@ pub async fn invalid_signature_hex() {
// Should error
assert!(res.is_err());

let error = res.err().expect("Couldn't unwrap error");
let error = res.expect_err("Couldn't unwrap error");
// Note: should be a from slice error as the signature
assert!(error.is_ed_25519());
}
Loading