Added working "infinite" jwt token for testing
parent
ac7a753dd3
commit
d3d3771d22
|
@ -7,7 +7,7 @@ use figment::{
|
||||||
providers::{Env, Format, Yaml},
|
providers::{Env, Format, Yaml},
|
||||||
Figment,
|
Figment,
|
||||||
};
|
};
|
||||||
use rb::{auth::JwtConf, guards};
|
use rb::auth::JwtConf;
|
||||||
use rocket::{
|
use rocket::{
|
||||||
fairing::AdHoc,
|
fairing::AdHoc,
|
||||||
http::Status,
|
http::Status,
|
||||||
|
@ -49,9 +49,6 @@ pub struct RbConfig
|
||||||
jwt: JwtConf,
|
jwt: JwtConf,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/test")]
|
|
||||||
async fn test(_yeet: guards::Jwt) {}
|
|
||||||
|
|
||||||
#[launch]
|
#[launch]
|
||||||
fn rocket() -> _
|
fn rocket() -> _
|
||||||
{
|
{
|
||||||
|
@ -87,8 +84,7 @@ fn rocket() -> _
|
||||||
posts::patch,
|
posts::patch,
|
||||||
posts::delete
|
posts::delete
|
||||||
],
|
],
|
||||||
)
|
);
|
||||||
.mount("/", routes![test]);
|
|
||||||
|
|
||||||
let new_figment = rocket.figment();
|
let new_figment = rocket.figment();
|
||||||
let jwt_conf: JwtConf = new_figment.extract_inner("jwt").expect("jwt config");
|
let jwt_conf: JwtConf = new_figment.extract_inner("jwt").expect("jwt config");
|
||||||
|
|
7
test.py
7
test.py
|
@ -1,6 +1,7 @@
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
token = "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6IjVjMjM2OTI0NjY4ZDQzZWFiNGNmNDczYjk1YWZiNzgzIiwidXNlcm5hbWUiOiJKb2huIERvZSIsImFkbWluIjp0cnVlLCJleHAiOjE1MTYyMzkwMjIwfQ.3AzUBe08lcnC3fUIMqPZ8kG51PNPS4MAMpoh_v5HSKM"
|
# Token specifically used for testing. It's signed with secret "secret" & expires in 2034 or something
|
||||||
|
token = "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6IjVjMjM2OTI0NjY4ZDQzZWFiNGNmNDczYjk1YWZiNzgzIiwidXNlcm5hbWUiOiJKb2huIERvZSIsImFkbWluIjp0cnVlLCJleHAiOjE1MTYyMzkwMjIwfQ.if939L9le8LP-dtXnQs-mHPkb-VieRAvAfSu20755jY"
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"Authorization": f"Bearer {token}"
|
"Authorization": f"Bearer {token}"
|
||||||
|
@ -11,6 +12,8 @@ data = {
|
||||||
"shortname": "short",
|
"shortname": "short",
|
||||||
}
|
}
|
||||||
|
|
||||||
r = requests.get("http://localhost:8000/test", headers=headers)
|
r = requests.post("http://localhost:8000/sections", headers=headers, json=data)
|
||||||
print(r.content)
|
print(r.content)
|
||||||
print(r.status_code)
|
print(r.status_code)
|
||||||
|
r = requests.get("http://localhost:8000/sections?offset=0&limit=100")
|
||||||
|
print(r.json())
|
||||||
|
|
Reference in New Issue