@@ -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 ) > ;
@@ -586,7 +585,6 @@ impl ProviderCredentialState {
586585 }
587586 }
588587
589-
590588 /// Whether every credential this connection injected is still at the
591589 /// version it injected. True for a connection that injected nothing;
592590 /// false for an untracked handle, which cannot tell.
@@ -4268,7 +4266,10 @@ mod tests {
42684266 #[ test]
42694267 fn tracked_resolver_records_the_key_and_version_of_each_secret_sent ( ) {
42704268 let tracked = token_state ( 10 , & [ ( "GITHUB_TOKEN" , "secret" ) ] ) . with_use_tracking ( ) ;
4271- assert ! ( tracked. credential_uses( ) . unwrap( ) . is_empty( ) , "nothing injected yet" ) ;
4269+ assert ! (
4270+ tracked. credential_uses( ) . unwrap( ) . is_empty( ) ,
4271+ "nothing injected yet"
4272+ ) ;
42724273
42734274 assert_eq ! ( inject_static( & tracked, "GITHUB_TOKEN" ) , "secret" ) ;
42744275
@@ -4305,24 +4306,35 @@ mod tests {
43054306
43064307 #[ test]
43074308 fn uses_stay_current_until_a_credential_the_connection_used_changes ( ) {
4308- let tracked = token_state ( 10 , & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b" ) ] )
4309- . with_use_tracking ( ) ;
4309+ let tracked =
4310+ token_state ( 10 , & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b" ) ] ) . with_use_tracking ( ) ;
43104311 inject_static ( & tracked, "GITHUB_TOKEN" ) ;
43114312 assert ! ( tracked. credential_uses_current( ) ) ;
43124313
43134314 // Another provider's credential rotates; this connection never sent it.
4314- reinstall_tokens ( & tracked, 11 , & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b2" ) ] ) ;
4315- assert ! ( tracked. credential_uses_current( ) , "unused credentials don't matter" ) ;
4315+ reinstall_tokens (
4316+ & tracked,
4317+ 11 ,
4318+ & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b2" ) ] ,
4319+ ) ;
4320+ assert ! (
4321+ tracked. credential_uses_current( ) ,
4322+ "unused credentials don't matter"
4323+ ) ;
43164324
43174325 // The credential it sent rotates.
4318- reinstall_tokens ( & tracked, 12 , & [ ( "GITHUB_TOKEN" , "a2" ) , ( "OTHER_TOKEN" , "b2" ) ] ) ;
4326+ reinstall_tokens (
4327+ & tracked,
4328+ 12 ,
4329+ & [ ( "GITHUB_TOKEN" , "a2" ) , ( "OTHER_TOKEN" , "b2" ) ] ,
4330+ ) ;
43194331 assert ! ( !tracked. credential_uses_current( ) ) ;
43204332 }
43214333
43224334 #[ test]
43234335 fn removing_a_used_credential_is_a_change ( ) {
4324- let tracked = token_state ( 10 , & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b" ) ] )
4325- . with_use_tracking ( ) ;
4336+ let tracked =
4337+ token_state ( 10 , & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b" ) ] ) . with_use_tracking ( ) ;
43264338 inject_static ( & tracked, "GITHUB_TOKEN" ) ;
43274339
43284340 // Its provider is detached.
@@ -4349,7 +4361,11 @@ mod tests {
43494361 tracked. record_grant_use ( malformed) ;
43504362
43514363 assert_eq ! (
4352- tracked. credential_uses( ) . unwrap( ) . grant_versions. get( malformed) ,
4364+ tracked
4365+ . credential_uses( )
4366+ . unwrap( )
4367+ . grant_versions
4368+ . get( malformed) ,
43534369 Some ( & STALE_CREDENTIAL_VERSION )
43544370 ) ;
43554371 assert ! (
@@ -4408,11 +4424,20 @@ mod tests {
44084424 HashMap :: new ( ) ,
44094425 HashMap :: new ( ) ,
44104426 HashMap :: from ( [
4411- ( API_GRANT . to_string ( ) , grant_credential ( "https://idp.example.com/token" ) ) ,
4412- ( OTHER_GRANT . to_string ( ) , grant_credential ( "https://other-idp.example.com/token" ) ) ,
4427+ (
4428+ API_GRANT . to_string ( ) ,
4429+ grant_credential ( "https://idp.example.com/token" ) ,
4430+ ) ,
4431+ (
4432+ OTHER_GRANT . to_string ( ) ,
4433+ grant_credential ( "https://other-idp.example.com/token" ) ,
4434+ ) ,
44134435 ] ) ,
44144436 ) ;
4415- assert ! ( tracked. credential_uses_current( ) , "only the used grant matters" ) ;
4437+ assert ! (
4438+ tracked. credential_uses_current( ) ,
4439+ "only the used grant matters"
4440+ ) ;
44164441
44174442 // The used grant changes.
44184443 tracked. install_environment (
@@ -4484,14 +4509,26 @@ mod tests {
44844509 assert_ne ! ( github, other, "versions come from one counter" ) ;
44854510
44864511 reinstall_tokens ( & state, 11 , & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b2" ) ] ) ;
4487- assert_eq ! ( state. static_credential_version( "GITHUB_TOKEN" ) , Some ( github) ) ;
4512+ assert_eq ! (
4513+ state. static_credential_version( "GITHUB_TOKEN" ) ,
4514+ Some ( github)
4515+ ) ;
44884516 let other_rotated = state. static_credential_version ( "OTHER_TOKEN" ) . unwrap ( ) ;
4489- assert ! ( other_rotated > other, "a changed value gets a newer version" ) ;
4517+ assert ! (
4518+ other_rotated > other,
4519+ "a changed value gets a newer version"
4520+ ) ;
44904521
44914522 // Reinstalling identical content changes no version.
44924523 reinstall_tokens ( & state, 12 , & [ ( "GITHUB_TOKEN" , "a" ) , ( "OTHER_TOKEN" , "b2" ) ] ) ;
4493- assert_eq ! ( state. static_credential_version( "GITHUB_TOKEN" ) , Some ( github) ) ;
4494- assert_eq ! ( state. static_credential_version( "OTHER_TOKEN" ) , Some ( other_rotated) ) ;
4524+ assert_eq ! (
4525+ state. static_credential_version( "GITHUB_TOKEN" ) ,
4526+ Some ( github)
4527+ ) ;
4528+ assert_eq ! (
4529+ state. static_credential_version( "OTHER_TOKEN" ) ,
4530+ Some ( other_rotated)
4531+ ) ;
44954532 }
44964533
44974534 #[ test]
@@ -4541,11 +4578,18 @@ mod tests {
45414578 // Revisions are sandbox-wide: another credential changing moves every
45424579 // placeholder to the new revision, but this one still sends the
45434580 // current value.
4544- let tracked = token_state ( 10 , & [ ( "GITHUB_TOKEN" , "same" ) , ( "OTHER_TOKEN" , "a" ) ] )
4545- . with_use_tracking ( ) ;
4581+ let tracked =
4582+ token_state ( 10 , & [ ( "GITHUB_TOKEN" , "same" ) , ( "OTHER_TOKEN" , "a" ) ] ) . with_use_tracking ( ) ;
45464583 let old_placeholder = tracked. snapshot ( ) . child_env [ "GITHUB_TOKEN" ] . clone ( ) ;
4547- reinstall_tokens ( & tracked, 11 , & [ ( "GITHUB_TOKEN" , "same" ) , ( "OTHER_TOKEN" , "b" ) ] ) ;
4548- assert_ne ! ( tracked. snapshot( ) . child_env[ "GITHUB_TOKEN" ] , old_placeholder) ;
4584+ reinstall_tokens (
4585+ & tracked,
4586+ 11 ,
4587+ & [ ( "GITHUB_TOKEN" , "same" ) , ( "OTHER_TOKEN" , "b" ) ] ,
4588+ ) ;
4589+ assert_ne ! (
4590+ tracked. snapshot( ) . child_env[ "GITHUB_TOKEN" ] ,
4591+ old_placeholder
4592+ ) ;
45494593
45504594 let resolver = tracked
45514595 . resolver_for_endpoint ( "api.github.com" , 443 , "/" )
@@ -4642,7 +4686,10 @@ mod tests {
46424686 grant_credential ( "https://idp.example.com/token" ) ,
46434687 ) ] ) ,
46444688 ) ;
4645- assert_eq ! ( state. grant_credential_version( "api:access_token" ) , Some ( version) ) ;
4689+ assert_eq ! (
4690+ state. grant_credential_version( "api:access_token" ) ,
4691+ Some ( version)
4692+ ) ;
46464693
46474694 state. install_environment (
46484695 12 ,
@@ -4653,7 +4700,10 @@ mod tests {
46534700 grant_credential ( "https://new-idp.example.com/token" ) ,
46544701 ) ] ) ,
46554702 ) ;
4656- assert_ne ! ( state. grant_credential_version( "api:access_token" ) , Some ( version) ) ;
4703+ assert_ne ! (
4704+ state. grant_credential_version( "api:access_token" ) ,
4705+ Some ( version)
4706+ ) ;
46574707 }
46584708
46594709 // --- Installed credential versions ---
@@ -4689,7 +4739,11 @@ mod tests {
46894739 assert ! ( !added. same_credentials( & installed) ) ;
46904740
46914741 reinstall_tokens ( & state, 12 , & [ ( "GITHUB_TOKEN" , "a" ) ] ) ;
4692- assert ! ( !state. installed_credential_versions( ) . same_credentials( & added) ) ;
4742+ assert ! (
4743+ !state
4744+ . installed_credential_versions( )
4745+ . same_credentials( & added)
4746+ ) ;
46934747 }
46944748
46954749 #[ test]
@@ -4702,7 +4756,11 @@ mod tests {
47024756 assert ! ( !revoked. same_credentials( & installed) ) ;
47034757
47044758 state. revoke_static_provider_environment ( 12 ) ;
4705- assert ! ( state. installed_credential_versions( ) . same_credentials( & revoked) ) ;
4759+ assert ! (
4760+ state
4761+ . installed_credential_versions( )
4762+ . same_credentials( & revoked)
4763+ ) ;
47064764 }
47074765
47084766 #[ test]
0 commit comments