diff options
Diffstat (limited to 'rs/server')
-rw-r--r-- | rs/server/src/main.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/rs/server/src/main.rs b/rs/server/src/main.rs index bdf38ef..68ef3b0 100644 --- a/rs/server/src/main.rs +++ b/rs/server/src/main.rs | |||
@@ -985,25 +985,27 @@ fn test_validate_claims() { | |||
985 | let key = "00232f7a019bd34e3921ee6c5f04caf48a4489d1be5d1999038950a7054e0bfea369ce2becc0f13fd3c69f8af2384a25b7ac2d52eb52c33722f3c00c50d4c9c2"; | 985 | let key = "00232f7a019bd34e3921ee6c5f04caf48a4489d1be5d1999038950a7054e0bfea369ce2becc0f13fd3c69f8af2384a25b7ac2d52eb52c33722f3c00c50d4c9c2"; |
986 | let key: common::Key = key.parse().unwrap(); | 986 | let key: common::Key = key.parse().unwrap(); |
987 | 987 | ||
988 | let expires_at = Utc::now() + std::time::Duration::from_secs(5 * 60); | ||
989 | let claims = common::Claims { | 988 | let claims = common::Claims { |
990 | expires_at, | 989 | expires_at: Utc::now() + std::time::Duration::from_secs(5 * 60), |
991 | repo_path: "lfs-test.git", | 990 | repo_path: "lfs-test.git", |
992 | specific_claims: common::SpecificClaims::BatchApi(common::Operation::Download), | 991 | specific_claims: common::SpecificClaims::BatchApi(common::Operation::Download), |
993 | }; | 992 | }; |
994 | let tag = common::generate_tag(claims, &key).unwrap(); | 993 | let tag = common::generate_tag(claims, &key).unwrap(); |
995 | let header_value = format!("Gitolfs3-Hmac-Sha256 {tag} {}", expires_at.timestamp()); | 994 | let header_value = format!( |
995 | "Gitolfs3-Hmac-Sha256 {tag} {}", | ||
996 | claims.expires_at.timestamp() | ||
997 | ); | ||
996 | 998 | ||
997 | let conf = AuthorizationConfig { | 999 | let conf = AuthorizationConfig { |
998 | key, | 1000 | key, |
999 | trusted_forwarded_hosts: HashSet::new(), | 1001 | trusted_forwarded_hosts: HashSet::new(), |
1000 | }; | 1002 | }; |
1001 | let claims = VerifyClaimsInput { | 1003 | let verification_claims = VerifyClaimsInput { |
1002 | repo_path: "lfs-test.git", | 1004 | repo_path: claims.repo_path, |
1003 | specific_claims: common::SpecificClaims::BatchApi(common::Operation::Download), | 1005 | specific_claims: claims.specific_claims, |
1004 | }; | 1006 | }; |
1005 | let mut headers = HeaderMap::new(); | 1007 | let mut headers = HeaderMap::new(); |
1006 | headers.insert(header::AUTHORIZATION, header_value.try_into().unwrap()); | 1008 | headers.insert(header::AUTHORIZATION, header_value.try_into().unwrap()); |
1007 | 1009 | ||
1008 | assert!(verify_claims(&conf, &claims, &headers).unwrap()); | 1010 | assert!(verify_claims(&conf, &verification_claims, &headers).unwrap()); |
1009 | } | 1011 | } |