Next release #38
29
src/token.rs
29
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;
|
||||
}
|
||||
|
||||
false
|
||||
self.scope.contains(des_scope)
|
||||
}
|
||||
}
|
||||
|
||||
#[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