• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2#   Copyright 2020 - The Android Open Source Project
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
17from acts import base_test
18from acts.test_decorators import test_tracker_info
19from acts.test_utils.net import connectivity_const
20from acts.test_utils.net import net_test_utils as nutils
21from acts.test_utils.wifi import wifi_test_utils as wutils
22
23VPN_CONST = connectivity_const.VpnProfile
24VPN_TYPE = connectivity_const.VpnProfileType
25VPN_PARAMS = connectivity_const.VpnReqParams
26
27
28class IKEv2VpnOverWifiTest(base_test.BaseTestClass):
29  """IKEv2 VPN tests."""
30
31  def setup_class(self):
32    self.dut = self.android_devices[0]
33
34    required_params = dir(VPN_PARAMS)
35    required_params = [x for x in required_params if not x.startswith("__")]
36    self.unpack_userparams(req_param_names=required_params)
37    self.vpn_params = {
38        "vpn_username": self.vpn_username,
39        "vpn_password": self.vpn_password,
40        "psk_secret": self.psk_secret,
41        "client_pkcs_file_name": self.client_pkcs_file_name,
42        "cert_path_vpnserver": self.cert_path_vpnserver,
43        "cert_password": self.cert_password,
44        "vpn_identity": self.vpn_identity,
45    }
46
47    wutils.wifi_test_device_init(self.dut)
48    wutils.connect_to_wifi_network(self.dut, self.wifi_network)
49
50  def teardown_class(self):
51    wutils.reset_wifi(self.dut)
52
53  def on_fail(self, test_name, begin_time):
54    self.dut.take_bug_report(test_name, begin_time)
55
56  ### Test cases ###
57
58  @test_tracker_info(uuid="4991755c-321d-4e9a-ada9-fc821a35bb5b")
59  def test_ikev2_psk_vpn_wifi(self):
60    vpn = VPN_TYPE.IKEV2_IPSEC_PSK
61    server_addr = self.vpn_server_addresses[vpn.name][0]
62    vpn_addr = self.vpn_verify_addresses[vpn.name][0]
63    vpn_profile = nutils.generate_ikev2_vpn_profile(
64        self.dut, self.vpn_params, vpn, server_addr, self.log_path)
65    nutils.legacy_vpn_connection_test_logic(self.dut, vpn_profile, vpn_addr)
66
67  @test_tracker_info(uuid="04d88575-7b96-4746-bff8-a1d6841e202e")
68  def test_ikev2_mschapv2_vpn_wifi(self):
69    vpn = VPN_TYPE.IKEV2_IPSEC_USER_PASS
70    server_addr = self.vpn_server_addresses[vpn.name][0]
71    vpn_addr = self.vpn_verify_addresses[vpn.name][0]
72    vpn_profile = nutils.generate_ikev2_vpn_profile(
73        self.dut, self.vpn_params, vpn, server_addr, self.log_path)
74    nutils.legacy_vpn_connection_test_logic(self.dut, vpn_profile, vpn_addr)
75
76  @test_tracker_info(uuid="e65f8a3e-f807-4493-822e-377dd6fa89cd")
77  def test_ikev2_rsa_vpn_wifi(self):
78    vpn = VPN_TYPE.IKEV2_IPSEC_RSA
79    server_addr = self.vpn_server_addresses[vpn.name][0]
80    self.vpn_params["server_addr"] = server_addr
81    vpn_addr = self.vpn_verify_addresses[vpn.name][0]
82    vpn_profile = nutils.generate_ikev2_vpn_profile(
83        self.dut, self.vpn_params, vpn, server_addr, self.log_path)
84    nutils.legacy_vpn_connection_test_logic(self.dut, vpn_profile, vpn_addr)
85