Implemented functionality and wrote test for checking token scope
All checks were successful
Rust Build / Check (pull_request) Successful in 35s
Rust Build / Test Suite (pull_request) Successful in 33s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Successful in 35s
Rust Build / build (pull_request) Successful in 32s

This commit is contained in:
2025-04-09 20:32:00 -04:00
parent 2dbed9fec9
commit f64c909fae

View File

@@ -57,14 +57,27 @@ impl Token {
false false
} }
// TODO: Implement
pub fn contains_scope(&self, des_scope: &String) -> bool { pub fn contains_scope(&self, des_scope: &String) -> bool {
let extracted_token: String = String::from("Token"); self.scope.contains(des_scope)
}
if extracted_token == *des_scope { }
return true;
} #[cfg(test)]
mod tests {
false use super::*;
#[test]
fn test_token_scope_check() {
let mut token = Token::default();
token.scope = String::from("song:read song:upload song:download");
let check_scope = String::from("song:download");
let result = token.contains_scope(&check_scope);
assert!(
result,
"Error: The scope {:?} was not found in the token's scope {:?}",
check_scope, token.scope
);
} }
} }