Move staging URI into constants.py

This commit is contained in:
Peter Eckersley 2015-12-10 19:37:22 -08:00
parent 3b5810995d
commit 88956dfba8
3 changed files with 7 additions and 7 deletions

View file

@ -699,11 +699,10 @@ class HelpfulArgumentParser(object):
# Do any post-parsing homework here
# argparse seemingly isn't flexible enough to give us this behaviour easily...
staging_uri = 'https://acme-staging.api.letsencrypt.org/directory'
if parsed_args.staging:
if parsed_args.server not in (flag_default("server"), staging_uri):
if parsed_args.server not in (flag_default("server"), constants.STAGING_URI):
raise errors.Error("--server value conflicts with --staging")
parsed_args.server = staging_uri
parsed_args.server = constants.STAGING_URI
return parsed_args
@ -1049,7 +1048,7 @@ def _paths_parser(helpful):
# overwrites server, handled in HelpfulArgumentParser.parse_args()
add("testing", "--test-cert", "--staging", action='store_true', dest='staging',
help='Use the staging server to obtain test (invalid) certs; equivalent'
' to --server https://acme-staging.api.letsencrypt.org/directory ')
' to --server ' + constants.STAGING_URI)
def _plugins_parsing(helpful, plugins):

View file

@ -30,8 +30,9 @@ CLI_DEFAULTS = dict(
auth_chain_path="./chain.pem",
strict_permissions=False,
)
"""Defaults for CLI flags and `.IConfig` attributes."""
STAGING_URI = "https://acme-staging.api.letsencrypt.org/directory"
"""Defaults for CLI flags and `.IConfig` attributes."""
RENEWER_DEFAULTS = dict(
renewer_enabled="yes",

View file

@ -15,6 +15,7 @@ from acme import jose
from letsencrypt import account
from letsencrypt import cli
from letsencrypt import configuration
from letsencrypt import constants
from letsencrypt import crypto_util
from letsencrypt import errors
from letsencrypt import le_util
@ -351,8 +352,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
short_args = ['--staging']
namespace = cli.prepare_and_parse_args(plugins, short_args)
self.assertEqual(namespace.server,
'https://acme-staging.api.letsencrypt.org/directory')
self.assertEqual(namespace.server, constants.STAGING_URI)
short_args = ['--staging', '--server', 'example.com']
self.assertRaises(errors.Error, cli.prepare_and_parse_args, plugins, short_args)