18
18
19
19
import com .google .common .truth .Expect ;
20
20
import io .grpc .s2a .internal .handshaker .S2AIdentity ;
21
+ import io .grpc .s2a .internal .handshaker .tokenmanager .AccessTokenManager ;
21
22
import io .grpc .s2a .internal .handshaker .tokenmanager .SingleTokenFetcher ;
22
23
import java .util .Optional ;
23
24
import org .junit .AfterClass ;
25
+ import org .junit .Before ;
24
26
import org .junit .BeforeClass ;
25
27
import org .junit .Rule ;
26
28
import org .junit .Test ;
@@ -33,6 +35,7 @@ public final class GetAuthenticationMechanismsTest {
33
35
@ Rule public final Expect expect = Expect .create ();
34
36
private static final String TOKEN = "access_token" ;
35
37
private static String originalAccessToken ;
38
+ private Optional <AccessTokenManager > tokenManager ;
36
39
37
40
@ BeforeClass
38
41
public static void setUpClass () {
@@ -41,6 +44,11 @@ public static void setUpClass() {
41
44
SingleTokenFetcher .setAccessToken (TOKEN );
42
45
}
43
46
47
+ @ Before
48
+ public void setUp () {
49
+ tokenManager = AccessTokenManager .create ();
50
+ }
51
+
44
52
@ AfterClass
45
53
public static void tearDownClass () {
46
54
SingleTokenFetcher .setAccessToken (originalAccessToken );
@@ -49,7 +57,7 @@ public static void tearDownClass() {
49
57
@ Test
50
58
public void getAuthMechanisms_emptyIdentity_success () {
51
59
expect
52
- .that (GetAuthenticationMechanisms .getAuthMechanism (Optional .empty ()))
60
+ .that (GetAuthenticationMechanisms .getAuthMechanism (Optional .empty (), tokenManager ))
53
61
.isEqualTo (
54
62
Optional .of (AuthenticationMechanism .newBuilder ().setToken ("access_token" ).build ()));
55
63
}
@@ -58,7 +66,7 @@ public void getAuthMechanisms_emptyIdentity_success() {
58
66
public void getAuthMechanisms_nonEmptyIdentity_success () {
59
67
S2AIdentity fakeIdentity = S2AIdentity .fromSpiffeId ("fake-spiffe-id" );
60
68
expect
61
- .that (GetAuthenticationMechanisms .getAuthMechanism (Optional .of (fakeIdentity )))
69
+ .that (GetAuthenticationMechanisms .getAuthMechanism (Optional .of (fakeIdentity ), tokenManager ))
62
70
.isEqualTo (
63
71
Optional .of (
64
72
AuthenticationMechanism .newBuilder ()
0 commit comments