Пример #1
0
 def test_backend(self):
     session_path = utils_dbus.create_connection('vpn-openconnect', '/')
     dbus_session = ConnectionSession('com.deepin.daemon.Network',
                                      session_path)
     uuid = dbus_session.Uuid
     dbus_session.SetKey('alias-vpn-openconnect', 'gateway',
                         json.dumps(utils.get_ansible_server_host()))
     dbus_session.SetKey('alias-vpn-openconnect', 'cacert',
                         json.dumps(accounts.vpn_openconnect_cert_cacert))
     self.assertTrue(dbus_session.Save())
     utils_dbus.test_active_connection(self, uuid, "/")
Пример #2
0
 def test_backend(self):
     session_path = utils_dbus.create_connection('pppoe', '/')
     dbus_session = ConnectionSession('com.deepin.daemon.Network',
                                      session_path)
     uuid = dbus_session.Uuid
     dbus_session.SetKey('pppoe', 'service',
                         json.dumps(accounts.pppoe_service))
     dbus_session.SetKey('pppoe', 'username',
                         json.dumps(accounts.pppoe_username))
     dbus_session.SetKey('pppoe', 'password',
                         json.dumps(accounts.pppoe_password))
     self.assertTrue(dbus_session.Save())
     utils_dbus.test_active_connection(
         self, uuid, utils_dbus.get_default_wired_device())
 def test_backend(self):
     session_path = utils_dbus.create_connection('wireless', '/')
     dbus_session = ConnectionSession('com.deepin.daemon.Network',
                                      session_path)
     uuid = dbus_session.Uuid
     dbus_session.SetKey('802-11-wireless', 'ssid',
                         json.dumps(accounts.router_wireless_ssid))
     dbus_session.SetKey('802-11-wireless-security', 'vk-key-mgmt',
                         json.dumps("wep"))
     dbus_session.SetKey('802-11-wireless-security', 'wep-key0',
                         json.dumps(accounts.router_wireless_wep_password))
     self.assertTrue(dbus_session.Save())
     utils_dbus.test_active_connection(
         self, uuid, utils_dbus.get_default_wireless_device())
 def test_backend(self):
     session_path = utils_dbus.create_connection('vpn-pptp', '/')
     dbus_session = ConnectionSession('com.deepin.daemon.Network',
                                      session_path)
     uuid = dbus_session.Uuid
     dbus_session.SetKey('alias-vpn-pptp', 'gateway',
                         json.dumps(utils.get_ansible_server_host()))
     dbus_session.SetKey('alias-vpn-pptp', 'user',
                         json.dumps(accounts.vpn_pptp_username))
     dbus_session.SetKey('alias-vpn-pptp', 'password',
                         json.dumps(accounts.vpn_pptp_password))
     dbus_session.SetKey('alias-vpn-pptp-ppp', 'vk-require-mppe',
                         json.dumps(False))
     self.assertTrue(dbus_session.Save())
     utils_dbus.test_active_connection(self, uuid, "/")
 def test_backend(self):
     session_path = utils_dbus.create_connection('vpn-pptp', '/')
     dbus_session = ConnectionSession('com.deepin.daemon.Network',
                                      session_path)
     uuid = dbus_session.Uuid
     dbus_session.SetKey('alias-vpn-pptp', 'gateway',
                         json.dumps(utils.get_ansible_server_host()))
     dbus_session.SetKey('alias-vpn-pptp', 'user',
                         json.dumps(accounts.vpn_pptp_username))
     dbus_session.SetKey('alias-vpn-pptp', 'password',
                         json.dumps(accounts.vpn_pptp_password))
     self.assertTrue(dbus_session.Save())
     # try to connect/disconnect twice to check reconnect failed issue for vpn-pptp
     utils_dbus.test_active_connection(self, uuid, "/", delete_conn=False)
     utils_dbus.test_active_connection(self, uuid, "/", delete_conn=True)
 def test_backend(self):
     session_path = utils_dbus.create_connection('vpn-l2tp', '/')
     dbus_session = ConnectionSession('com.deepin.daemon.Network',
                                      session_path)
     uuid = dbus_session.Uuid
     dbus_session.SetKey('alias-vpn-l2tp', 'gateway',
                         json.dumps(utils.get_ansible_server_host()))
     dbus_session.SetKey('alias-vpn-l2tp', 'user',
                         json.dumps(accounts.vpn_l2tp_username))
     dbus_session.SetKey('alias-vpn-l2tp', 'password',
                         json.dumps(accounts.vpn_l2tp_password))
     dbus_session.SetKey('alias-vpn-l2tp-ipsec', 'ipsec-enabled',
                         json.dumps(True))
     dbus_session.SetKey('alias-vpn-l2tp-ipsec', 'ipsec-psk',
                         json.dumps(accounts.vpn_l2tp_ipsec_key))
     self.assertTrue(dbus_session.Save())
     utils_dbus.test_active_connection(self, uuid, "/")
 def test_backend(self):
     session_path = utils_dbus.create_connection('vpn-openvpn', '/')
     dbus_session = ConnectionSession('com.deepin.daemon.Network',
                                      session_path)
     uuid = dbus_session.Uuid
     dbus_session.SetKey('alias-vpn-openvpn', 'connection-type',
                         json.dumps('password'))
     dbus_session.SetKey('alias-vpn-openvpn', 'remote',
                         json.dumps(utils.get_ansible_server_host()))
     dbus_session.SetKey('alias-vpn-openvpn', 'username',
                         json.dumps(accounts.vpn_openvpn_password_username))
     dbus_session.SetKey('alias-vpn-openvpn', 'password',
                         json.dumps(accounts.vpn_openvpn_password_password))
     dbus_session.SetKey('alias-vpn-openvpn', 'ca',
                         json.dumps(accounts.vpn_openvpn_password_cacert))
     self.assertTrue(dbus_session.Save())
     utils_dbus.test_active_connection(self, uuid, "/")
 def test_backend_strongswan_privatekey(self):
     session_path = utils_dbus.create_connection('vpn-strongswan', '/')
     dbus_session = ConnectionSession('com.deepin.daemon.Network',
                                      session_path)
     uuid = dbus_session.Uuid
     dbus_session.SetKey('alias-vpn-strongswan', 'address',
                         json.dumps(utils.get_ansible_server_host()))
     dbus_session.SetKey('alias-vpn-strongswan', 'certificate',
                         json.dumps(accounts.vpn_strongswan_cacert))
     dbus_session.SetKey('alias-vpn-strongswan', 'method',
                         json.dumps('key'))
     dbus_session.SetKey('alias-vpn-strongswan', 'usercert',
                         json.dumps(accounts.vpn_strongswan_clientcert))
     dbus_session.SetKey('alias-vpn-strongswan', 'userkey',
                         json.dumps(accounts.vpn_strongswan_clientkey))
     dbus_session.SetKey('alias-vpn-strongswan', 'virtual',
                         json.dumps(True))  # request an inner IP address
     self.assertTrue(dbus_session.Save())
     utils_dbus.test_active_connection(self, uuid, "/")
 def test_backend_peap(self):
     session_path = utils_dbus.create_connection('wireless', '/')
     dbus_session = ConnectionSession('com.deepin.daemon.Network',
                                      session_path)
     uuid = dbus_session.Uuid
     dbus_session.SetKey('802-11-wireless', 'ssid',
                         json.dumps(accounts.router_wireless_ssid))
     dbus_session.SetKey('802-11-wireless-security', 'vk-key-mgmt',
                         json.dumps("wpa-eap"))
     dbus_session.SetKey('802-1x', 'vk-eap', json.dumps("peap"))
     dbus_session.SetKey('802-1x', 'identity',
                         json.dumps(accounts.freeradius_identity))
     dbus_session.SetKey('802-1x', 'vk-ca-cert',
                         json.dumps(accounts.freeradius_cacert))
     dbus_session.SetKey('802-1x', 'password',
                         json.dumps(accounts.freeradius_password))
     self.assertTrue(dbus_session.Save())
     utils_dbus.test_active_connection(
         self, uuid, utils_dbus.get_default_wireless_device())
Пример #10
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# This example will create connection for target wifi and try to connect to it.

import json

import utils_dbus

from dbus_gen.com_deepin_daemon_Network import Network
from dbus_gen.com_deepin_daemon_Network_ConnectionSession import ConnectionSession

dbus_network = Network('com.deepin.daemon.Network', '/com/deepin/daemon/Network')

wifi_ssid = "test"
wifi_psk = "12345678"

# ensure target network device enabled
dbus_network.EnableDevice(utils_dbus.get_default_wireless_device(), True)

session_path = utils_dbus.create_connection('wireless', utils_dbus.get_default_wireless_device())
dbus_session = ConnectionSession('com.deepin.daemon.Network', session_path)
uuid = dbus_session.Uuid
dbus_session.SetKey('802-11-wireless', 'ssid', json.dump(wifi_ssid))
dbus_session.SetKey('802-11-wireless-security', 'vk-key-mgmt', json.dumps("wpa-psk"))
dbus_session.SetKey('802-11-wireless-security', 'psk', json.dump(wifi_psk))
dbus_session.Save()
path = dbus_network.ActivateConnection(uuid, utils_dbus.get_default_wireless_device())
print(path)