[MIG] letsencrypt: Migration to 16.0

pull/2917/head
Holger Brunn 2024-04-22 19:00:41 +02:00
parent 3d1836a363
commit 24c34f4274
10 changed files with 37 additions and 41 deletions

View File

@ -7,7 +7,7 @@ Let's Encrypt
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1e92ffe995bb1bc5f6e759273d8b25800a0df0a3cf55e76638062565845bfb95
!! source digest: sha256:4e5d65c682a4a9426ab0030b56b553f67f03a84fe525fd750b9df8621a5d8346
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@ -17,13 +17,13 @@ Let's Encrypt
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/15.0/letsencrypt
:target: https://github.com/OCA/server-tools/tree/16.0/letsencrypt
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-15-0/server-tools-15-0-letsencrypt
:target: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-letsencrypt
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=15.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=16.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -151,7 +151,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20letsencrypt%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20letsencrypt%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@ -202,6 +202,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/15.0/letsencrypt>`_ project on GitHub.
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/16.0/letsencrypt>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -2,13 +2,13 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Let's Encrypt",
"version": "15.0.1.0.3",
"version": "16.0.1.0.0",
"author": "Therp BV," "Tecnativa," "Acysos S.L," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/server-tools",
"license": "AGPL-3",
"category": "Tools",
"summary": "Request SSL certificates from letsencrypt.org",
"depends": ["base_setup"],
"depends": ["base"],
"data": [
"data/ir_config_parameter.xml",
"data/ir_cron.xml",
@ -17,5 +17,5 @@
"demo": ["demo/ir_cron.xml"],
"post_init_hook": "post_init_hook",
"installable": True,
"external_dependencies": {"python": ["acme<2.0.0", "dnspython", "josepy"]},
"external_dependencies": {"python": ["acme", "dnspython", "josepy"]},
}

View File

@ -27,4 +27,4 @@ class Letsencrypt(http.Controller):
return key.read()
except IOError:
_logger.exception(_("Error opening file %s"), path)
return request.not_found()
raise request.not_found()

View File

@ -239,9 +239,10 @@ class Letsencrypt(models.AbstractModel):
directory_url = V2_STAGING_DIRECTORY_URL
else:
directory_url = V2_DIRECTORY_URL
directory_json = requests.get(directory_url).json()
directory_json = requests.get(directory_url, timeout=60).json()
directory = acme.messages.Directory(directory_json)
net = acme.client.ClientNetwork(account_key)
return acme.client.ClientV2(directory_json, net)
return acme.client.ClientV2(directory, net)
def _register_client(self, client, account_key):
"""Register this Letsencrypt client."""

View File

@ -75,14 +75,6 @@ class ResConfigSettings(models.TransientModel):
"*." in altnames or self.letsencrypt_prefer_dns
)
@api.model
def default_get(self, fields_list):
res = super().default_get(fields_list)
res["letsencrypt_needs_dns_provider"] = (
"*." in res["letsencrypt_altnames"] or res["letsencrypt_prefer_dns"]
)
return res
def set_values(self):
"""Set Letsencrypt values on settings object."""
result = super().set_values()

View File

@ -367,9 +367,9 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1e92ffe995bb1bc5f6e759273d8b25800a0df0a3cf55e76638062565845bfb95
!! source digest: sha256:4e5d65c682a4a9426ab0030b56b553f67f03a84fe525fd750b9df8621a5d8346
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-tools/tree/15.0/letsencrypt"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-tools-15-0/server-tools-15-0-letsencrypt"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-tools&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-tools/tree/16.0/letsencrypt"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-letsencrypt"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-tools&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module was written to have your Odoo installation request SSL certificates
from <a class="reference external" href="https://letsencrypt.org">https://letsencrypt.org</a> automatically.</p>
<p><strong>Table of contents</strong></p>
@ -492,7 +492,7 @@ For example, <tt class="docutils literal"><span class="pre">--load=web,letsencry
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20letsencrypt%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20letsencrypt%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -539,7 +539,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/15.0/letsencrypt">OCA/server-tools</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/16.0/letsencrypt">OCA/server-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -5,6 +5,7 @@ import os
import shutil
from odoo.tests import HttpCase
from odoo.tools.misc import mute_logger
from ..models.letsencrypt import _get_challenge_dir
@ -17,6 +18,7 @@ class TestHTTP(HttpCase):
self.assertEqual(res.status_code, 200)
self.assertEqual(res.text, "content")
@mute_logger("odoo.addons.letsencrypt.controllers.main")
def test_query_missing(self):
res = self.url_open("/.well-known/acme-challenge/foobar")
self.assertEqual(res.status_code, 404)

View File

@ -5,12 +5,14 @@ import os
import shutil
from datetime import datetime, timedelta
from os import path
from unittest import mock
import dns.resolver
import mock
from odoo.exceptions import UserError, ValidationError
from odoo.tests import SingleTransactionCase
from odoo.tests.common import Form
from odoo.tools.misc import mute_logger
from ..models.letsencrypt import _get_challenge_dir, _get_data_dir
@ -39,18 +41,12 @@ class TestLetsencrypt(SingleTransactionCase):
).set_values()
def test_config_settings(self):
setting_vals = self.env["res.config.settings"].default_get([])
self.assertEqual(setting_vals["letsencrypt_dns_provider"], "shell")
self.assertEqual(
setting_vals["letsencrypt_dns_shell_script"],
"touch /tmp/.letsencrypt_test",
)
self.assertEqual(
setting_vals["letsencrypt_altnames"], "www.example.ltd,*.example.ltd"
)
self.assertEqual(setting_vals["letsencrypt_reload_command"], "echo reloaded")
self.assertTrue(setting_vals["letsencrypt_needs_dns_provider"])
self.assertFalse(setting_vals["letsencrypt_prefer_dns"])
with Form(self.env["res.config.settings"]) as settings_form:
self.assertTrue(settings_form.letsencrypt_needs_dns_provider)
settings_form.letsencrypt_altnames = "www.example.ltd"
self.assertFalse(settings_form.letsencrypt_needs_dns_provider)
settings_form.letsencrypt_prefer_dns = True
self.assertTrue(settings_form.letsencrypt_needs_dns_provider)
with self.assertRaises(ValidationError):
self.env["res.config.settings"].create(
@ -287,6 +283,7 @@ class TestLetsencrypt(SingleTransactionCase):
)
)
@mute_logger("odoo.addons.letsencrypt.models.letsencrypt")
def test_legacy_certificate_without_altnames(self):
self.install_certificate(60, use_altnames=False)
self.assertFalse(

View File

@ -2,7 +2,7 @@
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">Letsencrypt settings view</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form" />
<field name="inherit_id" ref="base.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[hasclass('settings')]" position="inside">
<div
@ -25,14 +25,17 @@
<div
class="text-muted"
>List the domains for the certificate</div>
<field name="letsencrypt_altnames" />
<field name="letsencrypt_altnames" widget="text" />
</div>
<div class="o_setting_right_pane">
<label for="letsencrypt_reload_command" />
<div
class="text-muted"
>Write a command to reload the server</div>
<field name="letsencrypt_reload_command" />
<field
name="letsencrypt_reload_command"
widget="text"
/>
</div>
<div class="o_setting_right_pane">
<label for="letsencrypt_dns_provider" />
@ -65,6 +68,7 @@
<field
name="letsencrypt_dns_shell_script"
attrs="{'required': [('letsencrypt_dns_provider', '=', 'shell')]}"
widget="text"
/>
</div>
</span>

View File

@ -1,5 +1,5 @@
# generated from manifests external_dependencies
acme<2.0.0
acme
astor
cryptography
dataclasses