1 /*
2  * Copyright 2018 The gRPC Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package io.grpc.alts.internal;
18 
19 import static com.google.common.truth.Truth.assertThat;
20 
21 import com.google.common.collect.ImmutableList;
22 import io.grpc.alts.internal.TransportSecurityCommon.RpcProtocolVersions;
23 import org.junit.Test;
24 import org.junit.runner.RunWith;
25 import org.junit.runners.JUnit4;
26 
27 /** Unit tests for {@link AltsClientOptions}. */
28 @RunWith(JUnit4.class)
29 public final class AltsClientOptionsTest {
30 
31   @Test
setAndGet()32   public void setAndGet() throws Exception {
33     String targetName = "foo";
34     String serviceAccount1 = "bar1";
35     String serviceAccount2 = "bar2";
36     RpcProtocolVersions rpcVersions =
37         RpcProtocolVersions.newBuilder()
38             .setMaxRpcVersion(
39                 RpcProtocolVersions.Version.newBuilder().setMajor(2).setMinor(1).build())
40             .setMinRpcVersion(
41                 RpcProtocolVersions.Version.newBuilder().setMajor(2).setMinor(1).build())
42             .build();
43     ImmutableList<String> serviceAccounts = ImmutableList.of(serviceAccount1, serviceAccount2);
44 
45     AltsClientOptions options =
46         new AltsClientOptions.Builder()
47             .setTargetName(targetName)
48             .setTargetServiceAccounts(serviceAccounts)
49             .setRpcProtocolVersions(rpcVersions)
50             .build();
51 
52     assertThat(options.getTargetName()).isEqualTo(targetName);
53     assertThat(options.getTargetServiceAccounts()).containsAllOf(serviceAccount1, serviceAccount2);
54     assertThat(options.getRpcProtocolVersions()).isEqualTo(rpcVersions);
55   }
56 }
57