def store_provider(meta): """Store the eduVPN configuration""" logger.info("storing profile with name {} using NetworkManager".format(meta.display_name)) meta.uuid = make_unique_id() ovpn_text = format_like_ovpn(meta.config, meta.cert, meta.key) config_dict = parse_ovpn(ovpn_text) cert_path = write_cert(meta.cert, 'cert', meta.uuid) key_path = write_cert(meta.key, 'key', meta.uuid) ca_path = write_cert(config_dict.pop('ca'), 'ca', meta.uuid) ta_path = write_cert(config_dict.pop('tls-auth'), 'ta', meta.uuid) nm_config = ovpn_to_nm(config_dict, uuid=meta.uuid, display_name=meta.display_name, username=meta.username) nm_config['vpn']['data'].update({'cert': cert_path, 'key': key_path, 'ca': ca_path, 'ta': ta_path}) insert_config(nm_config) meta.write() return meta.uuid
def store_provider(meta, config_dict): """Store the eduVPN configuration""" logger.info("storing profile with name {} using NetworkManager".format(meta.display_name)) new = False if not meta.uuid: meta.uuid = make_unique_id() new = True cert_path = write_cert(meta.cert, 'cert', meta.uuid) key_path = write_cert(meta.key, 'key', meta.uuid) nm_config = ovpn_to_nm(config_dict, meta=meta, display_name=meta.display_name, username=meta.username) nm_config['vpn']['data'].update({'cert': cert_path, 'key': key_path}) if new: insert_config(nm_config) else: update_config_provider(meta, config_dict) meta.write() return meta.uuid
def test_make_unique_id(self): make_unique_id()
def setUp(self): self.meta = Metadata() self.meta.uuid = make_unique_id() self.meta.cert = "testcert" self.meta.key = "testkey" self.meta.config = mock_config