Implemented functionality and wrote test for checking token scope (#39)
All checks were successful
Release Tagging / release (push) Successful in 54s
Rust Build / Check (push) Successful in 40s
Rust Build / Test Suite (push) Successful in 34s
Rust Build / Rustfmt (push) Successful in 36s
Rust Build / Clippy (push) Successful in 31s
Rust Build / build (push) Successful in 37s
Rust Build / Check (pull_request) Successful in 28s
Rust Build / Test Suite (pull_request) Successful in 41s
Rust Build / Rustfmt (pull_request) Successful in 33s
Rust Build / Clippy (pull_request) Successful in 37s
Rust Build / build (pull_request) Successful in 27s
All checks were successful
Release Tagging / release (push) Successful in 54s
Rust Build / Check (push) Successful in 40s
Rust Build / Test Suite (push) Successful in 34s
Rust Build / Rustfmt (push) Successful in 36s
Rust Build / Clippy (push) Successful in 31s
Rust Build / build (push) Successful in 37s
Rust Build / Check (pull_request) Successful in 28s
Rust Build / Test Suite (pull_request) Successful in 41s
Rust Build / Rustfmt (pull_request) Successful in 33s
Rust Build / Clippy (pull_request) Successful in 37s
Rust Build / build (pull_request) Successful in 27s
Reviewed-on: #39 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
25
src/token.rs
25
src/token.rs
@@ -57,14 +57,27 @@ impl Token {
|
||||
false
|
||||
}
|
||||
|
||||
// TODO: Implement
|
||||
pub fn contains_scope(&self, des_scope: &String) -> bool {
|
||||
let extracted_token: String = String::from("Token");
|
||||
|
||||
if extracted_token == *des_scope {
|
||||
return true;
|
||||
self.scope.contains(des_scope)
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user