From 0425935c46f370189110e8622d33f8167218440c Mon Sep 17 00:00:00 2001 From: Gijs Molenaar Date: Fri, 20 Jul 2018 17:10:44 +0200 Subject: [PATCH] fix all test errors --- .dockerignore | 5 ++- .travis.yml | 14 ++---- docker/Dockerfile.centos_7_py2 | 7 ++- docker/Dockerfile.centos_7_rpm | 3 ++ docker/Dockerfile.debian_jessie_py2 | 5 ++- docker/Dockerfile.debian_jessie_py3 | 5 ++- docker/Dockerfile.fedora_25_py2 | 20 --------- docker/Dockerfile.fedora_25_py3 | 19 -------- docker/Dockerfile.fedora_25_rpm | 43 ------------------- docker/Dockerfile.fedora_26_py2 | 20 --------- docker/Dockerfile.fedora_26_py3 | 19 -------- docker/Dockerfile.fedora_26_rpm | 43 ------------------- docker/Dockerfile.fedora_27_py2 | 5 ++- docker/Dockerfile.fedora_27_py3 | 5 ++- docker/Dockerfile.fedora_27_rpm | 11 +++-- docker/Dockerfile.fedora_28_py2 | 5 ++- docker/Dockerfile.fedora_28_py3 | 5 ++- docker/Dockerfile.fedora_28_rpm | 8 +++- docker/Dockerfile.ubuntu_artful_py2 | 23 ---------- docker/Dockerfile.ubuntu_artful_py3 | 23 ---------- ...enial_doc => Dockerfile.ubuntu_bionic_doc} | 2 +- docker/Dockerfile.ubuntu_bionic_py2 | 5 ++- docker/Dockerfile.ubuntu_bionic_py3 | 5 ++- docker/Dockerfile.ubuntu_bionic_py3_pep8 | 7 ++- docker/Dockerfile.ubuntu_xenial_py2 | 5 ++- docker/Dockerfile.ubuntu_xenial_py3 | 22 ---------- eduvpn-client.spec | 16 ++++++- eduvpn/config.py | 5 --- eduvpn/crypto.pyi | 5 ++- eduvpn/main.py | 1 - eduvpn/openvpn.py | 4 +- eduvpn/steps/instance.py | 2 +- eduvpn/steps/instance.pyi | 2 +- eduvpn/steps/yubi_enroll.pyi | 6 +-- eduvpn/util.pyi | 5 ++- rpm/centos7.spec | 8 ++++ setup.py | 3 +- tests/online.py | 9 ++-- tests/steps/test_totp_enroll.py | 27 ++++++++++++ tests/steps/test_two_way_auth.py | 1 + tests/test_online.py | 7 ++- 41 files changed, 149 insertions(+), 286 deletions(-) delete mode 100644 docker/Dockerfile.fedora_25_py2 delete mode 100644 docker/Dockerfile.fedora_25_py3 delete mode 100644 docker/Dockerfile.fedora_25_rpm delete mode 100644 docker/Dockerfile.fedora_26_py2 delete mode 100644 docker/Dockerfile.fedora_26_py3 delete mode 100644 docker/Dockerfile.fedora_26_rpm delete mode 100644 docker/Dockerfile.ubuntu_artful_py2 delete mode 100644 docker/Dockerfile.ubuntu_artful_py3 rename docker/{Dockerfile.ubuntu_xenial_doc => Dockerfile.ubuntu_bionic_doc} (92%) delete mode 100644 docker/Dockerfile.ubuntu_xenial_py3 create mode 100644 tests/steps/test_totp_enroll.py diff --git a/.dockerignore b/.dockerignore index e1fa6987..a407f3f5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,11 +3,12 @@ .gitignore .idea .ipynb_checkpoints -.virtualenv/ -.virtualenv3/ +.virtualenv*/ +.venv*/ .tox tmp build dist *.egg-info/ .eggs/ +doc/_build/ diff --git a/.travis.yml b/.travis.yml index 56edf134..d0e5387e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,26 +4,17 @@ matrix: - env: DIST=centos_7_py2 - env: DIST=debian_jessie_py2 - env: DIST=debian_jessie_py3 - - env: DIST=fedora_25_py2 - - env: DIST=fedora_25_py3 - - env: DIST=fedora_26_py2 - - env: DIST=fedora_26_py3 - env: DIST=fedora_27_py2 - env: DIST=fedora_27_py3 - env: DIST=fedora_28_py2 - env: DIST=fedora_28_py3 - - env: DIST=fedora_25_rpm - - env: DIST=fedora_26_rpm - env: DIST=fedora_27_rpm - env: DIST=fedora_28_rpm - env: DIST=ubuntu_xenial_py2 - - env: DIST=ubuntu_xenial_py3 - - env: DIST=ubuntu_xenial_doc - - env: DIST=ubuntu_artful_py2 - - env: DIST=ubuntu_artful_py3 - env: DIST=ubuntu_bionic_py2 - env: DIST=ubuntu_bionic_py3 - env: DIST=ubuntu_bionic_py3_pep8 + - env: DIST=ubuntu_bionic_doc sudo: required services: - docker @@ -44,3 +35,6 @@ deploy: tags: true distributions: sdist bdist_wheel repo: eduvpn/python-eduvpn-client +notifications: + email: + on_fail: always \ No newline at end of file diff --git a/docker/Dockerfile.centos_7_py2 b/docker/Dockerfile.centos_7_py2 index 51f1a484..8f3ecacb 100644 --- a/docker/Dockerfile.centos_7_py2 +++ b/docker/Dockerfile.centos_7_py2 @@ -15,11 +15,14 @@ RUN yum install -y \ python2-dateutil \ python2-mock \ python2-pip \ + python2-cryptography \ + python-qrcode \ + python-pillow \ pytest ADD . /code WORKDIR /code -RUN pip install --upgrade setuptools +RUN pip install --upgrade setuptools pip RUN pip install . -RUN py.test +RUN py.test -vv diff --git a/docker/Dockerfile.centos_7_rpm b/docker/Dockerfile.centos_7_rpm index 69f1f1d4..819b960d 100644 --- a/docker/Dockerfile.centos_7_rpm +++ b/docker/Dockerfile.centos_7_rpm @@ -19,6 +19,9 @@ RUN yum install -y \ python2-requests-oauthlib \ python2-mock \ python2-pytest-runner \ + python2-cryptography \ + python-qrcode \ + python-pillow \ gcc # GCC is required for the test run that will compile and install pynacl manually diff --git a/docker/Dockerfile.debian_jessie_py2 b/docker/Dockerfile.debian_jessie_py2 index 1183df83..656ed62a 100644 --- a/docker/Dockerfile.debian_jessie_py2 +++ b/docker/Dockerfile.debian_jessie_py2 @@ -14,7 +14,10 @@ RUN docker-apt-install \ python-pip \ python-mock \ python-repoze.lru \ - python-pytest + python-pytest \ + python-cryptography \ + python-qrcode \ + python-pillow ADD . /code WORKDIR /code diff --git a/docker/Dockerfile.debian_jessie_py3 b/docker/Dockerfile.debian_jessie_py3 index 2fb632fa..22942f80 100644 --- a/docker/Dockerfile.debian_jessie_py3 +++ b/docker/Dockerfile.debian_jessie_py3 @@ -12,7 +12,10 @@ RUN docker-apt-install \ python3-dateutil \ python3-mock \ python3-repoze.lru \ - python3-pytest + python3-pytest \ + python3-cryptography \ + python3-qrcode \ + python3-pillow ADD . /code diff --git a/docker/Dockerfile.fedora_25_py2 b/docker/Dockerfile.fedora_25_py2 deleted file mode 100644 index 52d16817..00000000 --- a/docker/Dockerfile.fedora_25_py2 +++ /dev/null @@ -1,20 +0,0 @@ -FROM fedora:25 - -RUN dnf install -y \ - libnotify \ - gtk3 \ - dbus-python \ - python-repoze-lru \ - python-gobject \ - python2-pynacl \ - python2-requests-oauthlib \ - python2-configparser \ - python2-future \ - python2-dateutil \ - python2-mock \ - python2-pytest - -ADD . /code -WORKDIR /code -RUN python setup.py install -RUN python setup.py test \ No newline at end of file diff --git a/docker/Dockerfile.fedora_25_py3 b/docker/Dockerfile.fedora_25_py3 deleted file mode 100644 index dce53cec..00000000 --- a/docker/Dockerfile.fedora_25_py3 +++ /dev/null @@ -1,19 +0,0 @@ -FROM fedora:25 - -RUN dnf install -y \ - libnotify \ - gtk3 \ - python3-dbus \ - python3-pynacl \ - python3-requests-oauthlib \ - python3-repoze-lru \ - python3-gobject \ - python3-future \ - python3-dateutil \ - python3-mock \ - python3-pytest - -ADD . /code -WORKDIR /code -RUN python3 setup.py install -RUN python3 setup.py test diff --git a/docker/Dockerfile.fedora_25_rpm b/docker/Dockerfile.fedora_25_rpm deleted file mode 100644 index fed5543b..00000000 --- a/docker/Dockerfile.fedora_25_rpm +++ /dev/null @@ -1,43 +0,0 @@ -FROM fedora:25 - -RUN dnf install -y \ - fedora-packager \ - fedora-review \ - - gtk3 \ - libnotify \ - - python2-devel \ - python-gobject \ - python2-configparser \ - python2-future \ - python2-pynacl \ - python2-requests-oauthlib \ - python-repoze-lru \ - dbus-python \ - - python3-devel \ - python3-future \ - python3-gobject \ - python3-pynacl \ - python3-requests-oauthlib \ - python3-dbus \ - python3-repoze-lru \ - - pytest \ - python2-mock \ - python2-pytest-runner \ - python3-pytest-runner - -RUN rpmdev-setuptree - -ADD . /code -WORKDIR /code - -RUN python setup.py sdist -RUN cp dist/*.tar.gz /root/rpmbuild/SOURCES/. -RUN rpmbuild -bs eduvpn-client.spec -RUN rpmbuild -bb eduvpn-client.spec - - - diff --git a/docker/Dockerfile.fedora_26_py2 b/docker/Dockerfile.fedora_26_py2 deleted file mode 100644 index 58fa21f5..00000000 --- a/docker/Dockerfile.fedora_26_py2 +++ /dev/null @@ -1,20 +0,0 @@ -FROM fedora:26 - -RUN dnf install -y \ - libnotify \ - gtk3 \ - dbus-python \ - python-repoze-lru \ - python-gobject \ - python2-pynacl \ - python2-requests-oauthlib \ - python2-configparser \ - python2-future \ - python2-dateutil \ - python2-mock \ - python2-pytest - -ADD . /code -WORKDIR /code -RUN python setup.py install -RUN python setup.py test diff --git a/docker/Dockerfile.fedora_26_py3 b/docker/Dockerfile.fedora_26_py3 deleted file mode 100644 index 5dc33f2c..00000000 --- a/docker/Dockerfile.fedora_26_py3 +++ /dev/null @@ -1,19 +0,0 @@ -FROM fedora:26 - -RUN dnf install -y \ - libnotify \ - gtk3 \ - python3-dbus \ - python3-pynacl \ - python3-requests-oauthlib \ - python3-repoze-lru \ - python3-gobject \ - python3-future \ - python3-dateutil \ - python3-mock \ - python3-pytest - -ADD . /code -WORKDIR /code -RUN python3 setup.py install -RUN python3 setup.py test diff --git a/docker/Dockerfile.fedora_26_rpm b/docker/Dockerfile.fedora_26_rpm deleted file mode 100644 index 1d05289a..00000000 --- a/docker/Dockerfile.fedora_26_rpm +++ /dev/null @@ -1,43 +0,0 @@ -FROM fedora:26 - -RUN dnf install -y \ - fedora-packager \ - fedora-review \ - - gtk3 \ - libnotify \ - - python2-devel \ - python-gobject \ - python2-configparser \ - python2-future \ - python2-pynacl \ - python2-requests-oauthlib \ - python-repoze-lru \ - dbus-python \ - - python3-devel \ - python3-future \ - python3-gobject \ - python3-pynacl \ - python3-requests-oauthlib \ - python3-dbus \ - python3-repoze-lru \ - - pytest \ - python2-mock \ - python3-pytest-runner \ - python2-pytest-runner - -RUN rpmdev-setuptree - -ADD . /code -WORKDIR /code - -RUN python setup.py sdist -RUN cp dist/*.tar.gz /root/rpmbuild/SOURCES/. -RUN rpmbuild -bs eduvpn-client.spec -RUN rpmbuild -bb eduvpn-client.spec - - - diff --git a/docker/Dockerfile.fedora_27_py2 b/docker/Dockerfile.fedora_27_py2 index 386ba18f..0ba069a9 100644 --- a/docker/Dockerfile.fedora_27_py2 +++ b/docker/Dockerfile.fedora_27_py2 @@ -12,7 +12,10 @@ RUN dnf install -y \ python2-future \ python2-dateutil \ python2-mock \ - python2-pytest + python2-pytest \ + python2-cryptography \ + python-qrcode \ + python2-pillow ADD . /code WORKDIR /code diff --git a/docker/Dockerfile.fedora_27_py3 b/docker/Dockerfile.fedora_27_py3 index 3ecce060..41719843 100644 --- a/docker/Dockerfile.fedora_27_py3 +++ b/docker/Dockerfile.fedora_27_py3 @@ -11,7 +11,10 @@ RUN dnf install -y \ python3-future \ python3-dateutil \ python3-mock \ - python3-pytest + python3-pytest \ + python3-cryptography \ + python3-qrcode \ + python3-pillow ADD . /code WORKDIR /code diff --git a/docker/Dockerfile.fedora_27_rpm b/docker/Dockerfile.fedora_27_rpm index 933b63fa..abd1f45a 100644 --- a/docker/Dockerfile.fedora_27_rpm +++ b/docker/Dockerfile.fedora_27_rpm @@ -6,16 +6,17 @@ RUN dnf install -y \ gtk3 \ libnotify \ - python2-devel \ python-gobject \ python2-configparser \ python2-future \ python2-pynacl \ python2-requests-oauthlib \ + python2-cryptography \ + python2-qrcode \ + python2-pillow python-repoze-lru \ dbus-python \ - python3-devel \ python3-future \ python3-gobject \ @@ -23,11 +24,13 @@ RUN dnf install -y \ python3-requests-oauthlib \ python3-dbus \ python3-repoze-lru \ - pytest \ python2-mock \ python2-pytest-runner \ - python3-pytest-runner + python3-pytest-runner \ + python3-cryptography \ + python3-qrcode \ + python3-pillow RUN rpmdev-setuptree diff --git a/docker/Dockerfile.fedora_28_py2 b/docker/Dockerfile.fedora_28_py2 index 84d39516..79e2c57f 100644 --- a/docker/Dockerfile.fedora_28_py2 +++ b/docker/Dockerfile.fedora_28_py2 @@ -12,7 +12,10 @@ RUN dnf install -y \ python2-future \ python2-dateutil \ python2-mock \ - python2-pytest + python2-pytest \ + python2-cryptography \ + python2-qrcode \ + python2-pillow ADD . /code WORKDIR /code diff --git a/docker/Dockerfile.fedora_28_py3 b/docker/Dockerfile.fedora_28_py3 index 5da85905..510bf2c8 100644 --- a/docker/Dockerfile.fedora_28_py3 +++ b/docker/Dockerfile.fedora_28_py3 @@ -11,7 +11,10 @@ RUN dnf install -y \ python3-future \ python3-dateutil \ python3-mock \ - python3-pytest + python3-pytest \ + python3-cryptography \ + python3-qrcode \ + python3-pillow ADD . /code WORKDIR /code diff --git a/docker/Dockerfile.fedora_28_rpm b/docker/Dockerfile.fedora_28_rpm index 2aab7d89..63fb9d63 100644 --- a/docker/Dockerfile.fedora_28_rpm +++ b/docker/Dockerfile.fedora_28_rpm @@ -11,6 +11,9 @@ RUN dnf install -y \ python2-future \ python2-pynacl \ python2-requests-oauthlib \ + python2-cryptography \ + python2-qrcode \ + python2-pillow \ python-repoze-lru \ dbus-python \ python3-devel \ @@ -24,7 +27,10 @@ RUN dnf install -y \ python2-mock \ python3-mock \ python2-pytest-runner \ - python3-pytest-runner + python3-pytest-runner \ + python3-cryptography \ + python3-qrcode \ + python3-pillow RUN rpmdev-setuptree diff --git a/docker/Dockerfile.ubuntu_artful_py2 b/docker/Dockerfile.ubuntu_artful_py2 deleted file mode 100644 index 7eacaf80..00000000 --- a/docker/Dockerfile.ubuntu_artful_py2 +++ /dev/null @@ -1,23 +0,0 @@ -FROM ubuntu:artful - -ADD docker/docker-apt-install /usr/local/bin/docker-apt-install -RUN docker-apt-install \ - gir1.2-gtk-3.0 \ - gir1.2-notify-0.7 \ - libnotify4 \ - python-gi \ - python-dbus \ - python-nacl \ - python-requests-oauthlib \ - python-configparser \ - python-future \ - python-repoze.lru \ - python-dateutil \ - python-mock \ - python-setuptools \ - python-pytest - -ADD . /code -WORKDIR /code -RUN python setup.py install -RUN python setup.py test diff --git a/docker/Dockerfile.ubuntu_artful_py3 b/docker/Dockerfile.ubuntu_artful_py3 deleted file mode 100644 index 4a8af2ff..00000000 --- a/docker/Dockerfile.ubuntu_artful_py3 +++ /dev/null @@ -1,23 +0,0 @@ -FROM ubuntu:artful - -ADD docker/docker-apt-install /usr/local/bin/docker-apt-install -RUN docker-apt-install \ - gir1.2-gtk-3.0 \ - gir1.2-notify-0.7 \ - libnotify4 \ - python3-gi \ - python3-dbus \ - python3-nacl \ - python3-requests-oauthlib \ - python3-future \ - python3-dateutil \ - python3-repoze.lru \ - python3-pip \ - python3-mock \ - python3-setuptools \ - python3-pytest - -ADD . /code -WORKDIR /code -RUN python3 setup.py install -RUN python3 setup.py test diff --git a/docker/Dockerfile.ubuntu_xenial_doc b/docker/Dockerfile.ubuntu_bionic_doc similarity index 92% rename from docker/Dockerfile.ubuntu_xenial_doc rename to docker/Dockerfile.ubuntu_bionic_doc index 20de55a7..0178f1c8 100644 --- a/docker/Dockerfile.ubuntu_xenial_doc +++ b/docker/Dockerfile.ubuntu_bionic_doc @@ -1,4 +1,4 @@ -FROM ubuntu:xenial +FROM ubuntu:bionic ADD docker/docker-apt-install /usr/local/bin/docker-apt-install RUN docker-apt-install \ diff --git a/docker/Dockerfile.ubuntu_bionic_py2 b/docker/Dockerfile.ubuntu_bionic_py2 index b7a0f83c..2af573a1 100644 --- a/docker/Dockerfile.ubuntu_bionic_py2 +++ b/docker/Dockerfile.ubuntu_bionic_py2 @@ -15,7 +15,10 @@ RUN docker-apt-install \ python-dateutil \ python-mock \ python-setuptools \ - python-pytest + python-pytest \ + python-cryptography \ + python-qrcode \ + python-pillow ADD . /code WORKDIR /code diff --git a/docker/Dockerfile.ubuntu_bionic_py3 b/docker/Dockerfile.ubuntu_bionic_py3 index bd3d1d99..6b24523e 100644 --- a/docker/Dockerfile.ubuntu_bionic_py3 +++ b/docker/Dockerfile.ubuntu_bionic_py3 @@ -15,7 +15,10 @@ RUN docker-apt-install \ python3-pip \ python3-mock \ python3-setuptools \ - python3-pytest + python3-pytest \ + python3-cryptography \ + python3-qrcode \ + python3-pillow ADD . /code WORKDIR /code diff --git a/docker/Dockerfile.ubuntu_bionic_py3_pep8 b/docker/Dockerfile.ubuntu_bionic_py3_pep8 index 3dc7018c..c0d45698 100644 --- a/docker/Dockerfile.ubuntu_bionic_py3_pep8 +++ b/docker/Dockerfile.ubuntu_bionic_py3_pep8 @@ -16,8 +16,13 @@ RUN docker-apt-install \ python3-mock \ python3-setuptools \ python3-pytest \ - pep8 + python3-cryptography \ + python3-qrcode \ + python3-pillow \ + pep8 \ + mypy ADD . /code WORKDIR /code RUN pep8 eduvpn --ignore=E501,E402,W391,W292 +#RUN mypy eduvpn diff --git a/docker/Dockerfile.ubuntu_xenial_py2 b/docker/Dockerfile.ubuntu_xenial_py2 index 8ad2ef40..63155190 100644 --- a/docker/Dockerfile.ubuntu_xenial_py2 +++ b/docker/Dockerfile.ubuntu_xenial_py2 @@ -15,7 +15,10 @@ RUN docker-apt-install \ python-dateutil \ python-mock \ python-pytest \ - python-setuptools + python-setuptools \ + python-cryptography \ + python-qrcode \ + python-pillow ADD . /code diff --git a/docker/Dockerfile.ubuntu_xenial_py3 b/docker/Dockerfile.ubuntu_xenial_py3 deleted file mode 100644 index 9eb678b1..00000000 --- a/docker/Dockerfile.ubuntu_xenial_py3 +++ /dev/null @@ -1,22 +0,0 @@ -FROM ubuntu:xenial - -ADD docker/docker-apt-install /usr/local/bin/docker-apt-install -RUN docker-apt-install \ - gir1.2-gtk-3.0 \ - gir1.2-notify-0.7 \ - libnotify4 \ - python3-setuptools \ - python3-gi \ - python3-dbus \ - python3-nacl \ - python3-requests-oauthlib \ - python3-future \ - python3-dateutil \ - python3-repoze.lru \ - python3-mock \ - python3-pytest - -ADD . /code -WORKDIR /code -RUN python3 setup.py install -RUN python3 setup.py test diff --git a/eduvpn-client.spec b/eduvpn-client.spec index ba314bf0..e1346495 100644 --- a/eduvpn-client.spec +++ b/eduvpn-client.spec @@ -23,6 +23,9 @@ BuildRequires: python2-requests-oauthlib BuildRequires: python2-configparser BuildRequires: python2-future BuildRequires: python2-mock +BuildRequires: python2-cryptography +BuildRequires: python2-qrcode +BuildRequires: python2-pillow BuildRequires: python-repoze-lru BuildRequires: python3-devel BuildRequires: python2-dateutil @@ -34,7 +37,9 @@ BuildRequires: python3-future BuildRequires: python3-dateutil BuildRequires: python3-repoze-lru BuildRequires: python3-mock - +BuildRequires: python3-cryptography +BuildRequires: python3-qrcode +BuildRequires: python3-pillow %description @@ -51,7 +56,9 @@ Requires: python2-configparser Requires: python2-future Requires: python2-dateutil Requires: python-repoze-lru - +Requires: python2-cryptography +Requires: python2-qrcode +Requires: python2-pillow %description -n python2-eduvpn-client eduVPN client API for Python2 @@ -67,6 +74,9 @@ Requires: python3-gobject Requires: python3-future Requires: python3-dateutil Requires: python3-repoze-lru +Requires: python3-cryptography +Requires: python3-qrcode +Requires: python3-qrcode %description -n python3-eduvpn-client eduVPN client API for Python3 @@ -126,6 +136,8 @@ eduVPN desktop client %{_datarootdir}/eduvpn/builder/redirecturl.ui %{_datarootdir}/eduvpn/builder/token.ui %{_datarootdir}/eduvpn/builder/window.ui +%{_datarootdir}/eduvpn/builder/totp_enroll.ui +%{_datarootdir}/eduvpn/builder/yubi_enroll.ui %{_datarootdir}/icons/hicolor/128x128/apps/eduvpn-client.png %{_datarootdir}/icons/hicolor/256x256/apps/eduvpn-client.png %{_datarootdir}/icons/hicolor/48x48/apps/eduvpn-client.png diff --git a/eduvpn/config.py b/eduvpn/config.py index beaf2e86..5cd2aca4 100644 --- a/eduvpn/config.py +++ b/eduvpn/config.py @@ -17,11 +17,6 @@ institute_access_uri_dev = 'https://static.eduvpn.nl/disco/institute_access_dev.json' verify_key_dev = ' zzls4TZTXHEyV3yxaxag1DZw3tSpIdBoaaOjUGH/Rwg=.' -# use for debugging -#secure_internet_uri = secure_internet_uri_dev -#institute_access_uri = institute_access_uri_dev -#verify_key = verify_key_dev - locale = "en-US" diff --git a/eduvpn/crypto.pyi b/eduvpn/crypto.pyi index a96b502d..3d6bd20a 100644 --- a/eduvpn/crypto.pyi +++ b/eduvpn/crypto.pyi @@ -3,9 +3,10 @@ # Copyright: 2017, The Commons Conservancy eduVPN Programme # SPDX-License-Identifier: GPL-3.0+ import nacl.signing +from typing import Optional -def common_name_from_cert(pem_data: str) -> str: -def gen_code_verifier(length: int = ...): ... +def common_name_from_cert(pem_data: str) -> str: ... +def gen_code_verifier(length: Optional[int]): ... def gen_code_challenge(code_verifier): ... def make_verifier(key: str) -> nacl.signing.VerifyKey: ... def gen_base32(length: int = ...) -> str: ... \ No newline at end of file diff --git a/eduvpn/main.py b/eduvpn/main.py index 2774edb6..f71798ee 100644 --- a/eduvpn/main.py +++ b/eduvpn/main.py @@ -75,7 +75,6 @@ def init(): return edu_vpn_app - def main(): init() Gtk.main() diff --git a/eduvpn/openvpn.py b/eduvpn/openvpn.py index 04a6cf27..5b55962d 100644 --- a/eduvpn/openvpn.py +++ b/eduvpn/openvpn.py @@ -99,8 +99,8 @@ def ovpn_to_nm(config, meta, display_name, username=None): } # issue #138, not supported by older network-manager-openvpn - #if 'server-poll-timeout' in config: - # settings['vpn']['data']['connect-timeout'] = config['server-poll-timeout'] + # if 'server-poll-timeout' in config: + # settings['vpn']['data']['connect-timeout'] = config['server-poll-timeout'] if 'comp-lzo' in config: settings['vpn']['data']['comp-lzo'] = config['comp-lzo'] or 'adaptive' diff --git a/eduvpn/steps/instance.py b/eduvpn/steps/instance.py index 739bde82..83301580 100644 --- a/eduvpn/steps/instance.py +++ b/eduvpn/steps/instance.py @@ -38,7 +38,7 @@ def fetch_instance_step(meta, builder, verifier): window = builder.get_object('eduvpn-window') dialog.set_transient_for(window) dialog.show_all() - thread_helper(lambda: _fetch_background( meta=meta, verifier=verifier, builder=builder)) + thread_helper(lambda: _fetch_background(meta=meta, verifier=verifier, builder=builder)) dialog.run() diff --git a/eduvpn/steps/instance.pyi b/eduvpn/steps/instance.pyi index 2c72ca1e..d28c69cf 100644 --- a/eduvpn/steps/instance.pyi +++ b/eduvpn/steps/instance.pyi @@ -5,6 +5,6 @@ from eduvpn.metadata import Metadata -def _fetch_background(dialog, meta:Metadata, verifier, builder): ... +def _fetch_background(meta:Metadata, verifier, builder): ... def fetch_instance_step(meta: Metadata, builder, verifier): ... def select_instance_step(meta: Metadata, instances, builder, verifier): ... diff --git a/eduvpn/steps/yubi_enroll.pyi b/eduvpn/steps/yubi_enroll.pyi index f3360404..b618a621 100644 --- a/eduvpn/steps/yubi_enroll.pyi +++ b/eduvpn/steps/yubi_enroll.pyi @@ -1,6 +1,6 @@ from eduvpn.metadata import Metadata -def yubi_enroll_window(builder, oauth, meta: Metadata, config_dict: {}) -> None: ... -def _parse_user_input(builder, oauth, meta: Metadata, config_dict: {}) -> None: ... -def _enroll(builder, oauth, meta: Metadata, config_dict: {}, key: str) -> None: ... +def yubi_enroll_window(builder, oauth, meta: Metadata, config_dict: dict) -> None: ... +def _parse_user_input(builder, oauth, meta: Metadata, config_dict: dict) -> None: ... +def _enroll(builder, oauth, meta: Metadata, config_dict: dict, key: str) -> None: ... diff --git a/eduvpn/util.pyi b/eduvpn/util.pyi index 17fdc6e2..2516c6ed 100644 --- a/eduvpn/util.pyi +++ b/eduvpn/util.pyi @@ -4,12 +4,15 @@ # SPDX-License-Identifier: GPL-3.0+ from typing import Any, Optional +from pil import Image +import gi +from gi.repository import GdkPixbuf def make_unique_id(): ... def error_helper(parent, msg_big, msg_small): ... def thread_helper(func): ... def bytes2pixbuf(data, width: Any = ..., height: Any = ..., display_name: Optional[Any] = ...): ... -def pil2pixbuf(img: "pil.Image.Image") -> "GdkPixbuf.Pixbuf": +def pil2pixbuf(img: Image.Image) -> GdkPixbuf.Pixbuf: ... def get_prefix(): ... def have_dbus(): ... def get_pixbuf(): ... diff --git a/rpm/centos7.spec b/rpm/centos7.spec index b43d6d08..05c0fdc3 100644 --- a/rpm/centos7.spec +++ b/rpm/centos7.spec @@ -24,6 +24,9 @@ BuildRequires: python2-configparser BuildRequires: python2-future BuildRequires: python2-mock BuildRequires: python-dateutil +BuildRequires: python2-cryptography +BuildRequires: python-qrcode +BuildRequires: python-pillow BuildRequires: gcc # GCC is required for the test run that will compile and install pynacl manually @@ -43,6 +46,9 @@ Requires: python2-requests-oauthlib Requires: python2-configparser Requires: python2-future Requires: python2-dateutil +Requires: python2-cryptography +Requires: python-qrcode +Requires: python-pillow %description -n python2-eduvpn-client @@ -95,6 +101,8 @@ eduVPN desktop client %{_datarootdir}/eduvpn/builder/redirecturl.ui %{_datarootdir}/eduvpn/builder/token.ui %{_datarootdir}/eduvpn/builder/window.ui +%{_datarootdir}/eduvpn/builder/totp_enroll.ui +%{_datarootdir}/eduvpn/builder/yubi_enroll.ui %{_datarootdir}/icons/hicolor/128x128/apps/eduvpn-client.png %{_datarootdir}/icons/hicolor/256x256/apps/eduvpn-client.png %{_datarootdir}/icons/hicolor/48x48/apps/eduvpn-client.png diff --git a/setup.py b/setup.py index 8a7327a7..43b3ee8c 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,8 @@ 'python-dateutil', 'six', 'repoze.lru', - 'qrcode[pil]', + 'qrcode', + 'pillow', 'cryptography', ] diff --git a/tests/online.py b/tests/online.py index be989e37..3751a548 100644 --- a/tests/online.py +++ b/tests/online.py @@ -1,9 +1,6 @@ from os import environ import logging -import mechanicalsoup -from pyotp import TOTP from future.moves.urllib.parse import urlparse -from concurrent.futures import ThreadPoolExecutor from eduvpn.exceptions import EduvpnAuthException from eduvpn.metadata import Metadata from eduvpn.crypto import gen_code_verifier @@ -23,6 +20,12 @@ def check_online_tests(): return False +if check_online_tests(): + import mechanicalsoup + from pyotp import TOTP + from concurrent.futures import ThreadPoolExecutor + + def disable_2fa(user, password, totp_secret, base_url): prefix = "/vpn-admin-portal" admin_url = base_url + prefix diff --git a/tests/steps/test_totp_enroll.py b/tests/steps/test_totp_enroll.py new file mode 100644 index 00000000..fcec5152 --- /dev/null +++ b/tests/steps/test_totp_enroll.py @@ -0,0 +1,27 @@ +from unittest import TestCase +from eduvpn.steps.totp_enroll import totp_enroll_window, _make_qr, _parse_user_input +from eduvpn.metadata import Metadata +from tests.util import MockBuilder, MockOAuth +from tests.mock_config import mock_config_dict + + +class TestTotpEnroll(TestCase): + @classmethod + def setUp(cls): + cls.builder = MockBuilder() + cls.meta = Metadata() + cls.meta.api_base_uri = "https://bla.bla/bla" + cls.oauth = MockOAuth() + + def test_totp_enroll_window(self): + totp_enroll_window(builder=self.builder, config_dict=mock_config_dict, + meta=self.meta, oauth=self.oauth) + + def test_make(self): + _make_qr(builder=self.builder, config_dict=mock_config_dict, + meta=self.meta, oauth=self.oauth) + + def test_parse_user_input(self): + _parse_user_input(builder=self.builder, config_dict=mock_config_dict, + meta=self.meta, oauth=self.oauth, secret='bla') + diff --git a/tests/steps/test_two_way_auth.py b/tests/steps/test_two_way_auth.py index 926a494c..11e44be9 100644 --- a/tests/steps/test_two_way_auth.py +++ b/tests/steps/test_two_way_auth.py @@ -48,6 +48,7 @@ def test_two_auth_background_step_2fa_multiple(self): @patch('eduvpn.steps.two_way_auth.finalizing_step') @patch('eduvpn.steps.two_way_auth.Gtk.Dialog') + @patch('eduvpn.steps.two_way_auth.Gtk.Label') def test_choice_window(self, *_): _choice_window(builder=self.builder, meta=self.meta, oauth=self.oauth, options=['bla1', 'bla2'], config_dict=mock_config_dict) diff --git a/tests/test_online.py b/tests/test_online.py index 6e8cf2eb..21296f87 100644 --- a/tests/test_online.py +++ b/tests/test_online.py @@ -2,12 +2,15 @@ This test suite only runs when EDUVPN_TEST_ONLINE, EDUVPN_TEST_USER and EDUVPN_TEST_PASSWORD are set """ from unittest import TestCase, skipIf -from pyotp import TOTP from eduvpn.remote import two_factor_enroll_totp -from tests.online import get_oauth_token, check_online_tests, disable_2fa +from tests.online import check_online_tests online_tests = check_online_tests() +if online_tests: + from pyotp import TOTP + from tests.online import get_oauth_token, disable_2fa + INSTANCE_URI = "https://debian-vpn.tuxed.net" TOTP_SECRET = "QXU5GXJ3Y3Z7TCZG"