Certbot AssertionError in make test on FreeBSD

Hi,

uname -a

FreeBSD FBSDmydomain 11.3-RELEASE-p3 FreeBSD 11.3-RELEASE-p3 #0: Mon Aug 19 21:08:43 UTC 2019
root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64

portsnap fetch update

cd

/usr/ports/security/py-certbot

make test

============== make test output start ================

===> Testing for py36-certbot-0.39.0,1
===> py36-certbot-0.39.0,1 depends on package: py36-mock>0 - found
===> py36-certbot-0.39.0,1 depends on file: /usr/local/bin/python3.6 - found
running test
...
...
...
running build_ext
============================= test session starts ==============================
platform freebsd11 -- Python 3.6.9, pytest-5.2.2, py-1.8.0, pluggy-0.13.0
rootdir: /usr/ports/security/py-certbot/work-py36/certbot-0.39.0
collected 909 items

certbot/plugins/common_test.py ................................... [ 3%]
...
...
...
certbot/tests/cli_test.py .F....................................... [ 34%]
...
...
...
certbot/tests/display/util_test.py ..................................... [ 99%]
....... [100%]

=================================== FAILURES ===================================
___________________ FlagDefaultTest.test_default_directories ___________________

self = <certbot.tests.cli_test.FlagDefaultTest testMethod=test_default_directories>

def test_default_directories(self):
    if os.name != 'nt':
      self.assertEqual(cli.flag_default('config_dir'), '/etc/letsencrypt')

E AssertionError: '/usr/local/etc/letsencrypt' != '/etc/letsencrypt'
E - /usr/local/etc/letsencrypt
E ? ----------
E + /etc/letsencrypt

certbot/tests/cli_test.py:54: AssertionError
=============================== warnings summary ===============================
...
...
...
====== 1 failed, 891 passed, 17 skipped, 51 warnings in 70.96s (0:01:10) =======
*** Error code 1

Stop.
make: stopped in /usr/ports/security/py-certbot
============== make test output end ================

/usr/ports/security/py-certbot/files/patch-certbot-compat-misc.py

============== patch-certbot-compat-misc.py === cut ====================
...
...
...
+FREEBSD_DEFAULT_FOLDERS = {

  • 'config': '/usr/local/etc/letsencrypt',
  • 'work': '/var/db/letsencrypt',
  • 'logs': '/var/log/letsencrypt',
    +}
    ...
    ...
    ...
  •    if sys.platform.startswith('freebsd') or sys.platform.startswith('dragonfly'):
    
  •        # FreeBSD specific
    
  •        return FREEBSD_DEFAULT_FOLDERS[folder_type]
    
  •    else:
    
  •        # Linux specific
    
  •        return LINUX_DEFAULT_FOLDERS[folder_type]
    

============== patch-certbot-compat-misc.py === end of cut =============

/usr/ports/security/py-certbot/work-py36/certbot-0.39.0/certbot/tests/cli_test.py

============== cli_test.py === cut ====================
class FlagDefaultTest(unittest.TestCase):
"""Tests cli.flag_default"""

def test_default_directories(self):
    if os.name != 'nt':
        self.assertEqual(cli.flag_default('config_dir'), '/etc/letsencrypt')
        self.assertEqual(cli.flag_default('work_dir'), '/var/lib/letsencrypt')
        self.assertEqual(cli.flag_default('logs_dir'), '/var/log/letsencrypt')
    else:
        self.assertEqual(cli.flag_default('config_dir'), 'C:\\Certbot')
        self.assertEqual(cli.flag_default('work_dir'), 'C:\\Certbot\\lib')
        self.assertEqual(cli.flag_default('logs_dir'), 'C:\\Certbot\\log')

============== cli_test.py === end of cut ====================

The question is: should I change in patch-certbot-compat-misc.py

'config': '/usr/local/etc/letsencrypt',
to
'/etc/letsencrypt',

?

'work': '/var/db/letsencrypt',
to
'/var/lib/letsencrypt'

?

Thanks a lot.

1 Like

Hi @MTumanov,

Welcome to the community forum!

Have you tried using the prebuilt package pkg install py36-certbot rather than compiling from source?

You should open an issue over at https://github.com/certbot/certbot!

2 Likes

No, I do not tried prebuilt package of certbot.
What if the package compiled without options that I must to have or do not want to have?
I prefer to compile packages myself.

Thank you for the link to Github, I will create the ticket on that site.

2 Likes

I have an answer to my question.

To fix this error you must edit
patch-certbot-compat-misc.py
and replace

‘config’: ‘/usr/local/etc/letsencrypt’,
with
‘/etc/letsencrypt’,

‘work’: ‘/var/db/letsencrypt’,
with
‘/var/lib/letsencrypt’

make test will end without errors.

I think that this is a bug in ports on FreeBSD.

And in fact there is a bugreport
Bug 233909 - security/py-certbot: Incorrect config file path since update to 0.29.1

In status: Closed FIXED

But I got this error and my ports was not updated.

But the most correct way is NOT to edit patch-certbot-compat-misc.py

Correct path in FreeBSD for ‘config’ is ‘%%LOCALBASE%%/etc/letsencrypt’
and this is equals to ‘/usr/local/etc/letsencrypt’

FreeBSD does not have /var/lib at all.
The correct path is /var/db

So, the most correct way is to edit all source text, not only cli_test.py
but all of files in this port.
And replace all path to correct for FreeBSD values.

3 Likes

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