Repository: certbot/certbot

Issue:
Fix Nginx prompt
Saw the following prompt when using Nginx

```
-------------------------------------------------------------------------------
No names were found in your configuration files.
You should specify ServerNames in your config files in order to allow for
accurate installation of your certificate.
If you do use the default vhost, you may specify the name manually. Would you
like to continue?
-------------------------------------------------------------------------------
(Y)es/(N)o: 
```

`ServerName` is Apache specific and based on #3508, we don't want to allow people to use the default vhost.



Discussion:
Was this copied from Apache, or was there some previous active decision to allow modifying the default vhost and specifying the name manually?

It's part of the core client (see [this](https://github.com/certbot/certbot/blob/master/certbot/display/ops.py#L107)). If the [get_all_names](https://github.com/certbot/certbot/blob/master/certbot/interfaces.py#L254) method of a plugin returns an empty list, it gives you that question.

The Apache plugin will currently make a copy of the default vhost and add names for you. Based on that behavior and prompts like this, it seems like that decision was probably deliberate.

I can't remember why that decision was made though (it might predate my involvement). I do remember there was some embarrassment that the plugin didn't work with the default configuration (which comes with no server names specified). Perhaps this feature was simply added so you could use our plugin out of the box?


Resolving patch:
diff --git a/certbot/display/ops.py b/certbot/display/ops.py
--- a/certbot/display/ops.py
+++ b/certbot/display/ops.py
@@ -103,18 +103,8 @@ def choose_names(installer):
     names = get_valid_domains(domains)
 
     if not names:
-        manual = z_util(interfaces.IDisplay).yesno(
-            "No names were found in your configuration files.{0}You should "
-            "specify ServerNames in your config files in order to allow for "
-            "accurate installation of your certificate.{0}"
-            "If you do use the default vhost, you may specify the name "
-            "manually. Would you like to continue?{0}".format(os.linesep),
-            default=True)
-
-        if manual:
-            return _choose_names_manually()
-        else:
-            return []
+        return _choose_names_manually(
+            "No names were found in your configuration files. ")
 
     code, names = _filter_names(names)
     if code == display_util.OK and names:
@@ -157,10 +147,17 @@ def _filter_names(names):
     return code, [str(s) for s in names]
 
 
-def _choose_names_manually():
-    """Manually input names for those without an installer."""
+def _choose_names_manually(prompt_prefix=""):
+    """Manually input names for those without an installer.
+
+    :param str prompt_prefix: string to prepend to prompt for domains
 
+    :returns: list of provided names
+    :rtype: `list` of `str`
+
+    """
     code, input_ = z_util(interfaces.IDisplay).input(
+        prompt_prefix +
         "Please enter in your domain name(s) (comma and/or space separated) ",
         cli_flag="--domains")
 


Test patch:
diff --git a/certbot/tests/display/ops_test.py b/certbot/tests/display/ops_test.py
--- a/certbot/tests/display/ops_test.py
+++ b/certbot/tests/display/ops_test.py
@@ -206,20 +206,14 @@ def test_no_installer_cancel(self, mock_util):
     @mock.patch("certbot.display.ops.z_util")
     def test_no_names_choose(self, mock_util):
         self.mock_install().get_all_names.return_value = set()
-        mock_util().yesno.return_value = True
         domain = "example.com"
         mock_util().input.return_value = (display_util.OK, domain)
 
         actual_doms = self._call(self.mock_install)
         self.assertEqual(mock_util().input.call_count, 1)
         self.assertEqual(actual_doms, [domain])
-
-    @mock.patch("certbot.display.ops.z_util")
-    def test_no_names_quit(self, mock_util):
-        self.mock_install().get_all_names.return_value = set()
-        mock_util().yesno.return_value = False
-
-        self.assertEqual(self._call(self.mock_install), [])
+        self.assertTrue(
+            "configuration files" in mock_util().input.call_args[0][0])
 
     @mock.patch("certbot.display.ops.z_util")
     def test_filter_names_valid_return(self, mock_util):