@@ -118,7 +118,6 @@ impl InstalledCredentialVersions {
118118 }
119119}
120120
121-
122121/// Token-grant dynamic credentials sharing one `provider:credential`
123122/// identity, keyed by their raw dynamic credential key and sorted.
124123type GrantConfigs = Vec < ( String , crate :: proto:: ProviderProfileCredential ) > ;
@@ -584,7 +583,6 @@ impl ProviderCredentialState {
584583 }
585584 }
586585
587-
588586 /// Whether every credential this connection injected is still at the
589587 /// version it injected. True for a connection that injected nothing;
590588 /// false for an untracked handle, which cannot tell.
@@ -4352,7 +4350,10 @@ mod tests {
43524350 #[ test]
43534351 fn tracked_resolver_records_the_key_and_version_of_each_secret_sent ( ) {
43544352 let tracked = token_state ( 10 , & [ ( "GITHUB_TOKEN" , "secret" ) ] ) . with_use_tracking ( ) ;
4355- assert ! ( tracked. credential_uses( ) . unwrap( ) . is_empty( ) , "nothing injected yet" ) ;
4353+ assert ! (
4354+ tracked. credential_uses( ) . unwrap( ) . is_empty( ) ,
4355+ "nothing injected yet"
4356+ ) ;
43564357
43574358 assert_eq ! ( inject_static( & tracked, "GITHUB_TOKEN" ) , "secret" ) ;
43584359
@@ -4389,24 +4390,35 @@ mod tests {
43894390
43904391 #[ test]
43914392 fn uses_stay_current_until_a_credential_the_connection_used_changes ( ) {
4392- let tracked = token_state ( 10 , & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b" ) ] )
4393- . with_use_tracking ( ) ;
4393+ let tracked =
4394+ token_state ( 10 , & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b" ) ] ) . with_use_tracking ( ) ;
43944395 inject_static ( & tracked, "GITHUB_TOKEN" ) ;
43954396 assert ! ( tracked. credential_uses_current( ) ) ;
43964397
43974398 // Another provider's credential rotates; this connection never sent it.
4398- reinstall_tokens ( & tracked, 11 , & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b2" ) ] ) ;
4399- assert ! ( tracked. credential_uses_current( ) , "unused credentials don't matter" ) ;
4399+ reinstall_tokens (
4400+ & tracked,
4401+ 11 ,
4402+ & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b2" ) ] ,
4403+ ) ;
4404+ assert ! (
4405+ tracked. credential_uses_current( ) ,
4406+ "unused credentials don't matter"
4407+ ) ;
44004408
44014409 // The credential it sent rotates.
4402- reinstall_tokens ( & tracked, 12 , & [ ( "GITHUB_TOKEN" , "a2" ) , ( "OTHER_TOKEN" , "b2" ) ] ) ;
4410+ reinstall_tokens (
4411+ & tracked,
4412+ 12 ,
4413+ & [ ( "GITHUB_TOKEN" , "a2" ) , ( "OTHER_TOKEN" , "b2" ) ] ,
4414+ ) ;
44034415 assert ! ( !tracked. credential_uses_current( ) ) ;
44044416 }
44054417
44064418 #[ test]
44074419 fn removing_a_used_credential_is_a_change ( ) {
4408- let tracked = token_state ( 10 , & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b" ) ] )
4409- . with_use_tracking ( ) ;
4420+ let tracked =
4421+ token_state ( 10 , & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b" ) ] ) . with_use_tracking ( ) ;
44104422 inject_static ( & tracked, "GITHUB_TOKEN" ) ;
44114423
44124424 // Its provider is detached.
@@ -4433,7 +4445,11 @@ mod tests {
44334445 tracked. record_grant_use ( malformed) ;
44344446
44354447 assert_eq ! (
4436- tracked. credential_uses( ) . unwrap( ) . grant_versions. get( malformed) ,
4448+ tracked
4449+ . credential_uses( )
4450+ . unwrap( )
4451+ . grant_versions
4452+ . get( malformed) ,
44374453 Some ( & STALE_CREDENTIAL_VERSION )
44384454 ) ;
44394455 assert ! (
@@ -4492,11 +4508,20 @@ mod tests {
44924508 HashMap :: new ( ) ,
44934509 HashMap :: new ( ) ,
44944510 HashMap :: from ( [
4495- ( API_GRANT . to_string ( ) , grant_credential ( "https://idp.example.com/token" ) ) ,
4496- ( OTHER_GRANT . to_string ( ) , grant_credential ( "https://other-idp.example.com/token" ) ) ,
4511+ (
4512+ API_GRANT . to_string ( ) ,
4513+ grant_credential ( "https://idp.example.com/token" ) ,
4514+ ) ,
4515+ (
4516+ OTHER_GRANT . to_string ( ) ,
4517+ grant_credential ( "https://other-idp.example.com/token" ) ,
4518+ ) ,
44974519 ] ) ,
44984520 ) ;
4499- assert ! ( tracked. credential_uses_current( ) , "only the used grant matters" ) ;
4521+ assert ! (
4522+ tracked. credential_uses_current( ) ,
4523+ "only the used grant matters"
4524+ ) ;
45004525
45014526 // The used grant changes.
45024527 tracked. install_environment (
@@ -4568,14 +4593,26 @@ mod tests {
45684593 assert_ne ! ( github, other, "versions come from one counter" ) ;
45694594
45704595 reinstall_tokens ( & state, 11 , & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b2" ) ] ) ;
4571- assert_eq ! ( state. static_credential_version( "GITHUB_TOKEN" ) , Some ( github) ) ;
4596+ assert_eq ! (
4597+ state. static_credential_version( "GITHUB_TOKEN" ) ,
4598+ Some ( github)
4599+ ) ;
45724600 let other_rotated = state. static_credential_version ( "OTHER_TOKEN" ) . unwrap ( ) ;
4573- assert ! ( other_rotated > other, "a changed value gets a newer version" ) ;
4601+ assert ! (
4602+ other_rotated > other,
4603+ "a changed value gets a newer version"
4604+ ) ;
45744605
45754606 // Reinstalling identical content changes no version.
45764607 reinstall_tokens ( & state, 12 , & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b2" ) ] ) ;
4577- assert_eq ! ( state. static_credential_version( "GITHUB_TOKEN" ) , Some ( github) ) ;
4578- assert_eq ! ( state. static_credential_version( "OTHER_TOKEN" ) , Some ( other_rotated) ) ;
4608+ assert_eq ! (
4609+ state. static_credential_version( "GITHUB_TOKEN" ) ,
4610+ Some ( github)
4611+ ) ;
4612+ assert_eq ! (
4613+ state. static_credential_version( "OTHER_TOKEN" ) ,
4614+ Some ( other_rotated)
4615+ ) ;
45794616 }
45804617
45814618 #[ test]
@@ -4625,11 +4662,18 @@ mod tests {
46254662 // Revisions are sandbox-wide: another credential changing moves every
46264663 // placeholder to the new revision, but this one still sends the
46274664 // current value.
4628- let tracked = token_state ( 10 , & [ ( "GITHUB_TOKEN" , "same" ) , ( "OTHER_TOKEN" , "a" ) ] )
4629- . with_use_tracking ( ) ;
4665+ let tracked =
4666+ token_state ( 10 , & [ ( "GITHUB_TOKEN" , "same" ) , ( "OTHER_TOKEN" , "a" ) ] ) . with_use_tracking ( ) ;
46304667 let old_placeholder = tracked. snapshot ( ) . child_env [ "GITHUB_TOKEN" ] . clone ( ) ;
4631- reinstall_tokens ( & tracked, 11 , & [ ( "GITHUB_TOKEN" , "same" ) , ( "OTHER_TOKEN" , "b" ) ] ) ;
4632- assert_ne ! ( tracked. snapshot( ) . child_env[ "GITHUB_TOKEN" ] , old_placeholder) ;
4668+ reinstall_tokens (
4669+ & tracked,
4670+ 11 ,
4671+ & [ ( "GITHUB_TOKEN" , "same" ) , ( "OTHER_TOKEN" , "b" ) ] ,
4672+ ) ;
4673+ assert_ne ! (
4674+ tracked. snapshot( ) . child_env[ "GITHUB_TOKEN" ] ,
4675+ old_placeholder
4676+ ) ;
46334677
46344678 let resolver = tracked
46354679 . resolver_for_endpoint ( "api.github.com" , 443 , "/" )
@@ -4726,7 +4770,10 @@ mod tests {
47264770 grant_credential ( "https://idp.example.com/token" ) ,
47274771 ) ] ) ,
47284772 ) ;
4729- assert_eq ! ( state. grant_credential_version( "api:access_token" ) , Some ( version) ) ;
4773+ assert_eq ! (
4774+ state. grant_credential_version( "api:access_token" ) ,
4775+ Some ( version)
4776+ ) ;
47304777
47314778 state. install_environment (
47324779 12 ,
@@ -4737,7 +4784,10 @@ mod tests {
47374784 grant_credential ( "https://new-idp.example.com/token" ) ,
47384785 ) ] ) ,
47394786 ) ;
4740- assert_ne ! ( state. grant_credential_version( "api:access_token" ) , Some ( version) ) ;
4787+ assert_ne ! (
4788+ state. grant_credential_version( "api:access_token" ) ,
4789+ Some ( version)
4790+ ) ;
47414791 }
47424792
47434793 // --- Installed credential versions ---
@@ -4773,7 +4823,11 @@ mod tests {
47734823 assert ! ( !added. same_credentials( & installed) ) ;
47744824
47754825 reinstall_tokens ( & state, 12 , & [ ( "GITHUB_TOKEN" , "a" ) ] ) ;
4776- assert ! ( !state. installed_credential_versions( ) . same_credentials( & added) ) ;
4826+ assert ! (
4827+ !state
4828+ . installed_credential_versions( )
4829+ . same_credentials( & added)
4830+ ) ;
47774831 }
47784832
47794833 #[ test]
@@ -4786,7 +4840,11 @@ mod tests {
47864840 assert ! ( !revoked. same_credentials( & installed) ) ;
47874841
47884842 state. revoke_static_provider_environment ( 12 ) ;
4789- assert ! ( state. installed_credential_versions( ) . same_credentials( & revoked) ) ;
4843+ assert ! (
4844+ state
4845+ . installed_credential_versions( )
4846+ . same_credentials( & revoked)
4847+ ) ;
47904848 }
47914849
47924850 #[ test]
0 commit comments