MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / issue_token_with_duration

Function issue_token_with_duration

nodedb-cluster/src/auth/join_token.rs:275–288  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

273 /// wall clock, identical to the CLI path.
274 #[test]
275 fn issue_token_with_duration() {
276 let secret = [0xBBu8; 32];
277 let ttl = Duration::from_secs(300);
278 let now = SystemTime::now()
279 .duration_since(UNIX_EPOCH)
280 .unwrap()
281 .as_secs();
282 let expiry = now + ttl.as_secs();
283 let hex = issue_token(&secret, 3, expiry).unwrap();
284 assert_eq!(hex.len(), TOKEN_HEX_LEN);
285 let (node, exp) = verify_token(&hex, &secret).unwrap();
286 assert_eq!(node, 3);
287 assert!(exp >= now + ttl.as_secs() - 2); // allow 2s clock slack
288 }
289}

Callers

nothing calls this directly

Calls 4

nowFunction · 0.85
issue_tokenFunction · 0.85
verify_tokenFunction · 0.85
duration_sinceMethod · 0.80

Tested by

no test coverage detected