From c15493777115a293378500c146c139e6349f8f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Alberto=20D=C3=ADaz=20Orozco=20=28Akiel=29?= Date: Mon, 26 Feb 2024 20:09:23 +0000 Subject: [PATCH 1/2] Add port option to key creation starting in 1.8.1, you can specify a port for your new keys --- outline_vpn/outline_vpn.py | 5 ++++- test_outline_vpn.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/outline_vpn/outline_vpn.py b/outline_vpn/outline_vpn.py index 9bc1f8e..a983bcc 100644 --- a/outline_vpn/outline_vpn.py +++ b/outline_vpn/outline_vpn.py @@ -1,6 +1,7 @@ """ API wrapper for Outline VPN """ + import typing from dataclasses import dataclass @@ -131,6 +132,7 @@ def create_key( method: str = None, password: str = None, data_limit: int = None, + port: int = None, ) -> OutlineKey: """Create a new key""" @@ -143,7 +145,8 @@ def create_key( payload["password"] = password if data_limit: payload["limit"] = {"bytes": data_limit} - + if port: + payload["port"] = port if key_id: payload["id"] = key_id response = self.session.put( diff --git a/test_outline_vpn.py b/test_outline_vpn.py index 8b8df63..d072b36 100644 --- a/test_outline_vpn.py +++ b/test_outline_vpn.py @@ -60,11 +60,13 @@ def test_create_key_with_attributes(client: OutlineVPN): data_limit=1024 * 1024 * 20, method="aes-192-gcm", password="test", + port=4545, ) assert key.name == "Another test key" assert key.method == "aes-192-gcm" assert key.password == "test" assert key.data_limit == 1024 * 1024 * 20 + assert key.port == 4545 assert client.delete_key(key.key_id) From 3d9c6e3f548e3960b2942328072058faa60731dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Alberto=20D=C3=ADaz=20Orozco=20=28Akiel=29?= Date: Mon, 26 Feb 2024 20:11:00 +0000 Subject: [PATCH 2/2] Add port to test when creating with id --- test_outline_vpn.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test_outline_vpn.py b/test_outline_vpn.py index d072b36..256b36a 100644 --- a/test_outline_vpn.py +++ b/test_outline_vpn.py @@ -79,12 +79,14 @@ def test_create_key_with_attributes_and_id(client: OutlineVPN): data_limit=1024 * 1024 * 20, method="aes-192-gcm", password="test", + port=2323, ) assert key.key_id == key_id assert key.name == "Yet another test key" assert key.method == "aes-192-gcm" assert key.password == "test" assert key.data_limit == 1024 * 1024 * 20 + assert key.port == 2323 assert client.delete_key(key.key_id)