2016-04-18 18:08:16 -04:00
|
|
|
|
===============
|
|
|
|
|
|
Developer Guide
|
|
|
|
|
|
===============
|
|
|
|
|
|
|
|
|
|
|
|
.. contents:: Table of Contents
|
|
|
|
|
|
:local:
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-08 15:17:42 -04:00
|
|
|
|
.. _getting_started:
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2016-08-08 15:17:42 -04:00
|
|
|
|
Getting Started
|
2017-05-26 23:57:14 -04:00
|
|
|
|
===============
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2018-05-11 10:07:02 -04:00
|
|
|
|
Certbot has the same :ref:`system requirements <system_requirements>` when set
|
|
|
|
|
|
up for development. While the section below will help you install Certbot and
|
|
|
|
|
|
its dependencies, Certbot needs to be run on a UNIX-like OS so if you're using
|
|
|
|
|
|
Windows, you'll need to set up a (virtual) machine running an OS such as Linux
|
|
|
|
|
|
and continue with these instructions on that UNIX-like OS.
|
|
|
|
|
|
|
Add executable scripts to start certbot and acme server in certbot-ci (#7073)
During review of #6989, we saw that some of our test bash scripts were still used in the Boulder project in particular. It is about `tests/integration/_common.sh` in particular, to expose the `certbot_test` bash function, that is an appropriate way to execute a local version of certbot in test mode: define a custom server, remove several checks, full log and so on.
This PR is an attempt to assert this goal: exposing a new `certbot_test` executable for test purpose. More generally, this PR is about giving well suited scripts to quickly make manual tests against certbot without launching the full automated pytest suite.
The idea here is to leverage the existing logic in certbot-ci, and expose it as executable scripts. This is done thanks to the `console_scripts` entry of setuptools entrypoint feature, that install scripts in the `PATH`, when `pip install` is invoked, that delegate to specific functions in the installed packages.
Two scripts are defined this way:
* `certbot_test`: it executes certbot in test mode in a very similar way than the original `certbot_test` in `_common.sh`, by delegating to `certbot_integration_tests.utils.certbot_call:main`. By default this execution will target a pebble directory url started locally. The url, and also http-01/tls-alpn-01 challenge ports can be configured using ad-hoc environment variables. All arguments passed to `certbot_test` are transferred to the underlying certbot command.
* `acme_server`: it set up a fully running instance of an ACME server, ready for tests (in particular, all FQDN resolves to localhost in order to target a locally running `certbot_test` command) by delegating to `certbot_integration_tests.utils.acme_server:main`. The choice of the ACME server is given by the first parameter passed to `acme_server`, it can be `pebble`, `boulder-v1` or `boulder-v2`. The command keeps running on foreground, displaying the logs of the ACME server on stdout/stderr. The server is shut down and resources cleaned upon entering CTRL+C.
This two commands can be run also through the underlying python modules, that are executable.
Finally, a typical workflow on certbot side to run manual tests would be:
```
cd certbot
tools/venv.py
source venv/bin/activate
acme_server pebble &
certbot_test certonly --standalone -d test.example.com
```
On boulder side it could be:
```
# Follow certbot dev environment setup instructions, then ...
cd boulder
docker-compose run --use-aliases -e FAKE_DNS=172.17.0.1 --service-ports boulder ./start.py
SERVER=http://localhost:4001/directory certbot_test certonly --standalone -d test.example.com
```
* Configure certbot-ci to expose a certbot_test console script calling certbot in test mode against a local pebble instance
* Add a command to start pebble/boulder
* Use explicit start
* Add execution permission to acme_server
* Add a docstring to certbot_test function
* Change executable name
* Increase sleep to 3600s
* Implement a context manager to handle the acme server
* Add certbot_test workspace in .gitignore
* Add documentation
* Remove one function in context, split logic of certbot_test towards capturing non capturing
* Use an explicit an properly configured ACMEServer as handler.
* Add doc. Put constants.
2019-06-12 20:19:23 -04:00
|
|
|
|
.. _local copy:
|
|
|
|
|
|
|
2016-04-18 18:08:16 -04:00
|
|
|
|
Running a local copy of the client
|
|
|
|
|
|
----------------------------------
|
|
|
|
|
|
|
2017-03-10 20:27:09 -05:00
|
|
|
|
Running the client in developer mode from your local tree is a little different
|
|
|
|
|
|
than running Certbot as a user. To get set up, clone our git repository by
|
|
|
|
|
|
running:
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
2016-05-03 20:04:30 -04:00
|
|
|
|
git clone https://github.com/certbot/certbot
|
2017-03-10 20:27:09 -05:00
|
|
|
|
|
2018-05-14 11:08:24 -04:00
|
|
|
|
If you're on macOS, we recommend you skip the rest of this section and instead
|
|
|
|
|
|
run Certbot in Docker. You can find instructions for how to do this :ref:`here
|
|
|
|
|
|
<docker-dev>`. If you're running on Linux, you can run the following commands to
|
|
|
|
|
|
install dependencies and set up a virtual environment where you can run
|
|
|
|
|
|
Certbot.
|
2017-03-10 20:27:09 -05:00
|
|
|
|
|
|
|
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
2016-05-03 20:04:30 -04:00
|
|
|
|
cd certbot
|
2018-05-11 10:07:02 -04:00
|
|
|
|
./certbot-auto --debug --os-packages-only
|
2018-11-07 20:16:16 -05:00
|
|
|
|
python tools/venv.py
|
2018-05-11 10:07:02 -04:00
|
|
|
|
|
2018-11-07 20:16:16 -05:00
|
|
|
|
If you have Python3 available and want to use it, run the ``venv3.py`` script.
|
2018-05-15 10:58:33 -04:00
|
|
|
|
|
|
|
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
2018-11-07 20:16:16 -05:00
|
|
|
|
python tools/venv3.py
|
2018-05-15 10:58:33 -04:00
|
|
|
|
|
2018-05-11 10:07:02 -04:00
|
|
|
|
.. note:: You may need to repeat this when
|
|
|
|
|
|
Certbot's dependencies change or when a new plugin is introduced.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2018-02-12 17:07:33 -05:00
|
|
|
|
You can now run the copy of Certbot from git either by executing
|
2018-05-11 10:07:02 -04:00
|
|
|
|
``venv/bin/certbot``, or by activating the virtual environment. You can do the
|
|
|
|
|
|
latter by running:
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
2018-05-11 10:07:02 -04:00
|
|
|
|
source venv/bin/activate
|
2018-05-15 10:58:33 -04:00
|
|
|
|
# or
|
|
|
|
|
|
source venv3/bin/activate
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2018-05-11 10:07:02 -04:00
|
|
|
|
After running this command, ``certbot`` and development tools like ``ipdb``,
|
|
|
|
|
|
``ipython``, ``pytest``, and ``tox`` are available in the shell where you ran
|
|
|
|
|
|
the command. These tools are installed in the virtual environment and are kept
|
|
|
|
|
|
separate from your global Python installation. This works by setting
|
|
|
|
|
|
environment variables so the right executables are found and Python can pull in
|
|
|
|
|
|
the versions of various packages needed by Certbot. More information can be
|
|
|
|
|
|
found in the `virtualenv docs`_.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
.. _`virtualenv docs`: https://virtualenv.pypa.io
|
|
|
|
|
|
|
|
|
|
|
|
Find issues to work on
|
|
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
|
|
|
|
You can find the open issues in the `github issue tracker`_. Comparatively
|
2018-04-24 09:38:15 -04:00
|
|
|
|
easy ones are marked `good first issue`_. If you're starting work on
|
2016-04-18 18:08:16 -04:00
|
|
|
|
something, post a comment to let others know and seek feedback on your plan
|
|
|
|
|
|
where appropriate.
|
|
|
|
|
|
|
|
|
|
|
|
Once you've got a working branch, you can open a pull request. All changes in
|
|
|
|
|
|
your pull request must have thorough unit test coverage, pass our
|
2017-02-16 15:39:17 -05:00
|
|
|
|
tests, and be compliant with the :ref:`coding style <coding-style>`.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2016-05-03 20:04:30 -04:00
|
|
|
|
.. _github issue tracker: https://github.com/certbot/certbot/issues
|
2018-04-24 09:38:15 -04:00
|
|
|
|
.. _good first issue: https://github.com/certbot/certbot/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2017-02-16 15:39:17 -05:00
|
|
|
|
.. _testing:
|
|
|
|
|
|
|
2016-04-18 18:08:16 -04:00
|
|
|
|
Testing
|
|
|
|
|
|
-------
|
|
|
|
|
|
|
Add executable scripts to start certbot and acme server in certbot-ci (#7073)
During review of #6989, we saw that some of our test bash scripts were still used in the Boulder project in particular. It is about `tests/integration/_common.sh` in particular, to expose the `certbot_test` bash function, that is an appropriate way to execute a local version of certbot in test mode: define a custom server, remove several checks, full log and so on.
This PR is an attempt to assert this goal: exposing a new `certbot_test` executable for test purpose. More generally, this PR is about giving well suited scripts to quickly make manual tests against certbot without launching the full automated pytest suite.
The idea here is to leverage the existing logic in certbot-ci, and expose it as executable scripts. This is done thanks to the `console_scripts` entry of setuptools entrypoint feature, that install scripts in the `PATH`, when `pip install` is invoked, that delegate to specific functions in the installed packages.
Two scripts are defined this way:
* `certbot_test`: it executes certbot in test mode in a very similar way than the original `certbot_test` in `_common.sh`, by delegating to `certbot_integration_tests.utils.certbot_call:main`. By default this execution will target a pebble directory url started locally. The url, and also http-01/tls-alpn-01 challenge ports can be configured using ad-hoc environment variables. All arguments passed to `certbot_test` are transferred to the underlying certbot command.
* `acme_server`: it set up a fully running instance of an ACME server, ready for tests (in particular, all FQDN resolves to localhost in order to target a locally running `certbot_test` command) by delegating to `certbot_integration_tests.utils.acme_server:main`. The choice of the ACME server is given by the first parameter passed to `acme_server`, it can be `pebble`, `boulder-v1` or `boulder-v2`. The command keeps running on foreground, displaying the logs of the ACME server on stdout/stderr. The server is shut down and resources cleaned upon entering CTRL+C.
This two commands can be run also through the underlying python modules, that are executable.
Finally, a typical workflow on certbot side to run manual tests would be:
```
cd certbot
tools/venv.py
source venv/bin/activate
acme_server pebble &
certbot_test certonly --standalone -d test.example.com
```
On boulder side it could be:
```
# Follow certbot dev environment setup instructions, then ...
cd boulder
docker-compose run --use-aliases -e FAKE_DNS=172.17.0.1 --service-ports boulder ./start.py
SERVER=http://localhost:4001/directory certbot_test certonly --standalone -d test.example.com
```
* Configure certbot-ci to expose a certbot_test console script calling certbot in test mode against a local pebble instance
* Add a command to start pebble/boulder
* Use explicit start
* Add execution permission to acme_server
* Add a docstring to certbot_test function
* Change executable name
* Increase sleep to 3600s
* Implement a context manager to handle the acme server
* Add certbot_test workspace in .gitignore
* Add documentation
* Remove one function in context, split logic of certbot_test towards capturing non capturing
* Use an explicit an properly configured ACMEServer as handler.
* Add doc. Put constants.
2019-06-12 20:19:23 -04:00
|
|
|
|
You can test your code in several ways:
|
|
|
|
|
|
|
|
|
|
|
|
- running the `automated unit`_ tests,
|
|
|
|
|
|
- running the `automated integration`_ tests
|
|
|
|
|
|
- running an *ad hoc* `manual integration`_ test
|
|
|
|
|
|
|
|
|
|
|
|
.. _automated unit:
|
|
|
|
|
|
|
|
|
|
|
|
Running automated unit tests
|
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
2017-02-16 15:39:17 -05:00
|
|
|
|
When you are working in a file ``foo.py``, there should also be a file ``foo_test.py``
|
|
|
|
|
|
either in the same directory as ``foo.py`` or in the ``tests`` subdirectory
|
|
|
|
|
|
(if there isn't, make one). While you are working on your code and tests, run
|
|
|
|
|
|
``python foo_test.py`` to run the relevant tests.
|
|
|
|
|
|
|
2017-03-03 13:37:31 -05:00
|
|
|
|
For debugging, we recommend putting
|
|
|
|
|
|
``import ipdb; ipdb.set_trace()`` statements inside the source code.
|
2017-02-16 15:39:17 -05:00
|
|
|
|
|
|
|
|
|
|
Once you are done with your code changes, and the tests in ``foo_test.py`` pass,
|
|
|
|
|
|
run all of the unittests for Certbot with ``tox -e py27`` (this uses Python
|
|
|
|
|
|
2.7).
|
|
|
|
|
|
|
2019-08-07 18:07:37 -04:00
|
|
|
|
Once all the unittests pass, check for sufficient test coverage using ``tox -e
|
|
|
|
|
|
py27-cover``, and then check for code style with ``tox -e lint`` (all files) or
|
|
|
|
|
|
``pylint --rcfile=.pylintrc path/to/file.py`` (single file at a time).
|
2017-02-16 15:39:17 -05:00
|
|
|
|
|
2018-05-11 10:07:02 -04:00
|
|
|
|
Once all of the above is successful, you may run the full test suite using
|
|
|
|
|
|
``tox --skip-missing-interpreters``. We recommend running the commands above
|
|
|
|
|
|
first, because running all tests like this is very slow, and the large amount
|
|
|
|
|
|
of output can make it hard to find specific failures when they happen.
|
2017-02-16 15:39:17 -05:00
|
|
|
|
|
2018-05-11 10:07:02 -04:00
|
|
|
|
.. warning:: The full test suite may attempt to modify your system's Apache
|
|
|
|
|
|
config if your user has sudo permissions, so it should not be run on a
|
|
|
|
|
|
production Apache server.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
Add executable scripts to start certbot and acme server in certbot-ci (#7073)
During review of #6989, we saw that some of our test bash scripts were still used in the Boulder project in particular. It is about `tests/integration/_common.sh` in particular, to expose the `certbot_test` bash function, that is an appropriate way to execute a local version of certbot in test mode: define a custom server, remove several checks, full log and so on.
This PR is an attempt to assert this goal: exposing a new `certbot_test` executable for test purpose. More generally, this PR is about giving well suited scripts to quickly make manual tests against certbot without launching the full automated pytest suite.
The idea here is to leverage the existing logic in certbot-ci, and expose it as executable scripts. This is done thanks to the `console_scripts` entry of setuptools entrypoint feature, that install scripts in the `PATH`, when `pip install` is invoked, that delegate to specific functions in the installed packages.
Two scripts are defined this way:
* `certbot_test`: it executes certbot in test mode in a very similar way than the original `certbot_test` in `_common.sh`, by delegating to `certbot_integration_tests.utils.certbot_call:main`. By default this execution will target a pebble directory url started locally. The url, and also http-01/tls-alpn-01 challenge ports can be configured using ad-hoc environment variables. All arguments passed to `certbot_test` are transferred to the underlying certbot command.
* `acme_server`: it set up a fully running instance of an ACME server, ready for tests (in particular, all FQDN resolves to localhost in order to target a locally running `certbot_test` command) by delegating to `certbot_integration_tests.utils.acme_server:main`. The choice of the ACME server is given by the first parameter passed to `acme_server`, it can be `pebble`, `boulder-v1` or `boulder-v2`. The command keeps running on foreground, displaying the logs of the ACME server on stdout/stderr. The server is shut down and resources cleaned upon entering CTRL+C.
This two commands can be run also through the underlying python modules, that are executable.
Finally, a typical workflow on certbot side to run manual tests would be:
```
cd certbot
tools/venv.py
source venv/bin/activate
acme_server pebble &
certbot_test certonly --standalone -d test.example.com
```
On boulder side it could be:
```
# Follow certbot dev environment setup instructions, then ...
cd boulder
docker-compose run --use-aliases -e FAKE_DNS=172.17.0.1 --service-ports boulder ./start.py
SERVER=http://localhost:4001/directory certbot_test certonly --standalone -d test.example.com
```
* Configure certbot-ci to expose a certbot_test console script calling certbot in test mode against a local pebble instance
* Add a command to start pebble/boulder
* Use explicit start
* Add execution permission to acme_server
* Add a docstring to certbot_test function
* Change executable name
* Increase sleep to 3600s
* Implement a context manager to handle the acme server
* Add certbot_test workspace in .gitignore
* Add documentation
* Remove one function in context, split logic of certbot_test towards capturing non capturing
* Use an explicit an properly configured ACMEServer as handler.
* Add doc. Put constants.
2019-06-12 20:19:23 -04:00
|
|
|
|
.. _automated integration:
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
Add executable scripts to start certbot and acme server in certbot-ci (#7073)
During review of #6989, we saw that some of our test bash scripts were still used in the Boulder project in particular. It is about `tests/integration/_common.sh` in particular, to expose the `certbot_test` bash function, that is an appropriate way to execute a local version of certbot in test mode: define a custom server, remove several checks, full log and so on.
This PR is an attempt to assert this goal: exposing a new `certbot_test` executable for test purpose. More generally, this PR is about giving well suited scripts to quickly make manual tests against certbot without launching the full automated pytest suite.
The idea here is to leverage the existing logic in certbot-ci, and expose it as executable scripts. This is done thanks to the `console_scripts` entry of setuptools entrypoint feature, that install scripts in the `PATH`, when `pip install` is invoked, that delegate to specific functions in the installed packages.
Two scripts are defined this way:
* `certbot_test`: it executes certbot in test mode in a very similar way than the original `certbot_test` in `_common.sh`, by delegating to `certbot_integration_tests.utils.certbot_call:main`. By default this execution will target a pebble directory url started locally. The url, and also http-01/tls-alpn-01 challenge ports can be configured using ad-hoc environment variables. All arguments passed to `certbot_test` are transferred to the underlying certbot command.
* `acme_server`: it set up a fully running instance of an ACME server, ready for tests (in particular, all FQDN resolves to localhost in order to target a locally running `certbot_test` command) by delegating to `certbot_integration_tests.utils.acme_server:main`. The choice of the ACME server is given by the first parameter passed to `acme_server`, it can be `pebble`, `boulder-v1` or `boulder-v2`. The command keeps running on foreground, displaying the logs of the ACME server on stdout/stderr. The server is shut down and resources cleaned upon entering CTRL+C.
This two commands can be run also through the underlying python modules, that are executable.
Finally, a typical workflow on certbot side to run manual tests would be:
```
cd certbot
tools/venv.py
source venv/bin/activate
acme_server pebble &
certbot_test certonly --standalone -d test.example.com
```
On boulder side it could be:
```
# Follow certbot dev environment setup instructions, then ...
cd boulder
docker-compose run --use-aliases -e FAKE_DNS=172.17.0.1 --service-ports boulder ./start.py
SERVER=http://localhost:4001/directory certbot_test certonly --standalone -d test.example.com
```
* Configure certbot-ci to expose a certbot_test console script calling certbot in test mode against a local pebble instance
* Add a command to start pebble/boulder
* Use explicit start
* Add execution permission to acme_server
* Add a docstring to certbot_test function
* Change executable name
* Increase sleep to 3600s
* Implement a context manager to handle the acme server
* Add certbot_test workspace in .gitignore
* Add documentation
* Remove one function in context, split logic of certbot_test towards capturing non capturing
* Use an explicit an properly configured ACMEServer as handler.
* Add doc. Put constants.
2019-06-12 20:19:23 -04:00
|
|
|
|
Running automated integration tests
|
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2018-05-11 10:07:02 -04:00
|
|
|
|
Generally it is sufficient to open a pull request and let Github and Travis run
|
2019-05-14 16:56:32 -04:00
|
|
|
|
integration tests for you. However, you may want to run them locally before submitting
|
|
|
|
|
|
your pull request. You need Docker and docker-compose installed and working.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
Add executable scripts to start certbot and acme server in certbot-ci (#7073)
During review of #6989, we saw that some of our test bash scripts were still used in the Boulder project in particular. It is about `tests/integration/_common.sh` in particular, to expose the `certbot_test` bash function, that is an appropriate way to execute a local version of certbot in test mode: define a custom server, remove several checks, full log and so on.
This PR is an attempt to assert this goal: exposing a new `certbot_test` executable for test purpose. More generally, this PR is about giving well suited scripts to quickly make manual tests against certbot without launching the full automated pytest suite.
The idea here is to leverage the existing logic in certbot-ci, and expose it as executable scripts. This is done thanks to the `console_scripts` entry of setuptools entrypoint feature, that install scripts in the `PATH`, when `pip install` is invoked, that delegate to specific functions in the installed packages.
Two scripts are defined this way:
* `certbot_test`: it executes certbot in test mode in a very similar way than the original `certbot_test` in `_common.sh`, by delegating to `certbot_integration_tests.utils.certbot_call:main`. By default this execution will target a pebble directory url started locally. The url, and also http-01/tls-alpn-01 challenge ports can be configured using ad-hoc environment variables. All arguments passed to `certbot_test` are transferred to the underlying certbot command.
* `acme_server`: it set up a fully running instance of an ACME server, ready for tests (in particular, all FQDN resolves to localhost in order to target a locally running `certbot_test` command) by delegating to `certbot_integration_tests.utils.acme_server:main`. The choice of the ACME server is given by the first parameter passed to `acme_server`, it can be `pebble`, `boulder-v1` or `boulder-v2`. The command keeps running on foreground, displaying the logs of the ACME server on stdout/stderr. The server is shut down and resources cleaned upon entering CTRL+C.
This two commands can be run also through the underlying python modules, that are executable.
Finally, a typical workflow on certbot side to run manual tests would be:
```
cd certbot
tools/venv.py
source venv/bin/activate
acme_server pebble &
certbot_test certonly --standalone -d test.example.com
```
On boulder side it could be:
```
# Follow certbot dev environment setup instructions, then ...
cd boulder
docker-compose run --use-aliases -e FAKE_DNS=172.17.0.1 --service-ports boulder ./start.py
SERVER=http://localhost:4001/directory certbot_test certonly --standalone -d test.example.com
```
* Configure certbot-ci to expose a certbot_test console script calling certbot in test mode against a local pebble instance
* Add a command to start pebble/boulder
* Use explicit start
* Add execution permission to acme_server
* Add a docstring to certbot_test function
* Change executable name
* Increase sleep to 3600s
* Implement a context manager to handle the acme server
* Add certbot_test workspace in .gitignore
* Add documentation
* Remove one function in context, split logic of certbot_test towards capturing non capturing
* Use an explicit an properly configured ACMEServer as handler.
* Add doc. Put constants.
2019-06-12 20:19:23 -04:00
|
|
|
|
The tox environment `integration` will setup `Pebble`_, the Let's Encrypt ACME CA server
|
2019-05-14 16:56:32 -04:00
|
|
|
|
for integration testing, then launch the Certbot integration tests.
|
2017-04-07 13:15:52 -04:00
|
|
|
|
|
2019-05-14 16:56:32 -04:00
|
|
|
|
With a user allowed to access your local Docker daemon, run:
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2017-02-16 15:39:17 -05:00
|
|
|
|
.. code-block:: shell
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2019-05-14 16:56:32 -04:00
|
|
|
|
tox -e integration
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2019-05-14 16:56:32 -04:00
|
|
|
|
Tests will be run using pytest. A test report and a code coverage report will be
|
|
|
|
|
|
displayed at the end of the integration tests execution.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
Add executable scripts to start certbot and acme server in certbot-ci (#7073)
During review of #6989, we saw that some of our test bash scripts were still used in the Boulder project in particular. It is about `tests/integration/_common.sh` in particular, to expose the `certbot_test` bash function, that is an appropriate way to execute a local version of certbot in test mode: define a custom server, remove several checks, full log and so on.
This PR is an attempt to assert this goal: exposing a new `certbot_test` executable for test purpose. More generally, this PR is about giving well suited scripts to quickly make manual tests against certbot without launching the full automated pytest suite.
The idea here is to leverage the existing logic in certbot-ci, and expose it as executable scripts. This is done thanks to the `console_scripts` entry of setuptools entrypoint feature, that install scripts in the `PATH`, when `pip install` is invoked, that delegate to specific functions in the installed packages.
Two scripts are defined this way:
* `certbot_test`: it executes certbot in test mode in a very similar way than the original `certbot_test` in `_common.sh`, by delegating to `certbot_integration_tests.utils.certbot_call:main`. By default this execution will target a pebble directory url started locally. The url, and also http-01/tls-alpn-01 challenge ports can be configured using ad-hoc environment variables. All arguments passed to `certbot_test` are transferred to the underlying certbot command.
* `acme_server`: it set up a fully running instance of an ACME server, ready for tests (in particular, all FQDN resolves to localhost in order to target a locally running `certbot_test` command) by delegating to `certbot_integration_tests.utils.acme_server:main`. The choice of the ACME server is given by the first parameter passed to `acme_server`, it can be `pebble`, `boulder-v1` or `boulder-v2`. The command keeps running on foreground, displaying the logs of the ACME server on stdout/stderr. The server is shut down and resources cleaned upon entering CTRL+C.
This two commands can be run also through the underlying python modules, that are executable.
Finally, a typical workflow on certbot side to run manual tests would be:
```
cd certbot
tools/venv.py
source venv/bin/activate
acme_server pebble &
certbot_test certonly --standalone -d test.example.com
```
On boulder side it could be:
```
# Follow certbot dev environment setup instructions, then ...
cd boulder
docker-compose run --use-aliases -e FAKE_DNS=172.17.0.1 --service-ports boulder ./start.py
SERVER=http://localhost:4001/directory certbot_test certonly --standalone -d test.example.com
```
* Configure certbot-ci to expose a certbot_test console script calling certbot in test mode against a local pebble instance
* Add a command to start pebble/boulder
* Use explicit start
* Add execution permission to acme_server
* Add a docstring to certbot_test function
* Change executable name
* Increase sleep to 3600s
* Implement a context manager to handle the acme server
* Add certbot_test workspace in .gitignore
* Add documentation
* Remove one function in context, split logic of certbot_test towards capturing non capturing
* Use an explicit an properly configured ACMEServer as handler.
* Add doc. Put constants.
2019-06-12 20:19:23 -04:00
|
|
|
|
.. _Pebble: https://github.com/letsencrypt/pebble
|
|
|
|
|
|
|
|
|
|
|
|
.. _manual integration:
|
|
|
|
|
|
|
|
|
|
|
|
Running manual integration tests
|
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
|
|
You can also manually execute Certbot against a local instance of the `Pebble`_ ACME server.
|
|
|
|
|
|
This is useful to verify that the modifications done to the code makes Certbot behave as expected.
|
|
|
|
|
|
|
|
|
|
|
|
To do so you need:
|
|
|
|
|
|
|
|
|
|
|
|
- Docker installed, and a user with access to the Docker client,
|
|
|
|
|
|
- an available `local copy`_ of Certbot.
|
|
|
|
|
|
|
|
|
|
|
|
The virtual environment set up with `python tools/venv.py` contains two commands
|
|
|
|
|
|
that can be used once the virtual environment is activated:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
|
|
|
|
|
run_acme_server
|
|
|
|
|
|
|
|
|
|
|
|
- Starts a local instance of Pebble and runs in the foreground printing its logs.
|
|
|
|
|
|
- Press CTRL+C to stop this instance.
|
|
|
|
|
|
- This instance is configured to validate challenges against certbot executed locally.
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
2019-07-25 04:23:28 -04:00
|
|
|
|
certbot_test [ARGS...]
|
Add executable scripts to start certbot and acme server in certbot-ci (#7073)
During review of #6989, we saw that some of our test bash scripts were still used in the Boulder project in particular. It is about `tests/integration/_common.sh` in particular, to expose the `certbot_test` bash function, that is an appropriate way to execute a local version of certbot in test mode: define a custom server, remove several checks, full log and so on.
This PR is an attempt to assert this goal: exposing a new `certbot_test` executable for test purpose. More generally, this PR is about giving well suited scripts to quickly make manual tests against certbot without launching the full automated pytest suite.
The idea here is to leverage the existing logic in certbot-ci, and expose it as executable scripts. This is done thanks to the `console_scripts` entry of setuptools entrypoint feature, that install scripts in the `PATH`, when `pip install` is invoked, that delegate to specific functions in the installed packages.
Two scripts are defined this way:
* `certbot_test`: it executes certbot in test mode in a very similar way than the original `certbot_test` in `_common.sh`, by delegating to `certbot_integration_tests.utils.certbot_call:main`. By default this execution will target a pebble directory url started locally. The url, and also http-01/tls-alpn-01 challenge ports can be configured using ad-hoc environment variables. All arguments passed to `certbot_test` are transferred to the underlying certbot command.
* `acme_server`: it set up a fully running instance of an ACME server, ready for tests (in particular, all FQDN resolves to localhost in order to target a locally running `certbot_test` command) by delegating to `certbot_integration_tests.utils.acme_server:main`. The choice of the ACME server is given by the first parameter passed to `acme_server`, it can be `pebble`, `boulder-v1` or `boulder-v2`. The command keeps running on foreground, displaying the logs of the ACME server on stdout/stderr. The server is shut down and resources cleaned upon entering CTRL+C.
This two commands can be run also through the underlying python modules, that are executable.
Finally, a typical workflow on certbot side to run manual tests would be:
```
cd certbot
tools/venv.py
source venv/bin/activate
acme_server pebble &
certbot_test certonly --standalone -d test.example.com
```
On boulder side it could be:
```
# Follow certbot dev environment setup instructions, then ...
cd boulder
docker-compose run --use-aliases -e FAKE_DNS=172.17.0.1 --service-ports boulder ./start.py
SERVER=http://localhost:4001/directory certbot_test certonly --standalone -d test.example.com
```
* Configure certbot-ci to expose a certbot_test console script calling certbot in test mode against a local pebble instance
* Add a command to start pebble/boulder
* Use explicit start
* Add execution permission to acme_server
* Add a docstring to certbot_test function
* Change executable name
* Increase sleep to 3600s
* Implement a context manager to handle the acme server
* Add certbot_test workspace in .gitignore
* Add documentation
* Remove one function in context, split logic of certbot_test towards capturing non capturing
* Use an explicit an properly configured ACMEServer as handler.
* Add doc. Put constants.
2019-06-12 20:19:23 -04:00
|
|
|
|
|
|
|
|
|
|
- Execute certbot with the provided arguments and other arguments useful for testing purposes,
|
|
|
|
|
|
such as: verbose output, full tracebacks in case Certbot crashes, *etc.*
|
|
|
|
|
|
- Execution is preconfigured to interact with the Pebble CA started with ``run_acme_server``.
|
|
|
|
|
|
- Any arguments can be passed as they would be to Certbot (eg. ``certbot_test certonly -d test.example.com``).
|
|
|
|
|
|
|
|
|
|
|
|
Here is a typical workflow to verify that Certbot successfully issued a certificate
|
|
|
|
|
|
using an HTTP-01 challenge on a machine with Python 3:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
|
|
|
|
|
python tools/venv3.py
|
|
|
|
|
|
source venv3/bin/activate
|
|
|
|
|
|
run_acme_server &
|
|
|
|
|
|
certbot_test certonly --standalone -d test.example.com
|
|
|
|
|
|
# To stop Pebble, launch `fg` to get back the background job, then press CTRL+C
|
|
|
|
|
|
|
2016-04-18 18:08:16 -04:00
|
|
|
|
Code components and layout
|
|
|
|
|
|
==========================
|
|
|
|
|
|
|
2019-11-01 18:05:41 -04:00
|
|
|
|
The following components of the Certbot repository are distributed to users:
|
|
|
|
|
|
|
2016-04-18 18:08:16 -04:00
|
|
|
|
acme
|
|
|
|
|
|
contains all protocol specific code
|
|
|
|
|
|
certbot
|
2017-02-16 15:39:17 -05:00
|
|
|
|
main client code
|
|
|
|
|
|
certbot-apache and certbot-nginx
|
|
|
|
|
|
client code to configure specific web servers
|
2019-11-01 18:05:41 -04:00
|
|
|
|
certbot-dns-*
|
|
|
|
|
|
client code to configure DNS providers
|
|
|
|
|
|
certbot-auto and letsencrypt-auto
|
|
|
|
|
|
shell scripts to install Certbot and its dependencies on UNIX systems
|
|
|
|
|
|
windows installer
|
|
|
|
|
|
Installs Certbot on Windows and is built using the files in windows-installer/
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
Plugin-architecture
|
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
|
|
Certbot has a plugin architecture to facilitate support for
|
|
|
|
|
|
different webservers, other TLS servers, and operating systems.
|
|
|
|
|
|
The interfaces available for plugins to implement are defined in
|
|
|
|
|
|
`interfaces.py`_ and `plugins/common.py`_.
|
|
|
|
|
|
|
2017-03-17 16:13:45 -04:00
|
|
|
|
The main two plugin interfaces are `~certbot.interfaces.IAuthenticator`, which
|
|
|
|
|
|
implements various ways of proving domain control to a certificate authority,
|
|
|
|
|
|
and `~certbot.interfaces.IInstaller`, which configures a server to use a
|
|
|
|
|
|
certificate once it is issued. Some plugins, like the built-in Apache and Nginx
|
|
|
|
|
|
plugins, implement both interfaces and perform both tasks. Others, like the
|
|
|
|
|
|
built-in Standalone authenticator, implement just one interface.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
There are also `~certbot.interfaces.IDisplay` plugins,
|
2017-03-17 16:13:45 -04:00
|
|
|
|
which can change how prompts are displayed to a user.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2016-05-03 20:04:30 -04:00
|
|
|
|
.. _interfaces.py: https://github.com/certbot/certbot/blob/master/certbot/interfaces.py
|
|
|
|
|
|
.. _plugins/common.py: https://github.com/certbot/certbot/blob/master/certbot/plugins/common.py#L34
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Authenticators
|
|
|
|
|
|
--------------
|
|
|
|
|
|
|
2017-03-17 16:13:45 -04:00
|
|
|
|
Authenticators are plugins that prove control of a domain name by solving a
|
2018-12-10 20:48:59 -05:00
|
|
|
|
challenge provided by the ACME server. ACME currently defines several types of
|
2019-10-31 13:17:29 -04:00
|
|
|
|
challenges: HTTP, TLS-ALPN, and DNS, represented by classes in `acme.challenges`.
|
2017-03-17 16:13:45 -04:00
|
|
|
|
An authenticator plugin should implement support for at least one challenge type.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2017-03-17 16:13:45 -04:00
|
|
|
|
An Authenticator indicates which challenges it supports by implementing
|
2017-04-03 17:55:27 -04:00
|
|
|
|
`get_chall_pref(domain)` to return a sorted list of challenge types in
|
|
|
|
|
|
preference order.
|
2017-03-17 16:13:45 -04:00
|
|
|
|
|
|
|
|
|
|
An Authenticator must also implement `perform(achalls)`, which "performs" a list
|
|
|
|
|
|
of challenges by, for instance, provisioning a file on an HTTP server, or
|
|
|
|
|
|
setting a TXT record in DNS. Once all challenges have succeeded or failed,
|
|
|
|
|
|
Certbot will call the plugin's `cleanup(achalls)` method to remove any files or
|
|
|
|
|
|
DNS records that were needed only during authentication.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
Installer
|
|
|
|
|
|
---------
|
|
|
|
|
|
|
|
|
|
|
|
Installers plugins exist to actually setup the certificate in a server,
|
|
|
|
|
|
possibly tweak the security configuration to make it more correct and secure
|
|
|
|
|
|
(Fix some mixed content problems, turn on HSTS, redirect to HTTPS, etc).
|
|
|
|
|
|
Installer plugins tell the main client about their abilities to do the latter
|
|
|
|
|
|
via the :meth:`~.IInstaller.supported_enhancements` call. We currently
|
|
|
|
|
|
have two Installers in the tree, the `~.ApacheConfigurator`. and the
|
|
|
|
|
|
`~.NginxConfigurator`. External projects have made some progress toward
|
|
|
|
|
|
support for IIS, Icecast and Plesk.
|
|
|
|
|
|
|
|
|
|
|
|
Installers and Authenticators will oftentimes be the same class/object
|
|
|
|
|
|
(because for instance both tasks can be performed by a webserver like nginx)
|
|
|
|
|
|
though this is not always the case (the standalone plugin is an authenticator
|
2018-12-07 17:18:28 -05:00
|
|
|
|
that listens on port 80, but it cannot install certs; a postfix plugin would
|
2016-04-18 18:08:16 -04:00
|
|
|
|
be an installer but not an authenticator).
|
|
|
|
|
|
|
|
|
|
|
|
Installers and Authenticators are kept separate because
|
|
|
|
|
|
it should be possible to use the `~.StandaloneAuthenticator` (it sets
|
|
|
|
|
|
up its own Python server to perform challenges) with a program that
|
|
|
|
|
|
cannot solve challenges itself (Such as MTA installers).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Installer Development
|
|
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
|
|
|
|
There are a few existing classes that may be beneficial while
|
|
|
|
|
|
developing a new `~certbot.interfaces.IInstaller`.
|
|
|
|
|
|
Installers aimed to reconfigure UNIX servers may use Augeas for
|
|
|
|
|
|
configuration parsing and can inherit from `~.AugeasConfigurator` class
|
|
|
|
|
|
to handle much of the interface. Installers that are unable to use
|
|
|
|
|
|
Augeas may still find the `~.Reverter` class helpful in handling
|
|
|
|
|
|
configuration checkpoints and rollback.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. _dev-plugin:
|
|
|
|
|
|
|
|
|
|
|
|
Writing your own plugin
|
2017-03-17 16:13:45 -04:00
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
Certbot client supports dynamic discovery of plugins through the
|
2017-04-03 17:51:48 -04:00
|
|
|
|
`setuptools entry points`_ using the `certbot.plugins` group. This
|
|
|
|
|
|
way you can, for example, create a custom implementation of
|
|
|
|
|
|
`~certbot.interfaces.IAuthenticator` or the
|
|
|
|
|
|
`~certbot.interfaces.IInstaller` without having to merge it
|
2016-04-18 18:08:16 -04:00
|
|
|
|
with the core upstream source code. An example is provided in
|
|
|
|
|
|
``examples/plugins/`` directory.
|
2017-03-17 16:13:45 -04:00
|
|
|
|
|
|
|
|
|
|
While developing, you can install your plugin into a Certbot development
|
|
|
|
|
|
virtualenv like this:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: shell
|
2017-04-03 17:58:25 -04:00
|
|
|
|
|
2017-03-17 16:13:45 -04:00
|
|
|
|
. venv/bin/activate
|
|
|
|
|
|
pip install -e examples/plugins/
|
|
|
|
|
|
certbot_test plugins
|
|
|
|
|
|
|
|
|
|
|
|
Your plugin should show up in the output of the last command. If not,
|
|
|
|
|
|
it was not installed properly.
|
|
|
|
|
|
|
|
|
|
|
|
Once you've finished your plugin and published it, you can have your
|
|
|
|
|
|
users install it system-wide with `pip install`. Note that this will
|
|
|
|
|
|
only work for users who have Certbot installed from OS packages or via
|
|
|
|
|
|
pip. Users who run `certbot-auto` are currently unable to use third-party
|
|
|
|
|
|
plugins. It's technically possible to install third-party plugins into
|
|
|
|
|
|
the virtualenv used by `certbot-auto`, but they will be wiped away when
|
|
|
|
|
|
`certbot-auto` upgrades.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
.. warning:: Please be aware though that as this client is still in a
|
|
|
|
|
|
developer-preview stage, the API may undergo a few changes. If you
|
|
|
|
|
|
believe the plugin will be beneficial to the community, please
|
|
|
|
|
|
consider submitting a pull request to the repo and we will update
|
|
|
|
|
|
it with any necessary API changes.
|
|
|
|
|
|
|
|
|
|
|
|
.. _`setuptools entry points`:
|
2016-06-06 20:05:51 -04:00
|
|
|
|
http://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
.. _coding-style:
|
|
|
|
|
|
|
|
|
|
|
|
Coding style
|
|
|
|
|
|
============
|
|
|
|
|
|
|
|
|
|
|
|
Please:
|
|
|
|
|
|
|
|
|
|
|
|
1. **Be consistent with the rest of the code**.
|
|
|
|
|
|
|
|
|
|
|
|
2. Read `PEP 8 - Style Guide for Python Code`_.
|
|
|
|
|
|
|
|
|
|
|
|
3. Follow the `Google Python Style Guide`_, with the exception that we
|
|
|
|
|
|
use `Sphinx-style`_ documentation::
|
|
|
|
|
|
|
|
|
|
|
|
def foo(arg):
|
|
|
|
|
|
"""Short description.
|
|
|
|
|
|
|
|
|
|
|
|
:param int arg: Some number.
|
|
|
|
|
|
|
|
|
|
|
|
:returns: Argument
|
|
|
|
|
|
:rtype: int
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
return arg
|
|
|
|
|
|
|
|
|
|
|
|
4. Remember to use ``pylint``.
|
|
|
|
|
|
|
|
|
|
|
|
.. _Google Python Style Guide:
|
2016-05-13 19:37:43 -04:00
|
|
|
|
https://google.github.io/styleguide/pyguide.html
|
2016-04-18 18:08:16 -04:00
|
|
|
|
.. _Sphinx-style: http://sphinx-doc.org/
|
|
|
|
|
|
.. _PEP 8 - Style Guide for Python Code:
|
|
|
|
|
|
https://www.python.org/dev/peps/pep-0008
|
|
|
|
|
|
|
2019-04-12 16:32:52 -04:00
|
|
|
|
Use ``certbot.compat.os`` instead of ``os``
|
|
|
|
|
|
===========================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Python's standard library ``os`` module lacks full support for several Windows
|
|
|
|
|
|
security features about file permissions (eg. DACLs). However several files
|
|
|
|
|
|
handled by Certbot (eg. private keys) need strongly restricted access
|
|
|
|
|
|
on both Linux and Windows.
|
|
|
|
|
|
|
|
|
|
|
|
To help with this, the ``certbot.compat.os`` module wraps the standard
|
|
|
|
|
|
``os`` module, and forbids usage of methods that lack support for these Windows
|
|
|
|
|
|
security features.
|
|
|
|
|
|
|
|
|
|
|
|
As a developer, when working on Certbot or its plugins, you must use ``certbot.compat.os``
|
|
|
|
|
|
in every place you would need ``os`` (eg. ``from certbot.compat import os`` instead of
|
|
|
|
|
|
``import os``). Otherwise the tests will fail when your PR is submitted.
|
|
|
|
|
|
|
2019-07-10 21:14:12 -04:00
|
|
|
|
.. _type annotations:
|
|
|
|
|
|
|
2018-05-31 16:57:23 -04:00
|
|
|
|
Mypy type annotations
|
|
|
|
|
|
=====================
|
|
|
|
|
|
|
|
|
|
|
|
Certbot uses the `mypy`_ static type checker. Python 3 natively supports official type annotations,
|
|
|
|
|
|
which can then be tested for consistency using mypy. Python 2 doesn’t, but type annotations can
|
|
|
|
|
|
be `added in comments`_. Mypy does some type checks even without type annotations; we can find
|
|
|
|
|
|
bugs in Certbot even without a fully annotated codebase.
|
|
|
|
|
|
|
|
|
|
|
|
Certbot supports both Python 2 and 3, so we’re using Python 2-style annotations.
|
|
|
|
|
|
|
|
|
|
|
|
Zulip wrote a `great guide`_ to using mypy. It’s useful, but you don’t have to read the whole thing
|
|
|
|
|
|
to start contributing to Certbot.
|
|
|
|
|
|
|
|
|
|
|
|
To run mypy on Certbot, use ``tox -e mypy`` on a machine that has Python 3 installed.
|
|
|
|
|
|
|
|
|
|
|
|
Note that instead of just importing ``typing``, due to packaging issues, in Certbot we import from
|
|
|
|
|
|
``acme.magic_typing`` and have to add some comments for pylint like this:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
|
|
from acme.magic_typing import Dict # pylint: disable=unused-import, no-name-in-module
|
|
|
|
|
|
|
|
|
|
|
|
Also note that OpenSSL, which we rely on, has type definitions for crypto but not SSL. We use both.
|
|
|
|
|
|
Those imports should look like this:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
|
|
from OpenSSL import crypto
|
|
|
|
|
|
from OpenSSL import SSL # type: ignore # https://github.com/python/typeshed/issues/2052
|
|
|
|
|
|
|
|
|
|
|
|
.. _mypy: https://mypy.readthedocs.io
|
|
|
|
|
|
.. _added in comments: https://mypy.readthedocs.io/en/latest/cheat_sheet.html
|
|
|
|
|
|
.. _great guide: https://blog.zulip.org/2016/10/13/static-types-in-python-oh-mypy/
|
|
|
|
|
|
|
2016-04-18 18:08:16 -04:00
|
|
|
|
Submitting a pull request
|
|
|
|
|
|
=========================
|
|
|
|
|
|
|
|
|
|
|
|
Steps:
|
|
|
|
|
|
|
2019-07-10 21:14:12 -04:00
|
|
|
|
1. Write your code! When doing this, you should add :ref:`mypy type annotations
|
|
|
|
|
|
<type annotations>` for any functions you add or modify. You can check that
|
|
|
|
|
|
you've done this correctly by running ``tox -e mypy`` on a machine that has
|
|
|
|
|
|
Python 3 installed.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
2. Make sure your environment is set up properly and that you're in your
|
2019-04-05 16:42:30 -04:00
|
|
|
|
virtualenv. You can do this by following the instructions in the
|
|
|
|
|
|
:ref:`Getting Started <getting_started>` section.
|
2017-01-19 14:21:25 -05:00
|
|
|
|
3. Run ``tox -e lint`` to check for pylint errors. Fix any errors.
|
|
|
|
|
|
4. Run ``tox --skip-missing-interpreters`` to run the entire test suite
|
2016-06-16 22:13:44 -04:00
|
|
|
|
including coverage. The ``--skip-missing-interpreters`` argument ignores
|
|
|
|
|
|
missing versions of Python needed for running the tests. Fix any errors.
|
2018-11-29 18:42:08 -05:00
|
|
|
|
5. Submit the PR. Once your PR is open, please do not force push to the branch
|
|
|
|
|
|
containing your pull request to squash or amend commits. We use `squash
|
|
|
|
|
|
merges <https://github.com/blog/2141-squash-your-commits>`_ on PRs and
|
|
|
|
|
|
rewriting commits makes changes harder to track between reviews.
|
2018-05-11 10:07:02 -04:00
|
|
|
|
6. Did your tests pass on Travis? If they didn't, fix any errors.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2019-06-28 18:53:56 -04:00
|
|
|
|
.. _ask for help:
|
|
|
|
|
|
|
2018-05-11 13:52:45 -04:00
|
|
|
|
Asking for help
|
|
|
|
|
|
===============
|
|
|
|
|
|
|
|
|
|
|
|
If you have any questions while working on a Certbot issue, don't hesitate to
|
2019-04-04 16:30:38 -04:00
|
|
|
|
ask for help! You can do this in the Certbot channel in EFF's Mattermost
|
2019-05-14 16:28:23 -04:00
|
|
|
|
instance for its open source projects as described below.
|
|
|
|
|
|
|
|
|
|
|
|
You can get involved with several of EFF's software projects such as Certbot at
|
|
|
|
|
|
the `EFF Open Source Contributor Chat Platform
|
|
|
|
|
|
<https://opensource.eff.org/signup_user_complete/?id=6iqur37ucfrctfswrs14iscobw>`_.
|
|
|
|
|
|
By signing up for the EFF Open Source Contributor Chat Platform, you consent to
|
|
|
|
|
|
share your personal information with the Electronic Frontier Foundation, which
|
|
|
|
|
|
is the operator and data controller for this platform. The channels will be
|
|
|
|
|
|
available both to EFF, and to other users of EFFOSCCP, who may use or disclose
|
|
|
|
|
|
information in these channels outside of EFFOSCCP. EFF will use your
|
|
|
|
|
|
information, according to the `Privacy Policy <https://www.eff.org/policy>`_,
|
|
|
|
|
|
to further the mission of EFF, including hosting and moderating the discussions
|
|
|
|
|
|
on this platform.
|
|
|
|
|
|
|
|
|
|
|
|
Use of EFFOSCCP is subject to the `EFF Code of Conduct
|
|
|
|
|
|
<https://www.eff.org/pages/eppcode>`_. When investigating an alleged Code of
|
|
|
|
|
|
Conduct violation, EFF may review discussion channels or direct messages.
|
2017-01-07 19:45:44 -05:00
|
|
|
|
|
|
|
|
|
|
Updating certbot-auto and letsencrypt-auto
|
|
|
|
|
|
==========================================
|
2018-05-11 10:07:02 -04:00
|
|
|
|
|
2019-06-28 18:53:56 -04:00
|
|
|
|
.. note:: We are currently only accepting changes to certbot-auto that fix
|
|
|
|
|
|
regressions on platforms where certbot-auto is the recommended installation
|
|
|
|
|
|
method at https://certbot.eff.org/instructions. If you are unsure if a change
|
|
|
|
|
|
you want to make qualifies, don't hesitate to `ask for help`_!
|
|
|
|
|
|
|
2017-01-07 19:45:44 -05:00
|
|
|
|
Updating the scripts
|
|
|
|
|
|
--------------------
|
|
|
|
|
|
Developers should *not* modify the ``certbot-auto`` and ``letsencrypt-auto`` files
|
|
|
|
|
|
in the root directory of the repository. Rather, modify the
|
|
|
|
|
|
``letsencrypt-auto.template`` and associated platform-specific shell scripts in
|
|
|
|
|
|
the ``letsencrypt-auto-source`` and
|
|
|
|
|
|
``letsencrypt-auto-source/pieces/bootstrappers`` directory, respectively.
|
|
|
|
|
|
|
|
|
|
|
|
Building letsencrypt-auto-source/letsencrypt-auto
|
|
|
|
|
|
-------------------------------------------------
|
|
|
|
|
|
Once changes to any of the aforementioned files have been made, the
|
2017-01-26 19:21:54 -05:00
|
|
|
|
``letsencrypt-auto-source/letsencrypt-auto`` script should be updated. In lieu of
|
2017-01-07 19:45:44 -05:00
|
|
|
|
manually updating this script, run the build script, which lives at
|
|
|
|
|
|
``letsencrypt-auto-source/build.py``:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
|
|
|
|
|
python letsencrypt-auto-source/build.py
|
|
|
|
|
|
|
|
|
|
|
|
Running ``build.py`` will update the ``letsencrypt-auto-source/letsencrypt-auto``
|
|
|
|
|
|
script. Note that the ``certbot-auto`` and ``letsencrypt-auto`` scripts in the root
|
|
|
|
|
|
directory of the repository will remain **unchanged** after this script is run.
|
|
|
|
|
|
Your changes will be propagated to these files during the next release of
|
|
|
|
|
|
Certbot.
|
|
|
|
|
|
|
|
|
|
|
|
Opening a PR
|
|
|
|
|
|
------------
|
|
|
|
|
|
When opening a PR, ensure that the following files are committed:
|
|
|
|
|
|
|
|
|
|
|
|
1. ``letsencrypt-auto-source/letsencrypt-auto.template`` and
|
|
|
|
|
|
``letsencrypt-auto-source/pieces/bootstrappers/*``
|
|
|
|
|
|
2. ``letsencrypt-auto-source/letsencrypt-auto`` (generated by ``build.py``)
|
|
|
|
|
|
|
|
|
|
|
|
It might also be a good idea to double check that **no** changes were
|
|
|
|
|
|
inadvertently made to the ``certbot-auto`` or ``letsencrypt-auto`` scripts in the
|
|
|
|
|
|
root of the repository. These scripts will be updated by the core developers
|
|
|
|
|
|
during the next release.
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-04-18 18:08:16 -04:00
|
|
|
|
Updating the documentation
|
|
|
|
|
|
==========================
|
|
|
|
|
|
|
|
|
|
|
|
In order to generate the Sphinx documentation, run the following
|
|
|
|
|
|
commands:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
2016-05-13 15:22:55 -04:00
|
|
|
|
make -C docs clean html man
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
This should generate documentation in the ``docs/_build/html``
|
|
|
|
|
|
directory.
|
|
|
|
|
|
|
2018-03-17 22:23:53 -04:00
|
|
|
|
.. note:: If you skipped the "Getting Started" instructions above,
|
2018-03-21 02:40:44 -04:00
|
|
|
|
run ``pip install -e ".[docs]"`` to install Certbot's docs extras modules.
|
2018-03-17 22:23:53 -04:00
|
|
|
|
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2018-03-16 20:48:46 -04:00
|
|
|
|
.. _docker-dev:
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2017-03-10 20:27:09 -05:00
|
|
|
|
Running the client with Docker
|
|
|
|
|
|
==============================
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2017-03-10 20:27:09 -05:00
|
|
|
|
You can use Docker Compose to quickly set up an environment for running and
|
2018-05-11 10:07:02 -04:00
|
|
|
|
testing Certbot. To install Docker Compose, follow the instructions at
|
|
|
|
|
|
https://docs.docker.com/compose/install/.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2017-03-10 20:27:09 -05:00
|
|
|
|
.. note:: Linux users can simply run ``pip install docker-compose`` to get
|
|
|
|
|
|
Docker Compose after installing Docker Engine and activating your shell as
|
|
|
|
|
|
described in the :ref:`Getting Started <getting_started>` section.
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2017-03-10 20:27:09 -05:00
|
|
|
|
Now you can develop on your host machine, but run Certbot and test your changes
|
|
|
|
|
|
in Docker. When using ``docker-compose`` make sure you are inside your clone of
|
|
|
|
|
|
the Certbot repository. As an example, you can run the following command to
|
|
|
|
|
|
check for linting errors::
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2017-03-10 20:27:09 -05:00
|
|
|
|
docker-compose run --rm --service-ports development bash -c 'tox -e lint'
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2017-03-10 20:27:09 -05:00
|
|
|
|
You can also leave a terminal open running a shell in the Docker container and
|
|
|
|
|
|
modify Certbot code in another window. The Certbot repo on your host machine is
|
|
|
|
|
|
mounted inside of the container so any changes you make immediately take
|
|
|
|
|
|
effect. To do this, run::
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2017-03-10 20:27:09 -05:00
|
|
|
|
docker-compose run --rm --service-ports development bash
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2017-03-10 20:27:09 -05:00
|
|
|
|
Now running the check for linting errors described above is as easy as::
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
2017-03-10 20:27:09 -05:00
|
|
|
|
tox -e lint
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
.. _prerequisites:
|
|
|
|
|
|
|
|
|
|
|
|
Notes on OS dependencies
|
|
|
|
|
|
========================
|
|
|
|
|
|
|
|
|
|
|
|
OS-level dependencies can be installed like so:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
2018-05-11 10:07:02 -04:00
|
|
|
|
./certbot-auto --debug --os-packages-only
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
In general...
|
|
|
|
|
|
|
|
|
|
|
|
* ``sudo`` is required as a suggested way of running privileged process
|
2018-05-11 10:07:02 -04:00
|
|
|
|
* `Python`_ 2.7 or 3.4+ is required
|
2016-04-18 18:08:16 -04:00
|
|
|
|
* `Augeas`_ is required for the Python bindings
|
2018-05-11 10:07:02 -04:00
|
|
|
|
* ``virtualenv`` is used for managing other Python library dependencies
|
2016-04-18 18:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
.. _Python: https://wiki.python.org/moin/BeginnersGuide/Download
|
|
|
|
|
|
.. _Augeas: http://augeas.net/
|
|
|
|
|
|
.. _Virtualenv: https://virtualenv.pypa.io
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FreeBSD
|
|
|
|
|
|
-------
|
|
|
|
|
|
|
|
|
|
|
|
FreeBSD by default uses ``tcsh``. In order to activate virtualenv (see
|
2017-04-04 00:45:48 -04:00
|
|
|
|
above), you will need a compatible shell, e.g. ``pkg install bash &&
|
2016-04-18 18:08:16 -04:00
|
|
|
|
bash``.
|