Updated test
This commit is contained in:
@@ -50,9 +50,12 @@ mod token_stuff {
|
|||||||
|
|
||||||
pub const TOKENTYPE: &str = "JWT";
|
pub const TOKENTYPE: &str = "JWT";
|
||||||
pub const TESTKEY: &str = "dfsdferferf";
|
pub const TESTKEY: &str = "dfsdferferf";
|
||||||
|
pub const KEY_ENV: &str = "SECRET_KEY";
|
||||||
|
|
||||||
fn get_key() -> Result<String, dotenvy::Error> {
|
pub fn get_key() -> Result<String, dotenvy::Error> {
|
||||||
Ok(String::from(TESTKEY))
|
dotenvy::dotenv().ok();
|
||||||
|
let key = std::env::var(KEY_ENV).expect("SECRET_KEY_NOT_FOUND");
|
||||||
|
Ok(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_token(provided_key: &String) -> Result<String, josekit::JoseError> {
|
pub fn create_token(provided_key: &String) -> Result<String, josekit::JoseError> {
|
||||||
@@ -91,7 +94,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_tokenize() {
|
fn test_tokenize() {
|
||||||
let special_key = String::from("mysecret-dsfsdfsdfsdfsdgfsdgsdgsdfg");
|
let special_key = token_stuff::get_key().unwrap();
|
||||||
match token_stuff::create_token(&special_key) {
|
match token_stuff::create_token(&special_key) {
|
||||||
Ok(token) => {
|
Ok(token) => {
|
||||||
let result = token_stuff::verify_token(&special_key, &token);
|
let result = token_stuff::verify_token(&special_key, &token);
|
||||||
|
Reference in New Issue
Block a user