Commit graph

330 commits

Author SHA1 Message Date
Brad Warren
d8a54dc444
Remove leading *. from default cert name. (#5639) 2018-03-01 14:55:45 -08:00
Brad Warren
8121acf2c1
Add user friendly wildcard error for ACMEv1 (#5636)
* add WildcardUnsupportedError

* Add friendly unsupported wildcard error msg

* correct documentation

* add version specifier
2018-03-01 14:54:48 -08:00
Brad Warren
78735fa2c3
Suggest DNS authenticator when it's needed (#5638) 2018-02-28 16:08:06 -08:00
Joona Hoikkala
e9bc4a319b Apache plugin wildcard support for ACMEv2 (#5608)
In `deploy_cert()` and `enhance()`, the user will be presented with a dialog to choose from the VirtualHosts that can be covered by the wildcard domain name. The (multiple) selection result will then be handled in a similar way that we previously handled a single VirtualHost that was returned by the `_find_best_vhost()`.

Additionally the selected VirtualHosts are added to a dictionary that maps selections to a wildcard domain to be reused in the later `enhance()` call and not forcing the user to select the same VirtualHosts again.

* Apache plugin wildcard support

* Present dialog only once per domain, added tests

* Raise exception if no VHosts selected for wildcard domain
2018-02-28 11:31:47 -08:00
Brad Warren
a39d2fe55b Fix wildcard issuance (#5620)
* Add is_wildcard_domain to certbot.util.

* Error with --allow-subset-of-names and wildcards.

* Fix issue preventing wildcard cert issuance.

* Kill assumption domain is unique in auth_handler

* fix typo and add test

* update comments
2018-02-27 18:05:33 -08:00
Brad Warren
1e46d26ac3 Fix ACMEv2 issues (#5612)
* Add post wrapper to automatically add acme_version

* Add uri to authzr.

* Only add kid when account is set.

* Add content_type when downloading certificate.

* Only save new_authz URL when it exists.

* Handle combinations in ACMEv1 and ACMEv2.

* Add tests for ACMEv2 "combinations".
2018-02-22 16:28:50 -08:00
ohemorange
457269b005 Add finalize_order to shim object, update Certbot to use it (#5601)
* update order object with returned authorizations

* major structure of finalize_order shim refactor

* util methods and imports for finalize_order shim refactor

* update certbot.tests.client_test.py

* extraneous client_test imports

* remove correct import

* update renewal call

* add test for acme.dump_pyopenssl_chain

* Add test for certbot.crypto_util.cert_and_chain_from_fullchain

* add tests for acme.client and change to fetch chain failure to TimeoutError

* s/rytpe/rtype

* remove ClientV1 passthrough

* dump the wrapped cert

* remove dead code

* remove the correct dead code

* support earlier mock
2018-02-22 10:14:29 -08:00
Brad Warren
f3b23662f1 Don't error immediately on wildcards. (#5600) 2018-02-21 20:52:04 -08:00
ohemorange
ea3b78e3c9
update order object with returned authorizations (#5598) 2018-02-20 18:53:48 -08:00
Erica Portnoy
d13a4ed18d add tests for if partial auth success 2018-02-20 16:50:23 -08:00
Erica Portnoy
df50f2d5fa client test 2018-02-20 16:12:15 -08:00
Erica Portnoy
65d0b9674c Fix client test 2018-02-20 16:01:35 -08:00
Erica Portnoy
051664a142 lint 2018-02-20 15:39:30 -08:00
Erica Portnoy
7c073dbcaf lint 2018-02-20 15:38:18 -08:00
Erica Portnoy
d29c637bf9 support best_effort 2018-02-20 15:36:35 -08:00
Erica Portnoy
3dfeb483ee lint 2018-02-20 14:49:23 -08:00
Erica Portnoy
76a0cbf9c2 client tests passing 2018-02-20 14:43:12 -08:00
Erica Portnoy
a0e84e65ce auth_handler tests are happy 2018-02-20 14:29:04 -08:00
Erica Portnoy
d6b4e2001b put back in best_effort code, with a todo for actually supporting it in ACMEv2 2018-02-20 13:19:04 -08:00
Erica Portnoy
68e24a8ea7 start test updates 2018-02-16 17:59:51 -08:00
ohemorange
d467a4ae95 Add mechanism to detect acme version (#5554)
Detects acme version by checking for newNonce field in the directory, since it's mandatory. Also updates ClientNetwork.account on register and update_registration.

* add mechanism to detect acme version

* update ClientNetwork.account comment

* switch to MultiVersionClient object in acme

* add shim methods

* add returns

* use backwards-compatible format and implement register

* update to actual representation of tos v2

* add tos fields and pass through to v1 for partial updates

* update tests

* pass more tests

* allow instance variable pass-through and lint

* update certbot and tests to use new_account_and_tos method

* remove --agree-tos test from main_test for now because we moved the callback into acme

* add docstrings

* use hasattr

* all most review comments

* use terms_of_service for both v1 and v2

* add tests for acme/client.py

* tests for acme/messages.py
2018-02-15 19:04:17 -08:00
sydneyli
7e6d2f1efe
Merge pull request #5259 from certbot/issue_5045
Show expiration dates for cert when skipping its renewal
2018-02-15 09:53:13 -08:00
Sydney Li
608875cd65 Add test for skipped certs 2018-02-14 15:45:08 -08:00
Joona Hoikkala
fbace69b5e Fix install verb (#5536)
* Fix install verb

* Fix error message, tests and remove global pylint change

* Fix boulder integration test keypath

* Also use chain_path from lineage if not defined on CLI
2018-02-14 09:28:36 -08:00
Jacob Hoffman-Andrews
789be8f9bc Change "Attempting to parse" warning to info. (#5557)
* Change "Attempting to parse" warning to info.

This message shows up on every renewal run when the config was updated
by a newer version of Certbot than the one being run. For instance, if a
user has the certbot packages installed from PPA (currently 0.18.2), but
runs certbot-auto once to try out the latest version (0.21.1), they will
start getting this message via email every 12 hours.
2018-02-12 14:55:41 -08:00
Brad Warren
24ddc65cd4
Allow non-interactive revocation without deleting certificates (#5386)
* Add --delete-after-revoke flags

* Use delete_after_revoke value

* Add delete_after_revoke unit tests

* Add integration tests for delete-after-revoke.
2018-01-08 17:02:20 -08:00
Jannis Leidel
2abc94661a Use josepy instead of acme.jose. (#5203) 2017-12-11 11:25:09 -08:00
Brad Warren
bb70962bb8
Stop using new mock functionality in tests (#5295)
* Remove assert_called_once from dns-route53

* Remove assert_called_once from main_test.py

* Remove assert_called() usage in dns-digitalocean

* Remove assert_called() usage in dns-route53

* Downgrade mock version in certbot-auto
2017-12-04 14:44:22 -08:00
Brad Warren
48173ed1cb
Switch from nose to pytest (#5282)
* Use pipstrap to install a good version of pip

* Use pytest in cb-auto tests

* Remove nose usage in auto_test.py

* remove nose dev dep

* use pytest in test_tests

* Use pytest in tox

* Update dev dependency pinnings

* remove nose multiprocess lines

* Use pytest for coverage

* Use older py and pytest for old python versions

* Add test for Error.__str__

* pin pytest in oldest test

* Fix tests for DNS-DO plugin on py26

* Work around bug for Python 3.3

* Clarify dockerfile comments
2017-12-01 10:59:55 -08:00
mvi
19a4e6079e [#5155] - replaces instances of isinstance(x, str) with isinstance(x, six.string_types) 2017-10-26 19:13:25 +02:00
yomna
3087b436f3 Delete after revoke [#4109] (#4914)
*     Switching from old branch (issue-4109) and addressing changes requested
    in last iteration of review:
    80aa857fd2

    Requested changes that were addressed:
    - fixed outdated docstring for `cert_path_to_lineage`
    - removed `full_archive_dir_from_renewal_conf` amd replaced with `full_archive_path` (and `_full_archive_path` -> `full_archive_path`)
    - matching on `cert` instead of `chain` in `cert_manager.cert_path_to_lineage`
    - fixed the two coding wrongs make a right issue

    Requested changes which were not addressed:
    - moving `cert_path_to_lineage` from `cert_manager` to `storage`,
      as it would introduce a hard to resolve circular dependency.

* Update integration tests to handle default deletion after revoke.

* Swapping test domains.

* Addressing PR feedback:
	- calling storage.full_archive_path with a ConfigObj instead of None
	- Removing lambda x: x.chain_path as an option to match against

* Addressing PR feedback: it's expected that len(pattern) is 0, so handle that case properly.

* Testing of conflicting values of --cert-name and --cert-path non-interactive mode.

* Silly test for when neither certname nor cert-path were specified.

* Changing archive_files to a private function, because mocking nested functions seems impossible.

* Tests for storage.cert_path_for_cert_name

* Splitting out _acceptable_matches

* Some tests for cert_manager.cert_path_to_lineage

* Offerings to the Lint God

* Cleaner way of dealing with files in archive dirs

* Handling the two different use cases of match_and_check_overlaps a bit better

* late night syntax errors

* Test for when multiple lineages share an archive dir

* Tests for certbot.cert_manager.match_and_check_overlaps

* Removing unneeded nesting

* Lint errors that Travis caught that didn't show up locally

* Adding two integration tests (matching & mismatched --cert-path, --cert-name)  based on feedback.

* Asking the user if they want to delete in interactive mode.
2017-10-03 16:36:26 -07:00
Brad Warren
356471cdf6 Add hook directories (#5151)
* Add hook dir constants

* Add hook dir properties to configuration

* test hook dir properties

* reuse certbot.util.is_exe

* Add certbot.hooks.list_hooks

* test list_hooks

* Run pre-hooks in directory

* Run deploy-hooks in directory

* Run post-hooks in directory

* Refactor and update certbot/tests/hook_test.py

* Add integration tests for hook directories

* Have Certbot create hook directories.

* document renewal hook directories

* Add --no-directory-hooks

* Make minor note about locale independent sorting
2017-10-03 13:52:02 -07:00
r5d
b9d129bd43 certbot: Stop using print in log module. (#5160)
* Update certbot.log.post_arg_parse_except_hook function.
* Update certbot.tests.log_test._test_common method.

See discussion #3720.
2017-10-03 12:52:41 -07:00
Brad Warren
5f6b1378ec Fixes #5115 (#5150) 2017-10-02 14:33:49 -07:00
ohemorange
7412099567 Allow multiple interactive certname selections in certbot delete (#5133) 2017-09-27 15:47:40 -07:00
r5d
85deca588f Stop using print in certbot.main module. (#5121)
* Stop using print in `certbot.main` module.

* Update certbot.main.plugins_cmd` function.

* Update test methods `test_plugins_no_args`,
`test_plugins_no_args_unprivileged`, `test_plugins_init` and
`test_plugins_prepare` in `cerbot.tests.MainTest` class.

Addresses #3720.

* certbot: Add `patch_get_utility_with_stdout` function.

* Add functions `certbot.tests.util.patch_get_utility_with_stdout`
  and `certbot.tests.util._create_get_utility_mock_with_stdout`.

* certbot: tests: Update tests in MainTest.

* Update methods `test_plugins_no_args`,
`test_plugins_no_args_unprivileged`, and `test_plugins_init`,
`test_plugins_prepare` to use `patch_get_utility_with_stdout`.

* certbot: tests: Update _create_get_utility_mock_with_stdout.

* Update certbot.tests.util._create_get_utility_mock_with_stdout
  function. The mock function for all IDisplay methods, except
  `notification` method, calls _write_msg and _assert_valid_call.

* certbot: tests: Update `patch_get_utility_with_stdout`

* Update doc string.
* Argument stdout's default value is None now.

* certbot: tests: Update util._create_get_utility_mock_with_stdout.
2017-09-25 18:42:31 -07:00
Chris Julian
f0caf5b04f #4435. CLI Argument Default Organization (#5037)
* Enhancement #4435. Organizing defaults in prepare_and_parse_args()

* Playing fast and loose with tox.

Discovered screwy case involving flag_default returning empty list (domains)

* Setting defaults for more low-hanging fruit. Some caveats remain.

* key_path default to None

* Applying PR feedback: explicit defaults even where redundant

* Obsessive quote consistency

* Set testing config path arguments to a 'certonly' default

* Copy the default domains list rather than get reference

* Build a testing Config from CLI_DEFAULTS

* Update some email tests for use with defaults in config.

config.email and config.noninteractive_mode in these tests
used to be magic-mock'd, so were True-ish. The default
email is now None and default noninteractive_mode is
False, so update in tests accordingly.

* Lint...

* Copy anything retrieved using flag_defaults. Apply this to test_cli_ini_domains too.

* Put those quotes back. Backslashes are just the worst.

* Remove vestigial line

* A test to ensure no regressions around modifying CLI_DEFAULTS
2017-09-15 17:10:43 -07:00
r5d
7c16e0da26 certbot: Let plugins_cmd be run as un-priviliged user. (#5103)
* certbot: Let plugins_cmd be run as un-priviliged user.

* certbot/main.py (main): Update function.

Addresses issue #4350.

* * Add test certbot.tests.main_testMainTest.test_plugins_no_args_unpriviliged
2017-09-15 16:55:05 -07:00
r5d
7cb8c1264f certbot: Update renew command output in quiet mode. (#5062)
* certbot: Update `renew` command output in quiet mode.

* certbot/renewal.py (_renew_describe_results): Update function.
* certbot/tests/main_test.py (_test_renewal_common): Update method.
  Add optional arg `stdout`; Modify `mock_get_utilitiy`, `stdout`.
  (test_quiet_renew): Update method.
2017-08-31 11:01:15 -07:00
Chris Julian
2bfc92e58d #4071 Mixin to prevent setting return_value after initializing certain Mock objects (#4963)
* Addressing #4071 Wrote an ImmutableReturnMixin to prevent developers overriding return_value in certain Mock objects

* Language

* Loosening the assumption that underlying _mock objects need to be Immutable-like simplifies implementation

* Addressing #4071

* Ensure side_effects and return_values are pushed down to the underlying _mock in FreezableMocks. And IDisplay mocks are no longer frozen in _create_get_utility_mock()

* Edit a handful of tests to not override the mock_get_utility return_value

* Brief explainer of FreezableMock.__setattr__

* Incorporating PR feedback and some compatibility

* FreezableMock __getattr__ needs a shortcut in case of return_value or side_effect

* Changing return_value only forbidden if set before freezing

* Remove unnecessary else block

* Expanded doc strings

* Bring a couple new tests in line with patch_get_utility() norms
2017-08-30 09:52:45 -07:00
r5d
b43bf8f94a Stop using print in certbot.cli module. (#5028)
* Update cerbot.tests.util.patch_get_utility (#3720)

* Add new arg `stdout_notification` to
  `cerbot.tests.util.patch_get_utility` function.

  If `stdout_notification` is True, then the mock
  interfaces.IDisplay.notification function will print out to stdout.

* Add new arg `stdout_notification` to _create_get_utility_mock
  function.

* Add new function `_stdout_notification`.

* Stop using print in certbot.cli (#3720)

* certbot/cli.py (HelpfulArgumentParser._usage_string)
(HelpfulArgumentParser.__init__): Update methods.
* certbot/tests/cli_test.py (test_cli_ini_domains, test_no_args)
(test_install_abspath, test_help, test_help_no_dashes)
(test_parse_domains, test_preferred_challenges, test_server_flag)
(test_must_staple_flag, test_no_gui, test_staging_flag)
(test_dry_run_flag, test_option_was_set)
(test_encode_revocation_reason, test_force_interactive)
(test_deploy_hook_conflict, test_deploy_hook_matches_renew_hook)
(test_deploy_hook_sets_renew_hook, test_renew_hook_conflict)
(test_renew_hook_matches_deploy_hook)
(test_renew_hook_does_not_set_renew_hook, test_max_log_backups_error)
(test_max_log_backups_success, test_webroot_map)
(test_report_config_interaction_str)
(test_report_config_interaction_iterable): Update tests.
* certbot/tests/main_test.py (test_certificates)
(test_certonly_abspath, test_certonly_bad_args)
(test_agree_dev_preview_config): Update tests.

* certbot: Refactor cli_test.ParseTest.

* certbot/tests/cli_test.py (ParseTest._unmocked_parse): Rename parse
to _unmocked_parse.
(parse): New method.
(ParseTest._help_output, ParseTest.test_cli_ini_domains)
(ParseTest.test_no_args, ParseTest.test_install_abspath)
(ParseTest.test_help, ParseTest.test_help_no_dashes)
(ParseTest.test_parse_domains, ParseTest.test_preferred_challenges)
(ParseTest.test_server_flag, ParseTest.test_must_staple_flag)
(ParseTest.test_no_gui, ParseTest.test_staging_flag)
(ParseTest.test_dry_run_flag, ParseTest.test_option_was_set)
(ParseTest.test_encode_revocation_reason)
(ParseTest.test_force_interactive)
(ParseTest.test_deploy_hook_conflict)
(ParseTest.test_deploy_hook_matches_renew_hook)
(ParseTest.test_deploy_hook_sets_renew_hook)
(ParseTest.test_renew_hook_conflict)
(ParseTest.test_renew_hook_matches_deploy_hook)
(ParseTest.test_renew_hook_does_not_set_renew_hook)
(ParseTest.test_max_log_backups_error)
(ParseTest.test_max_log_backups_success): Update methods.

* certbot: Refactor cli_test.SetByCliTest

* certbot/tests/cli_test.py (SetByCliTest.test_webroot_map)
(SetByCliTest.test_report_config_interaction_str)
(SetByCliTest.test_report_config_interaction_iteratable)
(_call_set_by_cli): Update methods.

* certbot: cli: Fix style.

* certbot/cli.py (HelpfulArgumentParser.__init__): Update method.

* certbot: Revert changes to tests.util.patch_get_utility

* certbot/tests/util.py (patch_get_utility): Remove
`stdout_notification` arg.
(_creat_get_utility_mock): Remove `stdout_notification` arg.
(_stdout_notification): Remove function.

* certbot: Revert changes to MainTest.

* certbot/tests/main_test.py
(MainTest.test_certificates, MainTest.test_certonly_abspath)
(MainTest.test_certonly_bad_args): Update methods.

* certbot: cli_test.py: Remove 'pylint: disable' lines.

* certbot/tests/cli_test.py (ParseTest.parse): Update method.
(_call_set_by_cli): Update function.
2017-08-25 10:05:58 -07:00
Winston Smith
8ca36a0b62 Organize + document certbot/tests/testdata directory (#4983)
* wp organize keys documentation start

* oganized testdata directory + readme

* clean up doc

* del acme change
2017-08-23 10:32:27 -07:00
cj-dev
48c890be61 #4434 Test Config Base Class (#4974)
* Addressing #4434 by implementing ConfigTestCase which mocks out a NamespaceConfig for consistent config use across tests

* Refactor account_test.py for use with ConfigTestCase

* Remove superfluous setup/teardown

* Pylint oops.

* Fix redundant inheritance class definitions

* Separate ConfigTestCase's mocked directories

* Module import style consistency

* Refactor log_test.py for use with ConfigTestCase

* Refactor eff_test.py for use with ConfigTestCase. Also tweak for import style consistency

* Refactor reverter_test.py for use with ConfigTestCase

* Refactor renewal_test.py for use with ConfigTestCase

* Refactor main_test.py for use with ConfigTestCase

* Refactor storage_test.py for use with ConfigTestCase

* Refactor cert_manager_test.py for use with ConfigTestCase

* Refactor client_test.py for use with ConfigTestCase

* Refactor configuration_test.py for use with ConfigTestCase

* Pylint!

* Incorporating PR feedback

* Remove comment
2017-08-09 13:19:43 -07:00
yomna
7d0e4d7bad Merge pull request #4915 from Baeumla/master
Check keys if revoke certificate by private key
2017-07-17 15:54:47 -07:00
Chris J
a8b5dfc76c Enhancement #4893. More copypastable output, including private key location on disk 2017-07-16 22:38:21 -04:00
Baime
0f30f9e96f Added test to check revoke cert by key mismatch 2017-07-15 15:17:25 +02:00
Brad Warren
29d80f334f Merge pull request #4907 from certbot/backup-count
Make Certbot's log rotation configurable
2017-07-13 08:56:24 -05:00
Brad Warren
a7a8e060e3 Finish adding configurable log rotation
* Update log backupCount name and description.

* Add additional error handling to --log-backups

* test --log-backups flag

* Pass log_backups value to RotatingFileHandler

* Test that log_backups is properly used

* add _test_success_common

* Add test_success_with_rollover

* Add test_success_without_rollover

* mock stderr in cli tests

* Set log_backups in PostArgParseSetupTest

* Rename "log backups" to "max log backups"
2017-07-11 21:14:18 -05:00
yomna
bc3765d6d0 No longer mask failed challenge errors with encoding errors (#4867)
*     no longer masker failed challenge errors with encoding errors

* simplifying through type-checking

* bytes
2017-07-10 21:05:52 -05:00
Baime
368beee8bf Use correct key/cert for revoke by key test 2017-07-09 12:10:35 +02:00