-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add endpoint for getting the Proxy settings
relates-to: #69
- Loading branch information
1 parent
dbadc74
commit ac795c4
Showing
10 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,6 @@ dist/ | |
|
||
# Test Reports | ||
.coverage | ||
cov/ | ||
cov/ | ||
|
||
boinc_client.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from marshmallow import Schema, fields | ||
|
||
|
||
class ProxySettings(Schema): | ||
autodetect_port = fields.Str() | ||
autodetect_protocol = fields.Str() | ||
autodetect_server_name = fields.Str() | ||
http_server_name = fields.Str(allow_none=True) | ||
http_server_port = fields.Int(allow_none=True) | ||
http_user_name = fields.Str(allow_none=True) | ||
http_user_passwd = fields.Str(allow_none=True) | ||
no_autodetect = fields.Str(allow_none=True) | ||
no_proxy = fields.Str(allow_none=True) | ||
socks5_remote_dns = fields.Str(allow_none=True) | ||
socks5_user_name = fields.Str(allow_none=True) | ||
socks5_user_passwd = fields.Str(allow_none=True) | ||
socks_server_name = fields.Str(allow_none=True) | ||
socks_server_port = fields.Int(allow_none=True) | ||
use_http_auth = fields.Str() | ||
use_http_proxy = fields.Str() | ||
use_socks_proxy = fields.Str() | ||
|
||
|
||
class ProxyInfo(Schema): | ||
proxy_info = fields.Nested(ProxySettings()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import xmltodict | ||
|
||
from boinc_client.clients.rpc_client import RpcClient | ||
from boinc_client.models.proxy_settings import ProxyInfo | ||
|
||
|
||
def get_proxy_settings(client: RpcClient) -> dict: | ||
rpc_resp = client.make_request("<get_proxy_settings/>") | ||
rpc_json = xmltodict.parse(rpc_resp) | ||
return ProxyInfo().load(rpc_json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from pytest import fixture | ||
|
||
|
||
@fixture | ||
def proxy_settings_xml() -> str: | ||
return """<proxy_info> | ||
<socks_server_name>foo</socks_server_name> | ||
<socks_server_port>foo</socks_server_port> | ||
<http_server_name>foo</http_server_name> | ||
<http_server_port>foo</http_server_port> | ||
<socks5_user_name>foo</socks5_user_name> | ||
<socks5_user_passwd>foo</socks5_user_passwd> | ||
<socks5_remote_dns>foo</socks5_remote_dns> | ||
<http_user_name>foo</http_user_name> | ||
<http_user_passwd>foo</http_user_passwd> | ||
<no_autodetect>foo</no_autodetect> | ||
<no_proxy>foo</no_proxy> | ||
</proxy_info>""" | ||
|
||
|
||
@fixture | ||
def proxy_settings_dict() -> dict: | ||
return { | ||
"proxy_info": { | ||
"socks_server_name": "foo", | ||
"socks_server_port": "foo", | ||
"http_server_name": "foo", | ||
"http_server_port": "foo", | ||
"socks5_user_name": "foo", | ||
"socks5_user_passwd": "foo", | ||
"socks5_remote_dns": "foo", | ||
"http_user_name": "foo", | ||
"http_user_passwd": "foo", | ||
"no_autodetect": "foo", | ||
"no_proxy": "foo", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from boinc_client.network import get_proxy_settings | ||
|
||
|
||
def test_can_get_proxy_settings( | ||
mocker, mock_rpc_client, proxy_settings_xml, proxy_settings_dict | ||
): | ||
mocker.patch( | ||
"boinc_client.clients.rpc_client.RpcClient.make_request", | ||
return_value=proxy_settings_xml, | ||
) | ||
assert get_proxy_settings(client=mock_rpc_client) == proxy_settings_dict | ||
assert True |