-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from guyonvarch/document-connman-service
Add initial tests and typings for the Kiosk browser proxy
- Loading branch information
Showing
8 changed files
with
128 additions
and
40 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
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,6 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
cd "$(dirname "$0")/.." | ||
|
||
mypy kiosk_browser | ||
python -m pytest |
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
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,19 @@ | ||
import dbus | ||
from kiosk_browser import proxy | ||
|
||
# Mock | ||
|
||
service = dbus.Struct((dbus.ObjectPath('/net/connman/service/wifi_a0510b58100d_517561657374791f6e657e2d4d7060046065_managed_psk'), dbus.Dictionary({dbus.String('Type'): dbus.String('wifi', variant_level=1), dbus.String('Security'): dbus.Array([dbus.String('psk')], signature=dbus.Signature('s'), variant_level=1), dbus.String('State'): dbus.String('online', variant_level=1), dbus.String('Strength'): dbus.Byte(51, variant_level=1), dbus.String('Favorite'): dbus.Boolean(True, variant_level=1), dbus.String('Immutable'): dbus.Boolean(False, variant_level=1), dbus.String('AutoConnect'): dbus.Boolean(True, variant_level=1), dbus.String('Name'): dbus.String('Super-Network', variant_level=1), dbus.String('Ethernet'): dbus.Dictionary({dbus.String('Method'): dbus.String('auto', variant_level=1), dbus.String('Interface'): dbus.String('wlp2s0', variant_level=1), dbus.String('Address'): dbus.String('B7:71:01:51:10:AD', variant_level=1), dbus.String('MTU'): dbus.UInt16(1500, variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv4'): dbus.Dictionary({dbus.String('Method'): dbus.String('dhcp', variant_level=1), dbus.String('Address'): dbus.String('192.168.1.1', variant_level=1), dbus.String('Netmask'): dbus.String('255.255.255.0', variant_level=1), dbus.String('Gateway'): dbus.String('192.168.1.254', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv4.Configuration'): dbus.Dictionary({dbus.String('Method'): dbus.String('dhcp', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv6'): dbus.Dictionary({dbus.String('Method'): dbus.String('auto', variant_level=1), dbus.String('Address'): dbus.String('0a21:e0f:5ba:7390:3304:872c:531c:cbad', variant_level=1), dbus.String('PrefixLength'): dbus.Byte(64, variant_level=1), dbus.String('Privacy'): dbus.String('prefered', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('IPv6.Configuration'): dbus.Dictionary({dbus.String('Method'): dbus.String('auto', variant_level=1), dbus.String('Privacy'): dbus.String('prefered', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('Nameservers'): dbus.Array([dbus.String('192.168.1.254')], signature=dbus.Signature('s'), variant_level=1), dbus.String('Nameservers.Configuration'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Timeservers'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Timeservers.Configuration'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Domains'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Domains.Configuration'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Proxy'): dbus.Dictionary({dbus.String('Servers'): dbus.Array([dbus.String('http://proxy.dividat.com:1234')], signature=dbus.Signature('s'), variant_level=1), dbus.String('Excludes'): dbus.Array([], signature=dbus.Signature('s'), variant_level=1), dbus.String('Method'): dbus.String('manual', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('Proxy.Configuration'): dbus.Dictionary({dbus.String('Servers'): dbus.Array([dbus.String('http://proxy.dividat.com')], signature=dbus.Signature('s'), variant_level=1), dbus.String('Method'): dbus.String('manual', variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1), dbus.String('mDNS'): dbus.Boolean(False, variant_level=1), dbus.String('mDNS.Configuration'): dbus.Boolean(False, variant_level=1), dbus.String('Provider'): dbus.Dictionary({}, signature=dbus.Signature('sv'), variant_level=1)}, signature=dbus.Signature('sv'))), signature=None) | ||
|
||
# Tests | ||
|
||
def test_parse_service(): | ||
s = proxy.parse_service(service) | ||
assert s.state == 'online' | ||
assert s.proxy == proxy.ProxyConf('proxy.dividat.com', 1234, None) | ||
|
||
def test_extract_manual_proxy(): | ||
assert proxy.parse_proxy_url('') == None | ||
assert proxy.parse_proxy_url('dividat') == None | ||
assert proxy.parse_proxy_url('dividat:88') == proxy.ProxyConf('dividat', 88, None) | ||
assert proxy.parse_proxy_url('user:pw@dividat:987') == proxy.ProxyConf('dividat', 987, proxy.Credentials('user', 'pw')) |
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 @@ | ||
[mypy] | ||
|
||
[mypy-PyQt5] | ||
ignore_missing_imports = True | ||
|
||
[mypy-PyQt5.QtNetwork] | ||
ignore_missing_imports = True | ||
|
||
[mypy-PyQt5.QtCore] | ||
ignore_missing_imports = True | ||
|
||
[mypy-PyQt5.QtGui] | ||
ignore_missing_imports = True | ||
|
||
[mypy-PyQt5.QtWidgets] | ||
ignore_missing_imports = True | ||
|
||
[mypy-dbus] | ||
ignore_missing_imports = True | ||
|
||
[mypy-dbus.mainloop.glib] | ||
ignore_missing_imports = True | ||
|
||
[mypy-gi.repository] | ||
ignore_missing_imports = True |
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 |
---|---|---|
@@ -1,8 +1,16 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
|
||
# Integration tests | ||
|
||
INTEGRATION_TEST_DIR="$(dirname "$(realpath "$0")")/integration" | ||
|
||
for TEST_DEF in $(ls "$INTEGRATION_TEST_DIR"/*.nix); do | ||
nix-build "$TEST_DEF" | ||
done | ||
|
||
# Kiosk browser | ||
|
||
pushd "$(dirname "$(realpath "$0")")/../kiosk" | ||
nix-shell --run bin/test | ||
popd |