Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-protonvpn-nm-lib for openSUSE:Factory checked in at 2022-03-08 20:31:48 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-protonvpn-nm-lib (Old) and /work/SRC/openSUSE:Factory/.python-protonvpn-nm-lib.new.2349 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-protonvpn-nm-lib" Tue Mar 8 20:31:48 2022 rev:3 rq:960105 version:3.7.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-protonvpn-nm-lib/python-protonvpn-nm-lib.changes 2021-10-27 22:21:46.371216103 +0200 +++ /work/SRC/openSUSE:Factory/.python-protonvpn-nm-lib.new.2349/python-protonvpn-nm-lib.changes 2022-03-11 11:33:02.578040402 +0100 @@ -1,0 +2,6 @@ +Thu Mar 3 15:07:18 UTC 2022 - Alexandre Vicenzi <alexandre.vice...@suse.com> + +- Update to 3.7.0 + * Bug fixes and improvments + +------------------------------------------------------------------- Old: ---- protonvpn-nm-lib-3.6.0.tar.gz New: ---- protonvpn-nm-lib-3.7.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-protonvpn-nm-lib.spec ++++++ --- /var/tmp/diff_new_pack.h8G4jW/_old 2022-03-11 11:33:03.130041049 +0100 +++ /var/tmp/diff_new_pack.h8G4jW/_new 2022-03-11 11:33:03.138041059 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-protonvpn-nm-lib # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-protonvpn-nm-lib -Version: 3.6.0 +Version: 3.7.0 Release: 0 Summary: ProtonVPN NetworkManager library License: GPL-3.0-or-later @@ -29,6 +29,7 @@ BuildRequires: %{python_module pytest-cov} BuildRequires: %{python_module pytest} BuildRequires: %{python_module pyxdg} +BuildRequires: %{python_module requests} BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros @@ -58,9 +59,6 @@ %python_install %python_expand %fdupes %{buildroot}%{python_sitelib}/protonvpn_nm_lib -%check -%pytest tests - %files %{python_files} %license LICENSE %doc README.md ++++++ protonvpn-nm-lib-3.6.0.tar.gz -> protonvpn-nm-lib-3.7.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/.coveragerc new/protonvpn-nm-lib-3.7.0/.coveragerc --- old/protonvpn-nm-lib-3.6.0/.coveragerc 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/.coveragerc 2021-11-25 12:57:46.000000000 +0100 @@ -1,6 +1,6 @@ [run] omit = - protonvpn_nm_lib/core/__init__.py - protonvpn_nm_lib/core/dbus_get_wrapper.py - protonvpn_nm_lib/core/abstract_interface_manager.py - protonvpn_nm_lib/core/reconnector_manager.py + protonvpn_nm_lib/core/logger.py + protonvpn_nm_lib/daemon/* + protonvpn_nm_lib/core/connection_backend/* + protonvpn_nm_lib/core/dbus/* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/.gitlab-ci.yml new/protonvpn-nm-lib-3.7.0/.gitlab-ci.yml --- old/protonvpn-nm-lib-3.6.0/.gitlab-ci.yml 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/.gitlab-ci.yml 2021-11-25 12:57:46.000000000 +0100 @@ -65,18 +65,6 @@ script: - make image-arch branch=$CI_COMMIT_REF_SLUG src=archlinux -make-image-fed31: - stage: image - extends: make-image-deb - script: - - make image-fed31 branch=$CI_COMMIT_REF_SLUG src=fedora31 - -make-image-fed32: - stage: image - extends: make-image-deb - script: - - make image-fed32 branch=$CI_COMMIT_REF_SLUG src=fedora32 - make-image-fed33: stage: image extends: make-image-deb @@ -88,6 +76,12 @@ extends: make-image-deb script: - make image-fed34 branch=$CI_COMMIT_REF_SLUG src=fedora34 + +make-image-fed35: + stage: image + extends: make-image-deb + script: + - make image-fed35 branch=$CI_COMMIT_REF_SLUG src=fedora35 ######### CI Test Jobs ########## test-deb: @@ -105,18 +99,6 @@ - job: make-image-arch image: $CI_REGISTRY_IMAGE/archlinux:branch-$CI_COMMIT_REF_SLUG -test-fed31: - extends: test-deb - needs: - - job: make-image-fed31 - image: $CI_REGISTRY_IMAGE/fedora31:branch-$CI_COMMIT_REF_SLUG - -test-fed32: - extends: test-deb - needs: - - job: make-image-fed32 - image: $CI_REGISTRY_IMAGE/fedora32:branch-$CI_COMMIT_REF_SLUG - test-fed33: extends: test-deb needs: @@ -128,6 +110,12 @@ needs: - job: make-image-fed34 image: $CI_REGISTRY_IMAGE/fedora34:branch-$CI_COMMIT_REF_SLUG + +test-fed35: + extends: test-deb + needs: + - job: make-image-fed35 + image: $CI_REGISTRY_IMAGE/fedora35:branch-$CI_COMMIT_REF_SLUG ## Jobs to publish commits + tags from master to github @@ -135,10 +123,9 @@ stage: release needs: - job: build-deb - - job: build-fed31 - - job: build-fed32 - job: build-fed33 - job: build-fed34 + - job: build-fed35 when: manual variables: RELEASE_SYNC_PUBLIC_URL: g...@github.com:ProtonVPN/protonvpn-nm-lib.git @@ -150,10 +137,9 @@ stage: release needs: - job: build-deb - - job: build-fed31 - - job: build-fed32 - job: build-fed33 - job: build-fed34 + - job: build-fed35 when: manual variables: RELEASE_SYNC_PUBLIC_URL: g...@github.com:ProtonVPN/protonvpn-nm-lib.git diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/Dockerfile.fed31 new/protonvpn-nm-lib-3.7.0/Dockerfile.fed31 --- old/protonvpn-nm-lib-3.6.0/Dockerfile.fed31 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/Dockerfile.fed31 1970-01-01 01:00:00.000000000 +0100 @@ -1,74 +0,0 @@ -FROM IMAGE_URL_FED31 -ARG git_repo -ENV git_repo=${git_repo:-GIT_REPO} -ARG git_branch -ENV git_branch=${git_branch:-GIT_BRANCH} - -RUN dnf update -y - -#??Install a few useful packages - -RUN dnf install -y net-tools \ - gcc \ - sudo \ - git \ - rpm-build \ - rpm-devel \ - rpmlint \ - rpmdevtools \ - rpm-sign \ - python3 \ - python3-pip \ - NetworkManager \ - NetworkManager-openvpn \ - sudo \ - vim \ - nano \ - pkg-config \ - openvpn \ - openssl-devel \ - openssl-libs \ - dbus-x11 \ - gnome-keyring \ - libsecret \ - gtk3 \ - polkit - -RUN dnf install -y \ - python3-pyxdg \ - python3-dbus \ - python3-keyring \ - python3-distro \ - python3-gobject \ - python3-jinja2 \ - python3-systemd - -RUN dnf install -y \ - python3-pytest \ - python3-pytest-cov - -RUN dnf install -y \ - python3-requests \ - python3-pyOpenSSL \ - python3-bcrypt \ - python3-gnupg - -RUN python3 -m pip install --upgrade sentry-sdk==0.10.2 - -RUN git clone --single-branch --branch $git_branch $git_repo -RUN cd proton-python-client && pip3 install -e . -RUN cd .. - -RUN useradd -ms /bin/bash user -RUN usermod -a -G wheel user -RUN echo '%wheel ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - -COPY docker_entry_rpm.sh /usr/local/bin -COPY . /home/user/protonvpn-nm-lib - -RUN chown -R user:user /home/user/protonvpn-nm-lib -WORKDIR /home/user/protonvpn-nm-lib - -USER user - -ENTRYPOINT ["/usr/local/bin/docker_entry_rpm.sh"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/Dockerfile.fed32 new/protonvpn-nm-lib-3.7.0/Dockerfile.fed32 --- old/protonvpn-nm-lib-3.6.0/Dockerfile.fed32 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/Dockerfile.fed32 1970-01-01 01:00:00.000000000 +0100 @@ -1,74 +0,0 @@ -FROM IMAGE_URL_FED32 -ARG git_repo -ENV git_repo=${git_repo:-GIT_REPO} -ARG git_branch -ENV git_branch=${git_branch:-GIT_BRANCH} - -RUN dnf update -y - -#??Install a few useful packages - -RUN dnf install -y net-tools \ - gcc \ - sudo \ - git \ - rpm-build \ - rpm-devel \ - rpmlint \ - rpmdevtools \ - rpm-sign \ - python3 \ - python3-pip \ - NetworkManager \ - NetworkManager-openvpn \ - sudo \ - vim \ - nano \ - pkg-config \ - openvpn \ - openssl-devel \ - openssl-libs \ - dbus-x11 \ - gnome-keyring \ - libsecret \ - gtk3 \ - polkit - -RUN dnf install -y \ - python3-pyxdg \ - python3-dbus \ - python3-keyring \ - python3-distro \ - python3-gobject \ - python3-jinja2 \ - python3-systemd - -RUN dnf install -y \ - python3-pytest \ - python3-pytest-cov - -RUN dnf install -y \ - python3-requests \ - python3-pyOpenSSL \ - python3-bcrypt \ - python3-gnupg - -RUN python3 -m pip install --upgrade sentry-sdk==0.10.2 - -RUN git clone --single-branch --branch $git_branch $git_repo -RUN cd proton-python-client && pip3 install -e . -RUN cd .. - -RUN useradd -ms /bin/bash user -RUN usermod -a -G wheel user -RUN echo '%wheel ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - -COPY docker_entry_rpm.sh /usr/local/bin -COPY . /home/user/protonvpn-nm-lib - -RUN chown -R user:user /home/user/protonvpn-nm-lib -WORKDIR /home/user/protonvpn-nm-lib - -USER user - -ENTRYPOINT ["/usr/local/bin/docker_entry_rpm.sh"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/Dockerfile.fed35 new/protonvpn-nm-lib-3.7.0/Dockerfile.fed35 --- old/protonvpn-nm-lib-3.6.0/Dockerfile.fed35 1970-01-01 01:00:00.000000000 +0100 +++ new/protonvpn-nm-lib-3.7.0/Dockerfile.fed35 2021-11-25 12:57:46.000000000 +0100 @@ -0,0 +1,74 @@ +FROM IMAGE_URL_FED35 +ARG git_repo +ENV git_repo=${git_repo:-GIT_REPO} +ARG git_branch +ENV git_branch=${git_branch:-GIT_BRANCH} + +RUN dnf update -y + +#??Install a few useful packages + +RUN dnf install -y net-tools \ + gcc \ + sudo \ + git \ + rpm-build \ + rpm-devel \ + rpmlint \ + rpmdevtools \ + rpm-sign \ + python3 \ + python3-pip \ + NetworkManager \ + NetworkManager-openvpn \ + sudo \ + vim \ + nano \ + pkg-config \ + openvpn \ + openssl-devel \ + openssl-libs \ + dbus-x11 \ + gnome-keyring \ + libsecret \ + gtk3 \ + polkit + +RUN dnf install -y \ + python3-pyxdg \ + python3-dbus \ + python3-keyring \ + python3-distro \ + python3-gobject \ + python3-jinja2 \ + python3-systemd + +RUN dnf install -y \ + python3-pytest \ + python3-pytest-cov + +RUN dnf install -y \ + python3-requests \ + python3-pyOpenSSL \ + python3-bcrypt \ + python3-gnupg + +RUN python3 -m pip install --upgrade sentry-sdk==0.10.2 + +RUN git clone --single-branch --branch $git_branch $git_repo +RUN cd proton-python-client && pip3 install -e . +RUN cd .. + +RUN useradd -ms /bin/bash user +RUN usermod -a -G wheel user +RUN echo '%wheel ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +COPY docker_entry_rpm.sh /usr/local/bin +COPY . /home/user/protonvpn-nm-lib + +RUN chown -R user:user /home/user/protonvpn-nm-lib +WORKDIR /home/user/protonvpn-nm-lib + +USER user + +ENTRYPOINT ["/usr/local/bin/docker_entry_rpm.sh"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/Makefile new/protonvpn-nm-lib-3.7.0/Makefile --- old/protonvpn-nm-lib-3.6.0/Makefile 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/Makefile 2021-11-25 12:57:46.000000000 +0100 @@ -13,14 +13,13 @@ endif IMAGE_URL_DEB = ubuntu:latest -IMAGE_URL_FED31 = fedora:31 -IMAGE_URL_FED32 = fedora:32 IMAGE_URL_FED33 = fedora:33 IMAGE_URL_FED34 = fedora:34 +IMAGE_URL_FED35 = fedora:35 IMAGE_URL_ARCH = archlinux:latest # Run make base to build both images based on ubuntu and fedora -base: image-deb image-fed31 image-fed32 image-fed33 image-fed34 image-arch +base: image-deb image-fed33 image-fed34 image-fed35 image-arch # Create the image based on ubuntu image-deb: image @@ -38,11 +37,6 @@ image-fed31: DOCKER_FILE_SOURCE = Dockerfile.fed31 image-fed31: src = fedora31 -# Create the image based on fedora 32 -image-fed32: image -image-fed32: DOCKER_FILE_SOURCE = Dockerfile.fed32 -image-fed32: src = fedora32 - # Create the image based on fedora 33 image-fed33: image image-fed33: DOCKER_FILE_SOURCE = Dockerfile.fed33 @@ -53,6 +47,11 @@ image-fed34: DOCKER_FILE_SOURCE = Dockerfile.fed34 image-fed34: src = fedora34 +# Create the image based on fedora 35 +image-fed35: image +image-fed35: DOCKER_FILE_SOURCE = Dockerfile.fed35 +image-fed35: src = fedora35 + ## Make remote image form a branch make image branch=<branchName> (master default) image: requirements.txt docker-source @@ -62,7 +61,7 @@ ## We host our own copy of the image ubuntu:latest docker-source: - sed "s|IMAGE_URL_FED31|$(IMAGE_URL_FED31)|; s|IMAGE_URL_FED32|$(IMAGE_URL_FED32)|; s|IMAGE_URL_FED33|$(IMAGE_URL_FED33)|; s|IMAGE_URL_FED34|$(IMAGE_URL_FED34)|; s|IMAGE_URL_DEB|$(IMAGE_URL_DEB)|; s|IMAGE_URL_ARCH|$(IMAGE_URL_ARCH)|" $(DOCKER_FILE_SOURCE) > /tmp/Dockerfile.image + sed "s|IMAGE_URL_FED33|$(IMAGE_URL_FED33)|; s|IMAGE_URL_FED34|$(IMAGE_URL_FED34)|; s|IMAGE_URL_FED35|$(IMAGE_URL_FED35)|; s|IMAGE_URL_DEB|$(IMAGE_URL_DEB)|; s|IMAGE_URL_ARCH|$(IMAGE_URL_ARCH)|" $(DOCKER_FILE_SOURCE) > /tmp/Dockerfile.image requirements.txt: @ touch requirements.txt @@ -79,23 +78,20 @@ @ rm -rf __SOURCE_APP || true local: NAME_IMAGE = protonvpn-nm-lib:latest -local-base: local-deb local-fed31 local-fed32 local-fed33 local-fed34 local-centos8 local-arch +local-base: local-deb local-fed33 local-fed34 local-fed35 local-centos8 local-arch local-deb: local local-deb: DOCKER_FILE_SOURCE = Dockerfile.deb -local-fed31: local -local-fed31: DOCKER_FILE_SOURCE = Dockerfile.fed31 - -local-fed32: local -local-fed32: DOCKER_FILE_SOURCE = Dockerfile.fed32 - local-fed33: local local-fed33: DOCKER_FILE_SOURCE = Dockerfile.fed33 local-fed34: local local-fed34: DOCKER_FILE_SOURCE = Dockerfile.fed34 +local-fed35: local +local-fed35: DOCKER_FILE_SOURCE = Dockerfile.fed35 + local-centos8: local local-centos8: DOCKER_FILE_SOURCE = Dockerfile.centos8 @@ -123,7 +119,7 @@ python3 -m pytest ## Run tests against the latest version of the image from your code -test-fed31: local-fed31 +test-fed33: local-fed33 # Keep -it because with colors it's better @ docker run \ --rm \ @@ -133,7 +129,7 @@ proton-python-client:latest \ python3 -m pytest -test-fed32: local-fed32 +test-fed34: local-fed34 # Keep -it because with colors it's better @ docker run \ --rm \ @@ -143,17 +139,7 @@ proton-python-client:latest \ python3 -m pytest -test-fed33: local-fed33 - # Keep -it because with colors it's better - @ docker run \ - --rm \ - -it \ - --privileged \ - --volume $(PWD)/.env:/home/user/proton-python-client.env \ - proton-python-client:latest \ - python3 -m pytest - -test-fed34: local-fed34 +test-fed35: local-fed35 # Keep -it because with colors it's better @ docker run \ --rm \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/arch/PKGBUILD new/protonvpn-nm-lib-3.7.0/arch/PKGBUILD --- old/protonvpn-nm-lib-3.6.0/arch/PKGBUILD 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/arch/PKGBUILD 2021-11-25 12:57:46.000000000 +0100 @@ -1,7 +1,7 @@ # Maintainer: Proton Technologies AG <opensou...@proton.me> pkgname=python-protonvpn-nm-lib -pkgver=3.6.0 -pkgrel=5 +pkgver=3.7.0 +pkgrel=6 pkgdesc="Official ProtonVPN NetworkManager library." arch=("any") url="https://github.com/ProtonVPN" @@ -9,7 +9,7 @@ groups=("ProtonVPN") depends=("python-proton-client" "networkmanager" "networkmanager-openvpn" "openvpn" "libnm" "dbus" "libsecret" "python-pyxdg" "python-keyring" "python-jinja" "python-distro" "python-dbus" "python-systemd" "xdg-utils" "python-gobject") makedepends=("python-setuptools") -conflicts=("protonvpn-cli<3.10.0" "protonvpn-cli<1.4.0") +conflicts=("protonvpn-cli<3.11.0" "protonvpn-cli<1.7.0") source=("$pkgname.tar.gz") sha256sums=(.) validpgpkeys=("A884 41BD 4864 F95B EE08 E63A 71EB 4740 1994 0E11") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/debian/changelog new/protonvpn-nm-lib-3.7.0/debian/changelog --- old/protonvpn-nm-lib-3.6.0/debian/changelog 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/debian/changelog 2021-11-25 12:57:46.000000000 +0100 @@ -1,3 +1,15 @@ +protonvpn-nm-lib (3.7.0-6) unstable; urgency=medium + + * Improve: Handle accounting use cases + + -- Proton Technologies AG <opensou...@proton.me> Thu, 11 Nov 2021 16:30:00 +0000 + +protonvpn-nm-lib (3.6.1-1) unstable; urgency=medium + + * Hotfix: Update event notifications + + -- Proton Technologies AG <opensou...@proton.me> Tue, 02 Nov 2021 12:30:00 +0000 + protonvpn-nm-lib (3.6.0-5) unstable; urgency=medium * Feature: Add notification polling diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/debian/control new/protonvpn-nm-lib-3.7.0/debian/control --- old/protonvpn-nm-lib-3.6.0/debian/control 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/debian/control 2021-11-25 12:57:46.000000000 +0100 @@ -11,7 +11,7 @@ Homepage: https://github.com/ProtonVPN Section: net Depends: ${python3:Depends}, ${misc:Depends}, python3-proton-client, network-manager, network-manager-openvpn, openvpn, python3-xdg, python3-keyring, python3-jinja2, python3-distro, gir1.2-nm-1.0, libsecret-tools, dbus-x11, network-manager-openvpn-gnome, python3-dbus, python3-systemd, xdg-utils, python3-gi -Breaks: protonvpn-cli (<< 3.10.0), protonvpn-gui (<< 1.4.0) +Breaks: protonvpn-cli (<< 3.11.0), protonvpn-gui (<< 1.7.0) Description: ProtonVPN NM library (Python 3) Package installs official ProtonVPN NetworkManager library. . diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/api.py new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/api.py --- old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/api.py 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/api.py 2021-11-25 12:57:46.000000000 +0100 @@ -5,7 +5,7 @@ from .core.utilities import Utilities from .core.report import BugReport from .enums import (ConnectionMetadataEnum, ConnectionTypeEnum, FeatureEnum, - MetadataEnum) + MetadataEnum, ServerTierEnum) from .logger import logger @@ -27,7 +27,7 @@ password (string) human_verification (optional; list|tuple) """ - self._utils.ensure_connectivity() + self._utils.ensure_internet_connection_is_available() self._env.api_session.authenticate(username, password, human_verification) def logout(self): @@ -44,7 +44,6 @@ Should be user either after setup_connection() or setup_reconnect(). """ - self._utils.ensure_internet_connection_is_available() connect_result = self._env.connection_backend.connect() self._env.connection_metadata.save_connect_time() return connect_result @@ -83,7 +82,7 @@ raise exceptions.UserSessionNotFound( "User session was not found, please login first." ) - self._utils.ensure_connectivity() + self._utils.ensure_internet_connection_is_available() ( _connection_type, @@ -97,6 +96,7 @@ } ) connect_configurations = { + ConnectionTypeEnum.FREE: self.config_for_fastest_free_server, ConnectionTypeEnum.SERVERNAME: self.config_for_server_with_servername, ConnectionTypeEnum.FASTEST: self.config_for_fastest_server, @@ -146,6 +146,23 @@ self._env.connection_backend.setup(**data) return server + def config_for_fastest_free_server(self, *_): + """Select fastest server. + + Returns: + LogicalServer + """ + secure_core = bool(self._env.settings.secure_core.value) + logger.info("Fastest with secure core \"{}\"".format(secure_core)) + try: + return self._env.api_session.servers.filter( + lambda server: server.tier == ServerTierEnum.FREE.value + ).get_fastest_server() + except exceptions.EmptyServerListError: + raise exceptions.FastestServerNotFound( + "Fastest server could not be found." + ) + def config_for_fastest_server(self, *_): """Select fastest server. @@ -157,7 +174,8 @@ try: return self._env.api_session.servers.filter( lambda server: - ( + server.tier <= ExecutionEnvironment().api_session.vpn_tier + and ( secure_core and FeatureEnum.SECURE_CORE in server.features ) or ( @@ -182,7 +200,8 @@ try: return self._env.api_session.servers.filter( lambda server: - server.exit_country.lower() == country_code.lower() + server.tier <= ExecutionEnvironment().api_session.vpn_tier + and server.exit_country.lower() == country_code.lower() and ( ( secure_core @@ -223,7 +242,8 @@ try: return self._env.api_session.servers.filter( lambda server: ( - all( + server.tier <= ExecutionEnvironment().api_session.vpn_tier + and all( chosen_feature in server.features for chosen_feature @@ -246,7 +266,9 @@ """ try: return self._env.api_session.servers.filter( - lambda server: server.name.lower() == servername.lower() # noqa + lambda server: + server.tier <= ExecutionEnvironment().api_session.vpn_tier + and server.name.lower() == servername.lower() # noqa ).get_fastest_server() except exceptions.EmptyServerListError: raise exceptions.ServernameServerNotFound( @@ -379,7 +401,7 @@ 1) It checks if there is internet connection 2) It checks if API can be reached """ - self._utils.ensure_connectivity() + self._utils.ensure_internet_connection_is_available() def get_bug_report(self): """Get bug report object.""" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/constants.py new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/constants.py --- old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/constants.py 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/constants.py 2021-11-25 12:57:46.000000000 +0100 @@ -13,7 +13,7 @@ SecureCoreStatusEnum, UserSettingConnectionEnum, UserSettingStatusEnum) -APP_VERSION = "3.6.0" +APP_VERSION = "3.7.0" API_URL = "https://api.protonvpn.ch" IPv6_LEAK_PROTECTION_CONN_NAME = "pvpn-ipv6leak-protection" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/accounting/__init__.py new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/accounting/__init__.py --- old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/accounting/__init__.py 1970-01-01 01:00:00.000000000 +0100 +++ new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/accounting/__init__.py 2021-11-25 12:57:46.000000000 +0100 @@ -0,0 +1,4 @@ +from .default_accounting import DefaultAccounting # noqa +from ._base import Accounting + +__all__ = ["Accounting"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/accounting/_base.py new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/accounting/_base.py --- old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/accounting/_base.py 1970-01-01 01:00:00.000000000 +0100 +++ new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/accounting/_base.py 2021-11-25 12:57:46.000000000 +0100 @@ -0,0 +1,17 @@ +from abc import ABCMeta, abstractmethod +from ..utils import SubclassesMixin +from ...logger import logger + + +class Accounting(SubclassesMixin, metaclass=ABCMeta): + + @classmethod + def get_backend(cls, backend="default"): + subclasses_dict = cls._get_subclasses_dict("accounting") + if backend not in subclasses_dict: + raise NotImplementedError("Backend not implemented") + logger.info( + "Accounting backend: {}".format(subclasses_dict[backend]) + ) + + return subclasses_dict[backend]() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/accounting/default_accounting.py new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/accounting/default_accounting.py --- old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/accounting/default_accounting.py 1970-01-01 01:00:00.000000000 +0100 +++ new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/accounting/default_accounting.py 2021-11-25 12:57:46.000000000 +0100 @@ -0,0 +1,69 @@ +from ... import exceptions +from ..environment import ExecutionEnvironment +from ..utilities import Utilities +from ._base import Accounting +from ...logger import logger + + +class DefaultAccounting(Accounting): + accounting = "default" + + def __init__(self): + self._env = ExecutionEnvironment() + + def ensure_accounting_has_expected_values(self): + """Ensure that accounting data is correct.""" + try: + Utilities.ensure_internet_connection_is_available() + except Exception as e: # noqa + logger.exception(e) + return + + try: + self.refresh_vpn_data() + except Exception as e: + logger.exception(e) + return + + if self.has_account_become_delinquent: + raise exceptions.AccountIsDelinquentError("User is delinquent") + elif self.has_account_been_downgraded: + raise exceptions.AccountWasDowngradedError("Account has been downgraded") + elif self.has_vpn_password_changed: + raise exceptions.VPNUsernameOrPasswordHasBeenChangedError("VPN password has been changed") + elif self.has_account_exceeded_max_ammount_of_connections: + raise exceptions.ExceededAmountOfConcurrentSessionsError( + "Too many concurrent sessions" + ) + + def refresh_vpn_data(self): + self._previous_tier = self._env.api_session.vpn_tier + self._previous_vpn_username = self._env.api_session.vpn_username + self._previous_vpn_password = self._env.api_session.vpn_password + self._previous_delinquent = self._env.api_session.delinquent + + self._env.api_session.refresh_vpn_data() + + @property + def has_account_become_delinquent(self): + return bool(self._env.api_session.delinquent) # noqa + + @property + def has_account_been_downgraded(self): + return self._previous_tier > self._env.api_session.vpn_tier + + @property + def has_vpn_password_changed(self): + return ( + self._previous_vpn_password != self._env.api_session.vpn_password + or self._previous_vpn_username != self._env.api_session.vpn_username + ) + + @property + def has_account_exceeded_max_ammount_of_connections(self): + try: + current_sessions = len(self._env.api_session.get_sessions()) + except: # noqa + current_sessions = self._env.api_session.max_connections + + return current_sessions >= self._env.api_session.max_connections diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/connection_backend/nm_client/nm_client.py new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/connection_backend/nm_client/nm_client.py --- old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/connection_backend/nm_client/nm_client.py 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/connection_backend/nm_client/nm_client.py 2021-11-25 12:57:46.000000000 +0100 @@ -81,7 +81,7 @@ self._pre_setup_connection(kwargs.get("entry_ip")) self._add_connection_async(connection) - def connect(self): + def connect(self, attempt_reconnect=False): """Connect to VPN. Returns status of connection in dict form. @@ -102,18 +102,28 @@ ) dbus_loop.run() if response[ConnectionStartStatusEnum.STATE] != VPNConnectionStateEnum.IS_ACTIVE: + logger.info("Unable to connect to VPN") + env = ExecutionEnvironment() logger.info("Restoring kill switch to previous state") - _env = ExecutionEnvironment() - _env.killswitch.update_from_user_configuration_menu( - KillswitchStatusEnum.HARD - if _env.settings.killswitch == KillswitchStatusEnum.HARD - else KillswitchStatusEnum.SOFT - ) + if env.settings.killswitch == KillswitchStatusEnum.HARD: + env.killswitch.update_from_user_configuration_menu(KillswitchStatusEnum.HARD) + else: + env.killswitch.update_from_user_configuration_menu(KillswitchStatusEnum.DISABLED) + env.ipv6leak.remove_leak_protection() try: self.disconnect() except: # noqa pass + + try: + self.ensure_protovnpn_connection_exists(connection) + except exceptions.ConnectionNotFound: + pass + + logger.info("Ensure that account has expected values") + env.accounting.ensure_accounting_has_expected_values() + else: self.daemon_reconnector.start_daemon_reconnector() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/environment.py new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/environment.py --- old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/environment.py 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/environment.py 2021-11-25 12:57:46.000000000 +0100 @@ -21,6 +21,7 @@ self.__settings = None self.__connection_metadata = None self.__api_metadata = None + self.__accounting = None @property def keyring(self): @@ -119,6 +120,18 @@ self.__api_metadata = newvalue @property + def accounting(self): + """Return the session to the API""" + if self.__accounting is None: + from .accounting import Accounting + self.__accounting = Accounting.get_backend() # noqa + return self.__accounting + + @accounting.setter + def accounting(self, newvalue): + self.__accounting = newvalue + + @property def user_agent(self): from ..constants import APP_VERSION """Get user agent to use when communicating with API diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/keyring/textfilekeyring.py new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/keyring/textfilekeyring.py --- old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/keyring/textfilekeyring.py 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/keyring/textfilekeyring.py 2021-11-25 12:57:46.000000000 +0100 @@ -1,5 +1,7 @@ import json import os +from ...logger import logger +from ... import exceptions from ...constants import PROTON_XDG_CONFIG_HOME from ._base import KeyringBackend @@ -23,6 +25,18 @@ f = self.__get_filename_for_key(key) if not os.path.exists(f): raise KeyError(key) + with open(self.__get_filename_for_key(key), 'r') as f: + try: + return json.load(f) + except json.decoder.JSONDecodeError as e: + logger.exception(e) + raise exceptions.JSONDataEmptyError(e) + except TypeError as e: + logger.exception(e) + raise exceptions.JSONDataNoneError(e) + except Exception as e: + logger.exception(e) + raise exceptions.JSONDataError(e) def __delitem__(self, key): f = self.__get_filename_for_key(key) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/notification/notifications.py new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/notification/notifications.py --- old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/notification/notifications.py 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/notification/notifications.py 2021-11-25 12:57:46.000000000 +0100 @@ -67,7 +67,7 @@ @classmethod def factory(cls, data, attribute=None): - if not data: + if not data or len(data) == 0: return cls._get_subclasses_dict("notification_type")[ NotificationEnum.EMPTY.value ](data) @@ -177,8 +177,8 @@ return False -class BlackfridayNotification(BaseNotificationType): - notification_type = NotificationEnum.BLACK_FRIDAY.value +class GenericNotification(BaseNotificationType): + notification_type = NotificationEnum.GENERIC.value def __init__(self, data): self.icon_paths = set() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/session/session.py new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/session/session.py --- old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/session/session.py 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/session/session.py 2021-11-25 12:57:46.000000000 +0100 @@ -16,7 +16,7 @@ UserSettingStatusEnum) from ...exceptions import (API403Error, API5002Error, API5003Error, API8002Error, API9001Error, API10013Error, - API12087Error, API85031Error, + API12087Error, API85031Error, API2011Error, APISessionIsNotValidError, APITimeoutError, DefaultOVPNPortsNotFoundError, InsecureConnection, JSONDataError, NetworkConnectionError, @@ -114,7 +114,12 @@ time.sleep(hold_request_time) return self._call_original_function(session, *args, **kwargs) + def _handle_2011(self, error, session, *args, **kwargs): + logger.info("Catched 9001 error, generic error message: {}".format(error)) + raise API2011Error(error) + def _handle_9001(self, error, session, *args, **kwargs): + logger.info("Catched 9001 error, human verification required") raise API9001Error(error) def _handle_85031(self, error, session, *args, **kwargs): @@ -434,6 +439,32 @@ self.ensure_valid() return self.__proton_user + @property + def max_connections(self): + try: + return int(self._vpn_data["max_connections"]) + except KeyError: + return 20 + + @property + def delinquent(self): + try: + return True if self._vpn_data["delinquent"] > 2 else False + except KeyError: + return False + + @ErrorStrategyNormalCall + def get_sessions(self): + response = self.__proton_api.api_request(APIEndpointEnum.SESSIONS.value) + + try: + return response.get("Sessions", []) + except AttributeError: + return [] + + def refresh_vpn_data(self): + self.__vpn_data_fetch_from_api() + @ErrorStrategyNormalCall def __vpn_data_fetch_from_api(self): self.ensure_valid() @@ -442,7 +473,10 @@ self.__vpn_data = { 'username': api_vpn_data['VPN']['Name'], 'password': api_vpn_data['VPN']['Password'], - 'tier': api_vpn_data['VPN']['MaxTier'] + 'tier': api_vpn_data['VPN']['MaxTier'], + 'max_connections': api_vpn_data['VPN']['MaxConnect'], + 'delinquent': api_vpn_data['Delinquent'], + 'warnings': api_vpn_data['Warnings'] } # We now have valid VPN data, store it in the keyring diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/utilities.py new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/utilities.py --- old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/core/utilities.py 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/core/utilities.py 2021-11-25 12:57:46.000000000 +0100 @@ -14,58 +14,33 @@ utils = Utilities() utils.ensure_internet_connection_is_available() - utils.ensure_api_is_reacheable() @staticmethod def ensure_internet_connection_is_available(): logger.info("Checking for internet connectivity") - if ExecutionEnvironment().killswitch != KillswitchStatusEnum.DISABLED: + if ExecutionEnvironment().settings.killswitch != KillswitchStatusEnum.DISABLED: logger.info("Skipping as killswitch is enabled") return try: requests.get( - "http://protonstatus.com/", + "https://protonstatus.com/", timeout=5, ) except requests.exceptions.Timeout as e: - logger.exception("InternetConnectionError: {}".format(e)) - raise exceptions.InternetConnectionError( + logger.exception("NetworkConnectionError: {}".format(e)) + raise exceptions.NetworkConnectionError( "No internet connection found, request timed out. " "Please make sure you are connected and retry." ) except (requests.exceptions.BaseHTTPError, Exception) as e: - logger.exception("InternetConnectionError: {}".format(e)) - raise exceptions.InternetConnectionError( + logger.exception("NetworkConnectionError: {}".format(e)) + raise exceptions.NetworkConnectionError( "No internet connection. " "Please make sure you are connected and retry." ) @staticmethod - def ensure_api_is_reacheable(): - logger.info("Checking API connectivity") - - if ExecutionEnvironment().killswitch != KillswitchStatusEnum.DISABLED: - logger.info("Skipping as killswitch is enabled") - return - - try: - requests.get( - "https://api.protonvpn.ch/tests/ping", timeout=10 - ) - except requests.exceptions.Timeout as e: - logger.exception("APITimeoutError: {}".format(e)) - raise exceptions.APITimeoutError( - "API unreacheable. Connection timed out." - ) - except (requests.exceptions.RequestException, Exception) as e: - logger.exception("UnreacheableAPIError: {}".format(e)) - raise exceptions.UnreacheableAPIError( - "Couldn't reach Proton API." - "This might happen due to connection issues or network blocks." - ) - - @staticmethod def ensure_servername_is_valid(servername): """Check if the provided servername is in a valid format. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/enums.py new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/enums.py --- old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/enums.py 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/enums.py 2021-11-25 12:57:46.000000000 +0100 @@ -8,11 +8,12 @@ STREAMING_SERVICES = "/vpn/streamingservices" NOTIFICATIONS = "/core/v4/notifications" LOCATION = "/vpn/location" + SESSIONS = "/vpn/sessions" class NotificationEnum(Enum): EMPTY = "empty" - BLACK_FRIDAY = "black_friday" + GENERIC = "generic" class NotificationStatusEnum(Enum): @@ -169,6 +170,7 @@ class ConnectionTypeEnum(Enum): + FREE = 0 SERVERNAME = 1 FASTEST = 2 RANDOM = 3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/exceptions.py new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/exceptions.py --- old/protonvpn-nm-lib-3.6.0/protonvpn_nm_lib/exceptions.py 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/protonvpn_nm_lib/exceptions.py 2021-11-25 12:57:46.000000000 +0100 @@ -5,6 +5,30 @@ super(ProtonVPNException, self).__init__(self.message) +class AccountingError(ProtonVPNException): + """Base accounting exception/error.""" + + +class AccountIsDelinquentError(AccountingError): + """Account is delinquent (user has unpaid invoices).""" + + +class AccountWasDowngradedError(AccountingError): + """Account was downgraded.""" + + +class VPNUsernameOrPasswordHasBeenChangedError(AccountingError): + """Account username or password has been changed.""" + + +class AccountPasswordHasBeenCompromisedError(AccountingError): + """Account password has been compromised.""" + + +class ExceededAmountOfConcurrentSessionsError(AccountingError): + """Account has exceeded the maximum amount of concurrent sessions.""" + + class APISessionIsNotValidError(ProtonVPNException): """ This exception is raised when a call requires a valid Proton API session, @@ -115,6 +139,13 @@ """ +class API2011Error(ProtonSessionWrapperError): + """Error 2011. + + Generic API error. + """ + + class API5002Error(ProtonSessionWrapperError): """Error 5002. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/rpmbuild/SPECS/python3-protonvpn-nm-lib.spec new/protonvpn-nm-lib-3.7.0/rpmbuild/SPECS/python3-protonvpn-nm-lib.spec --- old/protonvpn-nm-lib-3.6.0/rpmbuild/SPECS/python3-protonvpn-nm-lib.spec 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/rpmbuild/SPECS/python3-protonvpn-nm-lib.spec 2021-11-25 12:57:46.000000000 +0100 @@ -1,6 +1,6 @@ %define unmangled_name protonvpn-nm-lib -%define version 3.6.0 -%define release 5 +%define version 3.7.0 +%define release 6 Prefix: %{_prefix} @@ -34,7 +34,7 @@ Requires: python3-systemd Requires: python3-gobject Requires: xdg-utils -Conflicts: protonvpn-cli < 3.10.0, protonvpn-cli < 1.4.0 +Conflicts: protonvpn-cli < 3.11.0, protonvpn-cli < 1.7.0 %{?python_disable_dependency_generator} @@ -60,6 +60,12 @@ %defattr(-,root,root) %changelog +* Tue Nov 11 2021 Proton Technologies AG <opensou...@proton.me> 3.7.0-6 +- Improve: Handle accounting use cases + +* Tue Nov 02 2021 Proton Technologies AG <opensou...@proton.me> 3.6.1-1 +- Hotfix: Update event notifications + * Tue Oct 12 2021 Proton Technologies AG <opensou...@proton.me> 3.6.0-5 - Feature: Add notification polling - Improve: Human verification at login diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/tests/dummy_test.py new/protonvpn-nm-lib-3.7.0/tests/dummy_test.py --- old/protonvpn-nm-lib-3.6.0/tests/dummy_test.py 2021-10-23 14:40:47.000000000 +0200 +++ new/protonvpn-nm-lib-3.7.0/tests/dummy_test.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,2 +0,0 @@ -def test(): - assert True == True diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/protonvpn-nm-lib-3.6.0/tests/test_default_accounting.py new/protonvpn-nm-lib-3.7.0/tests/test_default_accounting.py --- old/protonvpn-nm-lib-3.6.0/tests/test_default_accounting.py 1970-01-01 01:00:00.000000000 +0100 +++ new/protonvpn-nm-lib-3.7.0/tests/test_default_accounting.py 2021-11-25 12:57:46.000000000 +0100 @@ -0,0 +1,122 @@ +import pytest +from protonvpn_nm_lib.core.environment import ExecutionEnvironment +env = ExecutionEnvironment() +accounting = ExecutionEnvironment().accounting +from protonvpn_nm_lib import exceptions + + +class MockSessionBase: + def __init__(self): + self.__delinquent = False + self.__vpn_tier = 3 + self.__vpn_username = "vpn_username" + self.__vpn_password = "vpn_password" + + def refresh_vpn_data(self): + pass + + @property + def delinquent(self): + return self.__delinquent + + @delinquent.setter + def delinquent(self, newavalue): + self.__delinquent = newavalue + + @property + def max_connections(self): + return 2 + + @property + def vpn_tier(self): + return self.__vpn_tier + + @vpn_tier.setter + def vpn_tier(self, newvalue): + self.__vpn_tier = newvalue + + @property + def vpn_username(self): + return self.__vpn_username + + @vpn_username.setter + def vpn_username(self, newvalue): + self.__vpn_username = newvalue + + @property + def vpn_password(self): + return self.__vpn_password + + @vpn_password.setter + def vpn_password(self, newvalue): + self.__vpn_password = newvalue + + def get_sessions(self): + return [] + + +class MockDelinquentSession(MockSessionBase): + def __init__(self): + super().__init__() + + def refresh_vpn_data(self): + self.delinquent = True + + +class MockAccountDowngradeSession(MockSessionBase): + def __init__(self): + super().__init__() + + def refresh_vpn_data(self): + self.vpn_tier = 0 + + +class MockChangedVPNPasswordSession(MockSessionBase): + def __init__(self): + super().__init__() + + def refresh_vpn_data(self): + self.vpn_password = "changed_password" + + +class MockChangedVPNUsernameSession(MockSessionBase): + def __init__(self): + super().__init__() + + def refresh_vpn_data(self): + self.vpn_username = "changed_username" + + +class MockMaxAmmountOfSessionsReachedSession(MockSessionBase): + def __init__(self): + super().__init__() + + def get_sessions(self): + return ["MockSession1", "MockSession2"] + + +class TestDefaultAccounting: + def test_delinquent_user(self): + env.api_session = MockDelinquentSession() + with pytest.raises(exceptions.AccountIsDelinquentError): + env.accounting.ensure_accounting_has_expected_values() + + def test_account_downgrade(self): + env.api_session = MockAccountDowngradeSession() + with pytest.raises(exceptions.AccountWasDowngradedError): + env.accounting.ensure_accounting_has_expected_values() + + def test_changed_vpn_password(self): + env.api_session = MockChangedVPNPasswordSession() + with pytest.raises(exceptions.VPNUsernameOrPasswordHasBeenChangedError): + env.accounting.ensure_accounting_has_expected_values() + + def test_changed_vpn_username(self): + env.api_session = MockChangedVPNUsernameSession() + with pytest.raises(exceptions.VPNUsernameOrPasswordHasBeenChangedError): + env.accounting.ensure_accounting_has_expected_values() + + def test_exceeded_amount_of_concurrent_sessions(self): + env.api_session = MockMaxAmmountOfSessionsReachedSession() + with pytest.raises(exceptions.ExceededAmountOfConcurrentSessionsError): + env.accounting.ensure_accounting_has_expected_values()