1818
1919import com .google .common .truth .Expect ;
2020import io .grpc .s2a .internal .handshaker .S2AIdentity ;
21+ import io .grpc .s2a .internal .handshaker .tokenmanager .AccessTokenManager ;
2122import io .grpc .s2a .internal .handshaker .tokenmanager .SingleTokenFetcher ;
2223import java .util .Optional ;
2324import org .junit .AfterClass ;
25+ import org .junit .Before ;
2426import org .junit .BeforeClass ;
2527import org .junit .Rule ;
2628import org .junit .Test ;
@@ -33,6 +35,7 @@ public final class GetAuthenticationMechanismsTest {
3335 @ Rule public final Expect expect = Expect .create ();
3436 private static final String TOKEN = "access_token" ;
3537 private static String originalAccessToken ;
38+ private Optional <AccessTokenManager > tokenManager ;
3639
3740 @ BeforeClass
3841 public static void setUpClass () {
@@ -41,6 +44,11 @@ public static void setUpClass() {
4144 SingleTokenFetcher .setAccessToken (TOKEN );
4245 }
4346
47+ @ Before
48+ public void setUp () {
49+ tokenManager = AccessTokenManager .create ();
50+ }
51+
4452 @ AfterClass
4553 public static void tearDownClass () {
4654 SingleTokenFetcher .setAccessToken (originalAccessToken );
@@ -49,7 +57,7 @@ public static void tearDownClass() {
4957 @ Test
5058 public void getAuthMechanisms_emptyIdentity_success () {
5159 expect
52- .that (GetAuthenticationMechanisms .getAuthMechanism (Optional .empty ()))
60+ .that (GetAuthenticationMechanisms .getAuthMechanism (Optional .empty (), tokenManager ))
5361 .isEqualTo (
5462 Optional .of (AuthenticationMechanism .newBuilder ().setToken ("access_token" ).build ()));
5563 }
@@ -58,7 +66,7 @@ public void getAuthMechanisms_emptyIdentity_success() {
5866 public void getAuthMechanisms_nonEmptyIdentity_success () {
5967 S2AIdentity fakeIdentity = S2AIdentity .fromSpiffeId ("fake-spiffe-id" );
6068 expect
61- .that (GetAuthenticationMechanisms .getAuthMechanism (Optional .of (fakeIdentity )))
69+ .that (GetAuthenticationMechanisms .getAuthMechanism (Optional .of (fakeIdentity ), tokenManager ))
6270 .isEqualTo (
6371 Optional .of (
6472 AuthenticationMechanism .newBuilder ()
0 commit comments