Make clippy happy

This commit is contained in:
Kerollmops 2022-11-14 17:37:18 +01:00
parent 5cfcdbb55a
commit 0331fc7c71
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
4 changed files with 20 additions and 20 deletions

View File

@ -99,7 +99,7 @@ async fn error_access_expired_key() {
assert!(response["key"].is_string()); assert!(response["key"].is_string());
let key = response["key"].as_str().unwrap(); let key = response["key"].as_str().unwrap();
server.use_api_key(&key); server.use_api_key(key);
// wait until the key is expired. // wait until the key is expired.
thread::sleep(time::Duration::new(1, 0)); thread::sleep(time::Duration::new(1, 0));
@ -135,7 +135,7 @@ async fn error_access_unauthorized_index() {
assert!(response["key"].is_string()); assert!(response["key"].is_string());
let key = response["key"].as_str().unwrap(); let key = response["key"].as_str().unwrap();
server.use_api_key(&key); server.use_api_key(key);
for (method, route) in AUTHORIZATIONS for (method, route) in AUTHORIZATIONS
.keys() .keys()
@ -175,7 +175,7 @@ async fn error_access_unauthorized_action() {
assert!(response["key"].is_string()); assert!(response["key"].is_string());
let key = response["key"].as_str().unwrap(); let key = response["key"].as_str().unwrap();
server.use_api_key(&key); server.use_api_key(key);
let (response, code) = server.dummy_request(method, route).await; let (response, code) = server.dummy_request(method, route).await;
assert_eq!( assert_eq!(
@ -230,7 +230,7 @@ async fn access_authorized_restricted_index() {
assert!(response["key"].is_string()); assert!(response["key"].is_string());
let key = response["key"].as_str().unwrap(); let key = response["key"].as_str().unwrap();
server.use_api_key(&key); server.use_api_key(key);
let (response, code) = server.dummy_request(method, route).await; let (response, code) = server.dummy_request(method, route).await;
@ -268,7 +268,7 @@ async fn access_authorized_no_index_restriction() {
assert!(response["key"].is_string()); assert!(response["key"].is_string());
let key = response["key"].as_str().unwrap(); let key = response["key"].as_str().unwrap();
server.use_api_key(&key); server.use_api_key(key);
let (response, code) = server.dummy_request(method, route).await; let (response, code) = server.dummy_request(method, route).await;
@ -313,7 +313,7 @@ async fn access_authorized_stats_restricted_index() {
// use created key. // use created key.
let key = response["key"].as_str().unwrap(); let key = response["key"].as_str().unwrap();
server.use_api_key(&key); server.use_api_key(key);
let (response, code) = server.stats().await; let (response, code) = server.stats().await;
assert_eq!(200, code, "{:?}", &response); assert_eq!(200, code, "{:?}", &response);
@ -353,7 +353,7 @@ async fn access_authorized_stats_no_index_restriction() {
// use created key. // use created key.
let key = response["key"].as_str().unwrap(); let key = response["key"].as_str().unwrap();
server.use_api_key(&key); server.use_api_key(key);
let (response, code) = server.stats().await; let (response, code) = server.stats().await;
assert_eq!(200, code, "{:?}", &response); assert_eq!(200, code, "{:?}", &response);
@ -393,7 +393,7 @@ async fn list_authorized_indexes_restricted_index() {
// use created key. // use created key.
let key = response["key"].as_str().unwrap(); let key = response["key"].as_str().unwrap();
server.use_api_key(&key); server.use_api_key(key);
let (response, code) = server.list_indexes(None, None).await; let (response, code) = server.list_indexes(None, None).await;
assert_eq!(200, code, "{:?}", &response); assert_eq!(200, code, "{:?}", &response);
@ -434,7 +434,7 @@ async fn list_authorized_indexes_no_index_restriction() {
// use created key. // use created key.
let key = response["key"].as_str().unwrap(); let key = response["key"].as_str().unwrap();
server.use_api_key(&key); server.use_api_key(key);
let (response, code) = server.list_indexes(None, None).await; let (response, code) = server.list_indexes(None, None).await;
assert_eq!(200, code, "{:?}", &response); assert_eq!(200, code, "{:?}", &response);
@ -474,7 +474,7 @@ async fn list_authorized_tasks_restricted_index() {
// use created key. // use created key.
let key = response["key"].as_str().unwrap(); let key = response["key"].as_str().unwrap();
server.use_api_key(&key); server.use_api_key(key);
let (response, code) = server.service.get("/tasks").await; let (response, code) = server.service.get("/tasks").await;
assert_eq!(200, code, "{:?}", &response); assert_eq!(200, code, "{:?}", &response);
@ -514,7 +514,7 @@ async fn list_authorized_tasks_no_index_restriction() {
// use created key. // use created key.
let key = response["key"].as_str().unwrap(); let key = response["key"].as_str().unwrap();
server.use_api_key(&key); server.use_api_key(key);
let (response, code) = server.service.get("/tasks").await; let (response, code) = server.service.get("/tasks").await;
assert_eq!(200, code, "{:?}", &response); assert_eq!(200, code, "{:?}", &response);
@ -545,7 +545,7 @@ async fn error_creating_index_without_action() {
// use created key. // use created key.
let key = response["key"].as_str().unwrap(); let key = response["key"].as_str().unwrap();
server.use_api_key(&key); server.use_api_key(key);
let expected_error = json!({ let expected_error = json!({
"message": "Index `test` not found.", "message": "Index `test` not found.",
@ -625,7 +625,7 @@ async fn lazy_create_index() {
// use created key. // use created key.
let key = response["key"].as_str().unwrap(); let key = response["key"].as_str().unwrap();
server.use_api_key(&key); server.use_api_key(key);
// try to create a index via add documents route // try to create a index via add documents route
let index = server.index("test"); let index = server.index("test");
@ -692,7 +692,7 @@ async fn error_creating_index_without_index() {
// use created key. // use created key.
let key = response["key"].as_str().unwrap(); let key = response["key"].as_str().unwrap();
server.use_api_key(&key); server.use_api_key(key);
// try to create a index via add documents route // try to create a index via add documents route
let index = server.index("test"); let index = server.index("test");

View File

@ -473,7 +473,7 @@ async fn error_access_forbidden_routes() {
"searchRules" => json!(["*"]), "searchRules" => json!(["*"]),
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp()) "exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
}; };
let web_token = generate_tenant_token(&uid, &key, tenant_token); let web_token = generate_tenant_token(uid, key, tenant_token);
server.use_api_key(&web_token); server.use_api_key(&web_token);
for ((method, route), actions) in AUTHORIZATIONS.iter() { for ((method, route), actions) in AUTHORIZATIONS.iter() {
@ -509,7 +509,7 @@ async fn error_access_expired_parent_key() {
"searchRules" => json!(["*"]), "searchRules" => json!(["*"]),
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp()) "exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
}; };
let web_token = generate_tenant_token(&uid, &key, tenant_token); let web_token = generate_tenant_token(uid, key, tenant_token);
server.use_api_key(&web_token); server.use_api_key(&web_token);
// test search request while parent_key is not expired // test search request while parent_key is not expired
@ -552,7 +552,7 @@ async fn error_access_modified_token() {
"searchRules" => json!(["products"]), "searchRules" => json!(["products"]),
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp()) "exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
}; };
let web_token = generate_tenant_token(&uid, &key, tenant_token); let web_token = generate_tenant_token(uid, key, tenant_token);
server.use_api_key(&web_token); server.use_api_key(&web_token);
// test search request while web_token is valid // test search request while web_token is valid
@ -567,7 +567,7 @@ async fn error_access_modified_token() {
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp()) "exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
}; };
let alt = generate_tenant_token(&uid, &key, tenant_token); let alt = generate_tenant_token(uid, key, tenant_token);
let altered_token = [ let altered_token = [
web_token.split('.').next().unwrap(), web_token.split('.').next().unwrap(),
alt.split('.').nth(1).unwrap(), alt.split('.').nth(1).unwrap(),

View File

@ -213,7 +213,7 @@ impl TaskQueue {
let head = self.queue.pop()?; let head = self.queue.pop()?;
let result = { let result = {
let mut ref_head = head.borrow_mut(); let mut ref_head = head.borrow_mut();
f(&mut *ref_head) f(&mut ref_head)
}; };
if !head.borrow().tasks.is_empty() { if !head.borrow().tasks.is_empty() {
// After being mutated, the head is reinserted to the correct position. // After being mutated, the head is reinserted to the correct position.

View File

@ -117,7 +117,7 @@ impl TaskStore {
match filter { match filter {
Some(filter) => filter Some(filter) => filter
.pass(&task) .pass(&task)
.then(|| task) .then_some(task)
.ok_or(TaskError::UnexistingTask(id)), .ok_or(TaskError::UnexistingTask(id)),
None => Ok(task), None => Ok(task),
} }