mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2025-12-06 09:47:50 +03:00
chore(clippy): fix all clippy warnings
This commit is contained in:
@@ -528,7 +528,7 @@ fn parse_name_and_subgroups(text: &str) -> Result<ParsedLessonName, Error> {
|
|||||||
if result.is_none() {
|
if result.is_none() {
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
sentry::capture_message(
|
sentry::capture_message(
|
||||||
&*format!("Не удалось угадать тип пары '{}'!", extra),
|
&format!("Не удалось угадать тип пары '{}'!", extra),
|
||||||
sentry::Level::Warning,
|
sentry::Level::Warning,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,6 @@ use jsonwebtoken::errors::ErrorKind;
|
|||||||
use jsonwebtoken::{Algorithm, DecodingKey, Validation, decode};
|
use jsonwebtoken::{Algorithm, DecodingKey, Validation, decode};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
|
||||||
struct TokenData {
|
|
||||||
iis: String,
|
|
||||||
sub: i32,
|
|
||||||
app: i32,
|
|
||||||
exp: i32,
|
|
||||||
iat: i32,
|
|
||||||
jti: i32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
struct Claims {
|
struct Claims {
|
||||||
sub: i32,
|
sub: i32,
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ mod tests {
|
|||||||
id: Set(id.clone()),
|
id: Set(id.clone()),
|
||||||
username: Set(username),
|
username: Set(username),
|
||||||
password: Set(Some(
|
password: Set(Some(
|
||||||
bcrypt::hash("example".to_string(), bcrypt::DEFAULT_COST).unwrap(),
|
bcrypt::hash("example", bcrypt::DEFAULT_COST).unwrap(),
|
||||||
)),
|
)),
|
||||||
vk_id: Set(None),
|
vk_id: Set(None),
|
||||||
telegram_id: Set(None),
|
telegram_id: Set(None),
|
||||||
|
|||||||
@@ -24,14 +24,13 @@ static ENCODING_KEY: LazyLock<EncodingKey> = LazyLock::new(|| {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/// Token verification errors.
|
/// Token verification errors.
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// The token has a different signature.
|
/// The token has a different signature.
|
||||||
InvalidSignature,
|
InvalidSignature,
|
||||||
|
|
||||||
/// Token reading error.
|
/// Token reading error.
|
||||||
InvalidToken(ErrorKind),
|
InvalidToken,
|
||||||
|
|
||||||
/// Token expired.
|
/// Token expired.
|
||||||
Expired,
|
Expired,
|
||||||
@@ -82,7 +81,7 @@ pub fn verify_and_decode(token: &str) -> Result<String, Error> {
|
|||||||
Err(err) => Err(match err.into_kind() {
|
Err(err) => Err(match err.into_kind() {
|
||||||
ErrorKind::InvalidSignature => Error::InvalidSignature,
|
ErrorKind::InvalidSignature => Error::InvalidSignature,
|
||||||
ErrorKind::ExpiredSignature => Error::Expired,
|
ErrorKind::ExpiredSignature => Error::Expired,
|
||||||
kind => Error::InvalidToken(kind),
|
_ => Error::InvalidToken,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,7 +114,7 @@ mod tests {
|
|||||||
fn test_encode() {
|
fn test_encode() {
|
||||||
test_env();
|
test_env();
|
||||||
|
|
||||||
assert_eq!(encode(&"test".to_string()).is_empty(), false);
|
assert!(!encode("test").is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -128,7 +127,7 @@ mod tests {
|
|||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.err().unwrap(),
|
result.err().unwrap(),
|
||||||
Error::InvalidToken(ErrorKind::InvalidToken)
|
Error::InvalidToken
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user