Python-proton-vpn-api-core Tests Fail Due to Insufficient Privileges during Build

Hello All,

The latest version of the Proton VPN app (4.4.4) for Linux came out recently with Wireguard support, and I decided I’d try to branch @avicenzi repos and give it a shot myself to try and learn. However, I ran into something I can’t seem to google my way out of. One of the requirements for the new app is an updated version of https://build.opensuse.org/package/show/openSUSE:Factory/python-proton-vpn-api-core. When I build it, it runs a bunch of Python tests at the end. Some of those tests are failing because the build user does not have root privileges:

==================================== ERRORS ====================================
[   11s] _________ ERROR at setup of test_ensure_configuration_file_is_created __________
[   11s] 
[   11s]     @pytest.fixture
[   11s]     def modified_exec_env():
[   11s]         from proton.utils.environment import ExecutionEnvironment
[   11s] >       m = ExecutionEnvironment().path_runtime
[   11s] 
[   11s] tests/connection/test_vpnconfiguration.py:48: 
[   11s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   11s] /usr/lib/python3.10/site-packages/proton/utils/environment.py:57: in path_runtime
[   11s]     self.generate_dirs(self._path_runtime)
[   11s] /usr/lib/python3.10/site-packages/proton/utils/environment.py:68: in generate_dirs
[   11s]     os.makedirs(path, mode=0o700, exist_ok=True)
[   11s] /usr/lib64/python3.10/os.py:215: in makedirs
[   11s]     makedirs(head, exist_ok=exist_ok)
[   11s] /usr/lib64/python3.10/os.py:215: in makedirs
[   11s]     makedirs(head, exist_ok=exist_ok)
[   11s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   11s] 
[   11s] name = '/run/user', mode = 511, exist_ok = True
[   11s] 
[   11s]     def makedirs(name, mode=0o777, exist_ok=False):
[   11s]         """makedirs(name [, mode=0o777][, exist_ok=False])
[   11s]     
[   11s]         Super-mkdir; create a leaf directory and all intermediate ones.  Works like
[   11s]         mkdir, except that any intermediate path segment (not just the rightmost)
[   11s]         will be created if it does not exist. If the target directory already
[   11s]         exists, raise an OSError if exist_ok is False. Otherwise no exception is
[   11s]         raised.  This is recursive.
[   11s]     
[   11s]         """
[   11s]         head, tail = path.split(name)
[   11s]         if not tail:
[   11s]             head, tail = path.split(head)
[   11s]         if head and tail and not path.exists(head):
[   11s]             try:
[   11s]                 makedirs(head, exist_ok=exist_ok)
[   11s]             except FileExistsError:
[   11s]                 # Defeats race condition when another thread created the path
[   11s]                 pass
[   11s]             cdir = curdir
[   11s]             if isinstance(tail, bytes):
[   11s]                 cdir = bytes(curdir, 'ASCII')
[   11s]             if tail == cdir:           # xxx/newdir/. exists if xxx/newdir exists
[   11s]                 return
[   11s]         try:
[   11s] >           mkdir(name, mode)
[   11s] E           PermissionError: [Errno 13] Permission denied: '/run/user'
[   11s] 
[   11s] /usr/lib64/python3.10/os.py:225: PermissionError

There are several other tests that fail in this same way. How would I work around this? Or, are these tests not really important here? Some GUI tests are disabled in the main Proton VPN package with %pytest tests/unit --ignore=tests/unit/widgets/, I guess these might be disabled in the same way if needed.

Thanks!

You diable tests that cannot be used in OBS environment. You may consider reporting it upstream.

OBS can’t run tests that require a desktop environment because it has none, nor tests that require a network connection because VMs are not connected to the outside world.

That is why some packages have a skip rule to ignore certain test cases. A few issues have been reported upstream, but Proton does not care too much about openSUSE as it is not an officially supported distro.

Updating the packages is on my backlog, I just need to find some time this week or next week.

The test in question does not really require either. It attempts to replace reference to $XDG_RUNTIME_DIR with temporary directory and apparently Python module that manages standard paths (in particular, $XDG_RUNTIME_DIR) tries to create the default path first before replacing it with a custom directory. This Python module is part of Proton either, but comes from a different repository and I did not look at it.

It is possible that this module already has constructor that bypasses this behavior and test simply needs to use it. Or such constructor can be added.

Thanks! So my options in a case like this are pretty much to disable the test and report more details upstream if I want. This was helpful, and I’ll have to dig in more and learn about Python test modules.

No worries regarding the ProtonVPN update, I am doing this to learn and my motivation was that if I could figure it out, then I get to test the new app! I certainly didn’t expect to submit to it Tumbleweed or anything, I’m definitely not there yet…

If you need any help feel free to reach out, you can also find me at chat.opensuse.org.

I updated the packages on my branch. You can test if you want. Soon they should be in TW.

zypper ar -ef https://download.opensuse.org/repositories/home:/avicenzi:/proton/openSUSE_Tumbleweed/ proton
zypper in proton-vpn

The test failures on the package are due to a merge of other packages into api-core. The tests were already skipped in the other package, so I just moved the skip into api-core if you want to take a look.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.