tangled
alpha
login
or
join now
malpercio.dev
/
ezpds
0
fork
atom
An easy-to-host PDS on the ATProtocol, MacOS. Grandma-approved.
0
fork
atom
overview
issues
pulls
pipelines
style: cargo fmt after review fix commit
malpercio.dev
1 day ago
744d2f52
1f56269d
+22
-28
2 changed files
expand all
collapse all
unified
split
crates
relay
src
db
oauth.rs
routes
oauth_token.rs
+4
-16
crates/relay/src/db/oauth.rs
reviewed
···
628
628
let second = consume_authorization_code(&pool, "hash-abc123")
629
629
.await
630
630
.unwrap();
631
631
-
assert!(
632
632
-
second.is_none(),
633
633
-
"consumed code must not be found again"
634
634
-
);
631
631
+
assert!(second.is_none(), "consumed code must not be found again");
635
632
}
636
633
637
634
#[tokio::test]
···
674
671
let result = consume_authorization_code(&pool, "expired-code-hash")
675
672
.await
676
673
.unwrap();
677
677
-
assert!(
678
678
-
result.is_none(),
679
679
-
"expired auth code must return None"
680
680
-
);
674
674
+
assert!(result.is_none(), "expired auth code must return None");
681
675
}
682
676
683
677
#[tokio::test]
···
757
751
let second = consume_oauth_refresh_token(&pool, "consume-test-token-hash")
758
752
.await
759
753
.unwrap();
760
760
-
assert!(
761
761
-
second.is_none(),
762
762
-
"consumed token must not be found again"
763
763
-
);
754
754
+
assert!(second.is_none(), "consumed token must not be found again");
764
755
}
765
756
766
757
#[tokio::test]
···
791
782
let result = consume_oauth_refresh_token(&pool, "expired-hash")
792
783
.await
793
784
.unwrap();
794
794
-
assert!(
795
795
-
result.is_none(),
796
796
-
"expired refresh token must return None"
797
797
-
);
785
785
+
assert!(result.is_none(), "expired refresh token must return None");
798
786
}
799
787
800
788
#[tokio::test]
+18
-12
crates/relay/src/routes/oauth_token.rs
reviewed
···
993
993
let header_b64 = at.split('.').next().unwrap();
994
994
let header_json = String::from_utf8(URL_SAFE_NO_PAD.decode(header_b64).unwrap()).unwrap();
995
995
let header: serde_json::Value = serde_json::from_str(&header_json).unwrap();
996
996
-
assert_eq!(
997
997
-
header["typ"], "at+jwt",
998
998
-
"access token typ must be at+jwt"
999
999
-
);
1000
1000
-
assert_eq!(
1001
1001
-
header["alg"], "ES256",
1002
1002
-
"access token alg must be ES256"
1003
1003
-
);
996
996
+
assert_eq!(header["typ"], "at+jwt", "access token typ must be at+jwt");
997
997
+
assert_eq!(header["alg"], "ES256", "access token alg must be ES256");
1004
998
1005
999
let payload_b64 = at.split('.').nth(1).unwrap();
1006
1000
let payload_json = String::from_utf8(URL_SAFE_NO_PAD.decode(payload_b64).unwrap()).unwrap();
···
1011
1005
cnf_jkt, expected_jkt,
1012
1006
"cnf.jkt must match DPoP key thumbprint"
1013
1007
);
1014
1014
-
assert_eq!(payload["iss"], "https://test.example.com", "iss must be public_url");
1015
1015
-
assert_eq!(payload["aud"], "https://test.example.com", "aud must be public_url");
1008
1008
+
assert_eq!(
1009
1009
+
payload["iss"], "https://test.example.com",
1010
1010
+
"iss must be public_url"
1011
1011
+
);
1012
1012
+
assert_eq!(
1013
1013
+
payload["aud"], "https://test.example.com",
1014
1014
+
"aud must be public_url"
1015
1015
+
);
1016
1016
}
1017
1017
1018
1018
#[tokio::test]
···
1327
1327
let payload_b64 = at.split('.').nth(1).unwrap();
1328
1328
let payload_json = String::from_utf8(URL_SAFE_NO_PAD.decode(payload_b64).unwrap()).unwrap();
1329
1329
let payload: serde_json::Value = serde_json::from_str(&payload_json).unwrap();
1330
1330
-
assert_eq!(payload["iss"], "https://test.example.com", "iss must be public_url");
1331
1331
-
assert_eq!(payload["aud"], "https://test.example.com", "aud must be public_url");
1330
1330
+
assert_eq!(
1331
1331
+
payload["iss"], "https://test.example.com",
1332
1332
+
"iss must be public_url"
1333
1333
+
);
1334
1334
+
assert_eq!(
1335
1335
+
payload["aud"], "https://test.example.com",
1336
1336
+
"aud must be public_url"
1337
1337
+
);
1332
1338
}
1333
1339
1334
1340
#[tokio::test]