Commit graph

45 commits

Author SHA1 Message Date
r5d
d2c16fcb62 certbot: Flush output after write in IDisplay methods. (#5164)
- Update `notification`, `yesno`, `checklist`, `_print_menu`, and
  `_get_valid_int_ans` methods in `certbot.display.util.FileDisplay`.
- Update `notification` method in
  `certbot.display.util.NoninteractiveDisplay`.

Addresses issue #4879.
2017-10-04 18:06:57 -07:00
ohemorange
97b22da1b6 Replace the easy v. secure prompt with more clear choices (#4897)
* Replace the easy v. secure prompt with more clear choices
2017-06-30 17:12:09 -07:00
Zach Shepherd
f51d345d5b Low-impact cleanup of IDisplay (#4818)
Remove unused help-related display code. When NcursesDisplay was
removed[1], help was deprecated. This change removes the remaining
bits and pieces of code.

Remove unused escape-related display code. When NcursesDisplay was
removed[1], escape was deprecated. This change removes the remaining
bits and pieces of code.

Remove uses of unused menu parameters.

Remove unused default_status/default_state argument from checklist.
(This seems safe because not only is it unused, the parameter has
different names in the interface and implementation)

1 - d54cb76432

Resolves #4795.
2017-06-15 17:14:38 -07:00
Brad Warren
2ebd8e9763 Add trailing space to prompt. 2017-06-09 10:50:21 -07:00
Brad Warren
1871f0d1b9 Deduplicate code using textwrap.fill. 2017-06-09 10:46:51 -07:00
Andrew Ittner
ed23290232 Clean up Sphinx errors (#4706)
Also minor copyedits, suppress unhelpful errors, mark files that should
*not* be in the TOC as hidden.
2017-05-26 20:57:14 -07:00
Brad Warren
13c88f1c02 Properly handle EOF in input (#4612)
* properly handle eof

* cleanup InputWithTimeoutTest

* add test_eof

* add comment about mimicking getpass
2017-05-03 14:44:15 -07:00
Brad Warren
79d5c890c3 Add a timeout to prompts (#4601)
* Add input_with_timeout

* use input_with_timeout
2017-05-01 14:55:31 -07:00
Zach Shepherd
b41472afce Enhance display.util to support input validation (#4372)
* display: support validation of user input

To avoid each caller of `display.input` and `display.directory_select`
needing to implement validation logic, this allows for a validator to be
supplied as a part of the call.

Following the existing pattern from `webroot`, this validator is expected
to throw a `Error` when it encounters invalid input. The user then
receives a `notification` is re-prompted.

Testing Done:
 * tox -e py27
 * tox -e lint

* plugins: update webroot to use display's validation functionality

This change updates the webroot plugin to use the now-built-in validation
functionality in display, reducing duplicated code.

Testing Done:
 * tox -e py27
 * tox -e lint

* display: move validation logic to ops

To avoid adding complexity to `IDisplay` methods, move validation logic
to helper methods in `display.ops`.

Testing Done:
 * tox -e py27
 * tox -e lint
2017-04-24 17:36:00 -07:00
Yen Chi Hsuan
4b91f7fbbc Replace e.message with str(e) for Python 3 compatibility (#4416) 2017-04-07 09:58:19 -07:00
dokazaki
8011fb2879 Add mypy (#4386)
* Initial configuration of mypy in box, correction of base mypy errors.

* Move mypy install to toe

* Add pylint comments for typing imports.

* Remove typing module for Python 2.6 compatibility.
2017-03-18 19:10:10 -07:00
Peter Eckersley
aa389cf8aa Revert "uncomment assertion (#4072)" (#4110)
Revert "uncomment assertion (#4072)"
2017-02-01 09:32:24 -08:00
Brad Warren
578815a20a uncomment assertion (#4072) 2017-01-24 14:39:27 -08:00
Brad Warren
9c9004aff1 Stop IDisplay AssertionErrors (#4010)
Fixes #3996.

I'm pretty confident this PR solves the problem. I've audited all calls to IDisplay methods and the assertions done in certbot.display.util are now done in all our unit tests.

With that said, it wouldn't hurt to have someone else double check I didn't miss anything. The easiest way to do this is to grep for IDisplay in our code and ensure all calls to IDisplay methods are valid. This means every method call other than notification (because a notification call is always OK) either provides a value for default or force_interactive. This is defined in interfaces.py.

I've also been considering removing the assertion that's been causing us trouble here from our release. The only argument I have for not doing so is it may hinder 3rd party plugin development. When they use IDisplay, they have the same problem as we do with prompting users without a TTY. Not keeping this assertion in makes it more likely they won't notice the issue and Certbot will crash on an unsuspecting user.

With that said, none of our known 3rd party plugins use IDisplay at all.

* Provide force_interactive in _get_certname

* Use force_interactive when asking for webroot

* Factor IDisplay assertion into it's own function

* Add util.patch_get_utility()

* Allow custom path to patch_get_utiity

* Change GetEmailTest to use patch_get_utility

* Use new_callable to create new objects

* Modify tests to use patch_get_utility

* Improve FreezableMock documentation

* Add user facing error to TTY magic

* Comment out assert_valid_call

* Add test_input_assertion_fail2()
2017-01-10 16:25:33 -08:00
Brad Warren
12edbb53db Fixes #3954 and adds a test to prevent regressions (#3957)
* fixes #3954 and adds test to prevent regressions

* assure pylint I know what I'm doing

* Test FileDisplay methods take force_interactive
2016-12-23 10:49:51 -08:00
Brad Warren
f92254769b I promise checklists are OK (fixes #3934) (#3940)
* TIL checklist calls input

* full coverage on certbot/display/util.py

* improve no double warning test
2016-12-20 14:34:12 -08:00
Brad Warren
ae379568b1 Mitigate problems for people who run without -n (#3916)
* CLI flag for forcing interactivity

* add --force-interactive

* Add force_interactive error checking and tests

* Add force_interactive parameter to FileDisplay

* add _can_interact

* Add _return_default

* Add **unused_kwargs to NoninteractiveDisplay

* improve _return_default assertion

* Change IDisplay calls and write tests

* Document force_interactive in interfaces.py

* Don't force_interactive with a new prompt

* Warn when skipping an interaction for the first time

* add specific logger.debug message
2016-12-19 12:45:40 -08:00
Frank
e6f24db624 Sort the names by domain (then subdomain) before showing them (#3892)
* Sort the names by domain (then subdomain) before showing them

* Sort the names in display + tests
2016-12-11 02:18:32 -08:00
Craig Smith
df5f08843f Output success message for revoke command (#3823)
* Output status for `revoke` operation. Fixes #2819.

    - Added method to `certbot.display.ops` to output confirmation of `revoke`.

    - Wrapped call to `acme.client.Client.revoke` in a try to statement to
      handle possible error.

    - Added test for `main.revoke`.

* Added test for failure of certificate revocation.

Moved creation of mocks into RevokeTest setup function.

Stopped mocks in RevokeTest teardown function.

* Fixed lint errors.

* Do not call `unittest.TestCase.assertRaises` as a context manager (to work with py26).

* Fixed spelling error in successful revocation notification.

Added test for the notification.
2016-11-29 15:30:37 -08:00
Brad Warren
e5f4d0cb5c Fix reinstall message (#3784)
* Changed informational messages because of confusing message on reinstallation.

Certbot prompts the user when it detects that an appropriately fresh certificate
is already available:

        You have an existing certificate that contains exactly the same domains you requested and isn't close to expiry.
        (ref: <path>)

        What would you like to do?
        -------------------------------------------------------------------------------
        1: Attempt to reinstall this existing certificate
        2: Renew & replace the cert (limit ~5 per 7 days)
        -------------------------------------------------------------------------------
        Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1

On selecting '1' (reinstall), the resulting message is:

        -------------------------------------------------------------------------------
        Your existing certificate has been successfully reinstalled, and the new
        certificate has been installed.

        The new certificate covers the following domains: https://<whatever>

        You should test your configuration at:
        https://www.ssllabs.com/ssltest/analyze.html?d=<whatever>
        -------------------------------------------------------------------------------

"Your existing certificate has been successfully reinstalled" <-- Okay

"and the new certificate has been installed." <-- Wait, what?

The issue appears to come from assumptions in certbot/certbot/main.py

It uses `len(lineage.available_versions("cert"))` to determine if this was a
fresh install or renewal, and then calls either `display_ops.success_renewal()`
(which produces the "existing certificate ... and the new certificate" language)
or `display_ops.success_installation()` (which has no messaging about existing
vs. new certificates).

The len(lineage) test isn't the right way to make this choice. The certificate's
lineage length doesn't imply anything about whether we've just obtained a new
certificate, because there is no new certificate in the case of a "reinstall"
action.

The new logic calls `display_ops.success_installation()` on all "reinstall"
actions, and otherwise employs the existing `len(lineage)` test.

Additionally the `display_ops.success_installation()` has been enhanced to
accept an action parameter, and has the message reworded slightly to make
sense regardless of the action passed. The messaging is mostly unchanged if it's
called without the action parameter:

Original message:
        -------------------------------------------------------------------------------
        Congratulations! You have successfully enabled https://<whatever>

        You should test your configuration at:
        https://www.ssllabs.com/ssltest/analyze.html?d=<whatever>
        -------------------------------------------------------------------------------

New message on initial install:
        -------------------------------------------------------------------------------
        Congratulations! You have successfully installed a certificate for
        https://<whatever>

        You should test your configuration at:
        https://www.ssllabs.com/ssltest/analyze.html?d=<whatever>
        -------------------------------------------------------------------------------

New message on re-install:
        -------------------------------------------------------------------------------
        Congratulations! You have successfully reinstalled a certificate for
        https://<whatever>

        You should test your configuration at:
        https://www.ssllabs.com/ssltest/analyze.html?d=<whatever>
        -------------------------------------------------------------------------------

* Typo in display message.

* Typo, characters transposed.

* undo changes to certbot/display/ops.py

* remove invalid todos

* Test success_installation() called for reinstall

* Simplify display_ops.success* functions

* refactor and expand run() tests
2016-11-15 11:56:05 -08:00
Erica Portnoy
2b229d4b9d Allow notification interface to not wrap text (#3728) 2016-11-07 16:14:09 -08:00
Erica Portnoy
4b5db7aec4 Allow user to select all domains by typing empty string at checklist (#3693)
* Allow user to select all domains by typing empty string at checklist
2016-10-26 15:43:40 -07:00
Jay Faulkner
98911d0c3c Fix issue with suggest_unsafe undeclared (#3685)
Added missing declaration of support_unsafe and unit test to prevent
regression.

Issue #3672
2016-10-24 14:51:50 -07:00
Erica Portnoy
d54cb76432 Remove the curses dialog, thereby deprecating the --help and --dialog command line options (#3665)
* Remove the curses dialog, thereby deprecating the --help and --dialog command line options

* Deprecate --dialog and suppress --text
2016-10-21 15:45:57 -07:00
Peter Eckersley
3615b9030c Improve description of what email is used for.
Specifically, it's not currently used for account recovery.
2016-10-12 16:37:55 -07:00
Brad Warren
769ebfce5e Remove pointless question (#3526)
* remove unhelpful question about servernames and default vhosts

* add prefix about names found in config files

* test we include configuration files prefix

* Tell the user what kind of conf files were missing domains

* Revert "Tell the user what kind of conf files were missing domains"

This reverts commit 1066a88dae.
2016-09-28 15:52:08 -07:00
Noah Swartz
7767975204 move error outside of get_email 2016-08-16 16:13:31 -07:00
Noah Swartz
4a28bb1af7 clarify invalid email error in non-interactive 2016-08-16 12:37:45 -07:00
Noah Swartz
ed6b6e2286 Merge pull request #3268 from jsachs/dialog-autosize
Set dialog widgets to use autowidgetsize
2016-08-15 15:03:12 -07:00
Yen Chi Hsuan
fe76d558ed Enable unit tests of certbot core on Python 3 2016-08-06 21:09:43 +08:00
Jacob Sachs
64012a6053 set dialog widgets to use autowidgetsize 2016-07-09 09:18:16 -03:00
Peter Eckersley
4b84538c8c Address review comments 2016-07-06 12:57:16 -07:00
Peter Eckersley
23f0ccbc8e Address review issues 2016-06-25 12:28:47 -07:00
Peter Eckersley
8a28cb7352 Implement Brad's more systematic solution for this 2016-06-22 15:50:21 -07:00
Peter Eckersley
e231dae2c1 Merge remote-tracking branch 'origin/master' into dialog-escape 2016-06-22 15:35:07 -07:00
Seth Schoen
10612a0ced Merge remote-tracking branch 'origin/update_registration' into update_registration 2016-05-31 15:54:00 -07:00
Seth Schoen
c1e4b57d37 Tiny documentation fixes 2016-05-31 15:53:40 -07:00
Brad Warren
673b5e960a Merge branch 'master' into update_registration 2016-05-31 14:35:30 -07:00
Peter Eckersley
61e0e3cc83 Merge pull request #3073 from cowlicks/rename-le-util
Rename certbot.le_util to certbot.util
2016-05-27 14:37:36 -07:00
Brad Warren
653935b937 Merge branch 'master' into update_registration 2016-05-25 21:54:51 -07:00
Brad Warren
6598bcb53e refactor get_email 2016-05-25 21:53:20 -07:00
Blake Griffith
d9d2377242 Rename certbot.le_util to certbot.util
Also rename certbot/tests/le_util_test.py to certbot/tests/util_test.py
2016-05-25 18:50:02 -05:00
Amjad Mashaal
0999705691 Fixing wrapping for messages with URLs 2016-05-25 22:58:16 +02:00
Brad Warren
1b565ef74a s/Let's Encrypt/Certbot 2016-04-13 16:13:50 -07:00
Brad Warren
3961b70deb s/letsencrypt/certbot 2016-04-13 16:03:59 -07:00