|
21 | 21 |
|
22 | 22 | import com.google.api.gax.grpc.ChannelFactory; |
23 | 23 | import com.google.common.collect.Iterables; |
| 24 | +import io.grpc.Attributes; |
24 | 25 | import io.grpc.CallOptions; |
25 | 26 | import io.grpc.ClientCall; |
26 | 27 | import io.grpc.ManagedChannel; |
@@ -112,6 +113,8 @@ public void setUp() throws IOException { |
112 | 113 | // Capture the listener when start is called |
113 | 114 | // Configure mockClientCall.start to capture the listener |
114 | 115 | doNothing().when(mockClientCall).start(listenerCaptor.capture(), any(Metadata.class)); |
| 116 | + // Default to no ALTS context |
| 117 | + when(mockClientCall.getAttributes()).thenReturn(Attributes.EMPTY); |
115 | 118 | } |
116 | 119 |
|
117 | 120 | private BigtableChannelPool.Entry getSingleEntry() { |
@@ -233,4 +236,16 @@ public void testMixedRpcs() { |
233 | 236 | assertThat(entry.getAndResetErrorCount()).isEqualTo(1); // The last failure |
234 | 237 | assertThat(entry.totalOutstandingRpcs()).isEqualTo(0); |
235 | 238 | } |
| 239 | + |
| 240 | + @Test |
| 241 | + public void testNonAltsChannelReturnsFalse() { |
| 242 | + // empty attributes |
| 243 | + // cannot test true value as logic is complicated. |
| 244 | + // alts check looks at attributes.get(AltsProtocolNegotiator.AUTH_CONTEXT_KEY); |
| 245 | + when(mockClientCall.getAttributes()).thenReturn(Attributes.EMPTY); |
| 246 | + BigtableChannelPool.Entry entry = getSingleEntry(); |
| 247 | + assertThat(entry.isAltsHolder.get()).isNull(); |
| 248 | + startCall(unaryMethodDescriptor); |
| 249 | + assertThat(entry.isAltsChannel()).isFalse(); |
| 250 | + } |
236 | 251 | } |
0 commit comments