mirror of
https://github.com/Gandi/gandi.cli.git
synced 2026-01-16 23:00:21 +00:00
PEP8 fixes
This commit is contained in:
parent
be0df58b9f
commit
d7367f963f
16 changed files with 125 additions and 126 deletions
|
|
@ -10,8 +10,6 @@ try:
|
|||
except NameError:
|
||||
basestring = (str, bytes)
|
||||
|
||||
type_list = list
|
||||
|
||||
from gandi.cli.core.cli import cli
|
||||
from gandi.cli.core.utils import output_cert, output_cert_oper, display_rows
|
||||
from gandi.cli.core.params import (pass_gandi, IntChoice,
|
||||
|
|
@ -20,6 +18,8 @@ from gandi.cli.core.params import (pass_gandi, IntChoice,
|
|||
CERTIFICATE_PACKAGE_MAX,
|
||||
CERTIFICATE_PACKAGE_WARRANTY)
|
||||
|
||||
type_list = list
|
||||
|
||||
|
||||
@cli.group(name='certificate')
|
||||
@pass_gandi
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ try:
|
|||
except NameError:
|
||||
basestring = (str, bytes)
|
||||
|
||||
type_list = list
|
||||
|
||||
from gandi.cli.core.cli import cli
|
||||
from gandi.cli.core.utils import output_hostedcert
|
||||
from gandi.cli.core.params import pass_gandi
|
||||
|
||||
type_list = list
|
||||
|
||||
|
||||
@cli.group(name='certstore')
|
||||
@pass_gandi
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ def info(gandi, resource, format):
|
|||
iface = gandi.iface.info(ip['iface_id'])
|
||||
server['name'] = gandi.iaas.info(iface['vm_id'])['hostname']
|
||||
output_servers = ['name', 'ip', 'port', 'state']
|
||||
except:
|
||||
except Exception:
|
||||
warningmsg = ('\tBackend with ip address %s no longer exists.'
|
||||
'\n\tYou should remove it.' % server['ip'])
|
||||
gandi.echo(warningmsg)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from gandi.cli import __version__
|
|||
|
||||
try:
|
||||
use_man_epilog = platform.system() == 'Linux'
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class JsonClient(object):
|
|||
if isinstance(err, requests.HTTPError):
|
||||
try:
|
||||
resp = response.json()
|
||||
except:
|
||||
except Exception:
|
||||
msg = 'An unknown error has occurred: %s' % err
|
||||
raise APICallFailed(msg)
|
||||
|
||||
|
|
|
|||
|
|
@ -468,7 +468,7 @@ def output_json(gandi, format, value):
|
|||
gandi.echo(json.dumps(value, default=date_handler, sort_keys=True))
|
||||
elif format == 'pretty-json':
|
||||
gandi.echo(json.dumps(value, default=date_handler, sort_keys=True,
|
||||
indent=2, separators=(',', ': ')))
|
||||
indent=2, separators=(',', ': ')))
|
||||
|
||||
|
||||
def output_sub_line(gandi, key, val, justify):
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class Certificate(GandiModule):
|
|||
if len(set(hosts) - cert_hosts) == 0:
|
||||
if (possible and possible['date_end'] < cert['date_end']
|
||||
or not possible):
|
||||
possible = cert
|
||||
possible = cert
|
||||
|
||||
return possible
|
||||
|
||||
|
|
|
|||
|
|
@ -483,7 +483,7 @@ class Iaas(GandiModule, SshkeyHelper):
|
|||
ip_addr = '[%s]' % ip_addr
|
||||
|
||||
cmd.extend((local_file, '%s@%s:%s' %
|
||||
(login, ip_addr, remote_file),))
|
||||
(login, ip_addr, remote_file),))
|
||||
cls.echo('Running %s' % ' '.join(cmd))
|
||||
for _ in range(5):
|
||||
ret = cls.execute(cmd, False)
|
||||
|
|
@ -569,7 +569,7 @@ class Image(GandiModule):
|
|||
"""Retrieve disk image id associated to a label."""
|
||||
result = cls.list(datacenter=datacenter)
|
||||
image_labels = dict([(image['label'], image['disk_id'])
|
||||
for image in result])
|
||||
for image in result])
|
||||
|
||||
return image_labels.get(label)
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test3.domain.f
|
|||
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test4.domain.fr
|
||||
----------
|
||||
subject : /OU=Domain Control Validated/OU=Gandi Standard Wildcard SSL/CN=*.domain.fr
|
||||
""")
|
||||
""") # noqa
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
def test_list_all(self):
|
||||
|
|
@ -37,80 +37,81 @@ id : 1
|
|||
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test1.domain.fr
|
||||
date_created: 20150407T00:00:00
|
||||
date_expire : 20160316T00:00:00
|
||||
----------
|
||||
fqdn : test1.domain.fr
|
||||
----------
|
||||
vhost : test1.domain.fr
|
||||
type : paas
|
||||
\t----------
|
||||
\tfqdn : test1.domain.fr
|
||||
\t----------
|
||||
\tvhost : test1.domain.fr
|
||||
\ttype : paas
|
||||
----------
|
||||
id : 2
|
||||
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test1.domain.fr
|
||||
date_created: 20150407T00:00:00
|
||||
date_expire : 20160316T00:00:00
|
||||
----------
|
||||
fqdn : test1.domain.fr
|
||||
----------
|
||||
vhost : test1.domain.fr
|
||||
type : paas
|
||||
\t----------
|
||||
\tfqdn : test1.domain.fr
|
||||
\t----------
|
||||
\tvhost : test1.domain.fr
|
||||
\ttype : paas
|
||||
----------
|
||||
id : 3
|
||||
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test2.domain.fr
|
||||
date_created: 20150408T00:00:00
|
||||
date_expire : 20160408T00:00:00
|
||||
----------
|
||||
fqdn : test2.domain.fr
|
||||
\t----------
|
||||
\tfqdn : test2.domain.fr
|
||||
----------
|
||||
id : 4
|
||||
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test3.domain.fr
|
||||
date_created: 20150408T00:00:00
|
||||
date_expire : 20160408T00:00:00
|
||||
----------
|
||||
fqdn : test3.domain.fr
|
||||
\t----------
|
||||
\tfqdn : test3.domain.fr
|
||||
----------
|
||||
id : 5
|
||||
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test4.domain.fr
|
||||
date_created: 20150408T00:00:00
|
||||
date_expire : 20160408T00:00:00
|
||||
----------
|
||||
fqdn : test4.domain.fr
|
||||
\t----------
|
||||
\tfqdn : test4.domain.fr
|
||||
----------
|
||||
id : 6
|
||||
subject : /OU=Domain Control Validated/OU=Gandi Standard Wildcard SSL/CN=*.domain.fr
|
||||
date_created: 20150409T00:00:00
|
||||
date_expire : 20160409T00:00:00
|
||||
----------
|
||||
fqdn : *.domain.fr
|
||||
----------
|
||||
vhost : *.domain.fr
|
||||
type : paas
|
||||
""")
|
||||
\t----------
|
||||
\tfqdn : *.domain.fr
|
||||
\t----------
|
||||
\tvhost : *.domain.fr
|
||||
\ttype : paas
|
||||
""") # noqa
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
def test_info_fqdn(self):
|
||||
|
||||
result = self.invoke_with_exceptions(certstore.info, ['test1.domain.fr'])
|
||||
result = self.invoke_with_exceptions(
|
||||
certstore.info, ['test1.domain.fr'])
|
||||
|
||||
self.assertEqual(result.output, """\
|
||||
id : 1
|
||||
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test1.domain.fr
|
||||
date_created: 20150407T00:00:00
|
||||
date_expire : 20160316T00:00:00
|
||||
----------
|
||||
fqdn : test1.domain.fr
|
||||
----------
|
||||
vhost : test1.domain.fr
|
||||
type : paas
|
||||
\t----------
|
||||
\tfqdn : test1.domain.fr
|
||||
\t----------
|
||||
\tvhost : test1.domain.fr
|
||||
\ttype : paas
|
||||
----------
|
||||
id : 2
|
||||
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test1.domain.fr
|
||||
date_created: 20150407T00:00:00
|
||||
date_expire : 20160316T00:00:00
|
||||
----------
|
||||
fqdn : test1.domain.fr
|
||||
----------
|
||||
vhost : test1.domain.fr
|
||||
type : paas
|
||||
""")
|
||||
\t----------
|
||||
\tfqdn : test1.domain.fr
|
||||
\t----------
|
||||
\tvhost : test1.domain.fr
|
||||
\ttype : paas
|
||||
""") # noqa
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
def test_info_id(self):
|
||||
|
|
@ -121,12 +122,12 @@ id : 1
|
|||
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test1.domain.fr
|
||||
date_created: 20150407T00:00:00
|
||||
date_expire : 20160316T00:00:00
|
||||
----------
|
||||
fqdn : test1.domain.fr
|
||||
----------
|
||||
vhost : test1.domain.fr
|
||||
type : paas
|
||||
""")
|
||||
\t----------
|
||||
\tfqdn : test1.domain.fr
|
||||
\t----------
|
||||
\tvhost : test1.domain.fr
|
||||
\ttype : paas
|
||||
""") # noqa
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
def test_create(self):
|
||||
|
|
@ -138,9 +139,9 @@ id : 5
|
|||
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test4.domain.fr
|
||||
date_created: 20150408T00:00:00
|
||||
date_expire : 20160408T00:00:00
|
||||
----------
|
||||
fqdn : test4.domain.fr
|
||||
""")
|
||||
\t----------
|
||||
\tfqdn : test4.domain.fr
|
||||
""") # noqa
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
def test_create_id(self):
|
||||
|
|
@ -152,9 +153,9 @@ id : 5
|
|||
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test4.domain.fr
|
||||
date_created: 20150408T00:00:00
|
||||
date_expire : 20160408T00:00:00
|
||||
----------
|
||||
fqdn : test4.domain.fr
|
||||
""")
|
||||
\t----------
|
||||
\tfqdn : test4.domain.fr
|
||||
""") # noqa
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
def test_create_missing(self):
|
||||
|
|
@ -176,9 +177,9 @@ id : 5
|
|||
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test4.domain.fr
|
||||
date_created: 20150408T00:00:00
|
||||
date_expire : 20160408T00:00:00
|
||||
----------
|
||||
fqdn : test4.domain.fr
|
||||
""")
|
||||
\t----------
|
||||
\tfqdn : test4.domain.fr
|
||||
""") # noqa
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
def test_create_parameter_files(self):
|
||||
|
|
@ -198,9 +199,9 @@ id : 5
|
|||
subject : /OU=Domain Control Validated/OU=Gandi Standard SSL/CN=test4.domain.fr
|
||||
date_created: 20150408T00:00:00
|
||||
date_expire : 20160408T00:00:00
|
||||
----------
|
||||
fqdn : test4.domain.fr
|
||||
""")
|
||||
\t----------
|
||||
\tfqdn : test4.domain.fr
|
||||
""") # noqa
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
def test_delete(self):
|
||||
|
|
|
|||
|
|
@ -155,4 +155,4 @@ Will save your apikey into the config file.""")
|
|||
self.assertTrue('api' in GandiModule._conffiles['global'])
|
||||
|
||||
api_key = GandiModule._conffiles['global']['api'].get('key')
|
||||
self.assertEqual(api_key,'apikey0002')
|
||||
self.assertEqual(api_key, 'apikey0002')
|
||||
|
|
|
|||
|
|
@ -11,63 +11,63 @@ RESPONSES = {
|
|||
'https://dns.api.gandi.net/api/v5/domains': {
|
||||
'status': 200,
|
||||
'headers': 'application/json',
|
||||
'body': [{'domain_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com', # noqa
|
||||
'domain_records_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records', # noqa
|
||||
'body': [{'domain_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com', # noqa
|
||||
'domain_records_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records', # noqa
|
||||
'fqdn': 'iheartcli.com'},
|
||||
{'domain_href': 'https://dns.api.gandi.net/api/v5/domains/cli.sexy', # noqa
|
||||
'domain_records_href': 'https://dns.api.gandi.net/api/v5/domains/cli.sexy/records', # noqa
|
||||
{'domain_href': 'https://dns.api.gandi.net/api/v5/domains/cli.sexy', # noqa
|
||||
'domain_records_href': 'https://dns.api.gandi.net/api/v5/domains/cli.sexy/records', # noqa
|
||||
'fqdn': 'cli.sexy'}],
|
||||
},
|
||||
'https://dns.api.gandi.net/api/v5/domains/iheartcli.com': {
|
||||
'status': 200,
|
||||
'headers': 'application/json',
|
||||
'body': {'domain_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com', # noqa
|
||||
'domain_keys_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys', # noqa
|
||||
'domain_records_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records', # noqa
|
||||
'body': {'domain_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com', # noqa
|
||||
'domain_keys_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys', # noqa
|
||||
'domain_records_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records', # noqa
|
||||
'fqdn': 'iheartcli.com',
|
||||
'zone_href': 'https://dns.api.gandi.net/api/v5/zones/397c514-e7cb-11e6-9429-00163e6dc886', # noqa
|
||||
'zone_records_href': 'https://dns.api.gandi.net/api/v5/zones/397c514-e7cb-11e6-9429-00163e6dc886/records', # noqa
|
||||
'zone_href': 'https://dns.api.gandi.net/api/v5/zones/397c514-e7cb-11e6-9429-00163e6dc886', # noqa
|
||||
'zone_records_href': 'https://dns.api.gandi.net/api/v5/zones/397c514-e7cb-11e6-9429-00163e6dc886/records', # noqa
|
||||
'zone_uuid': '397c514-e7cb-11e6-9429-00163e6dc886'}
|
||||
},
|
||||
'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records?sort_by=rrset_name': { # noqa
|
||||
'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records?sort_by=rrset_name': { # noqa
|
||||
'status': 200,
|
||||
'headers': 'application/json',
|
||||
'body': [{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/%40/A', # noqa
|
||||
'body': [{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/%40/A', # noqa
|
||||
'rrset_name': '@',
|
||||
'rrset_ttl': 10800,
|
||||
'rrset_type': 'A',
|
||||
'rrset_values': ['217.70.184.38']},
|
||||
{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/%40/MX', # noqa
|
||||
{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/%40/MX', # noqa
|
||||
'rrset_name': '@',
|
||||
'rrset_ttl': 10800,
|
||||
'rrset_type': 'MX',
|
||||
'rrset_values': ['50 fb.mail.gandi.net.', '10 spool.mail.gandi.net.']}, # noqa
|
||||
{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/blog/CNAME', # noqa
|
||||
'rrset_values': ['50 fb.mail.gandi.net.', '10 spool.mail.gandi.net.']}, # noqa
|
||||
{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/blog/CNAME', # noqa
|
||||
'rrset_name': 'blog',
|
||||
'rrset_ttl': 10800,
|
||||
'rrset_type': 'CNAME',
|
||||
'rrset_values': ['blogs.vip.gandi.net.']},
|
||||
{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/imap/CNAME', # noqa
|
||||
{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/imap/CNAME', # noqa
|
||||
'rrset_name': 'imap',
|
||||
'rrset_ttl': 10800,
|
||||
'rrset_type': 'CNAME',
|
||||
'rrset_values': ['access.mail.gandi.net.']},
|
||||
{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/pop/CNAME', # noqa
|
||||
{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/pop/CNAME', # noqa
|
||||
'rrset_name': 'pop',
|
||||
'rrset_ttl': 10800,
|
||||
'rrset_type': 'CNAME',
|
||||
'rrset_values': ['access.mail.gandi.net.']},
|
||||
{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/smtp/CNAME', # noqa
|
||||
{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/smtp/CNAME', # noqa
|
||||
'rrset_name': 'smtp',
|
||||
'rrset_ttl': 10800,
|
||||
'rrset_type': 'CNAME',
|
||||
'rrset_values': ['relay.mail.gandi.net.']},
|
||||
{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/webmail/CNAME', # noqa
|
||||
{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/webmail/CNAME', # noqa
|
||||
'rrset_name': 'webmail',
|
||||
'rrset_ttl': 10800,
|
||||
'rrset_type': 'CNAME',
|
||||
'rrset_values': ['webmail.gandi.net.']},
|
||||
{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/www/CNAME', # noqa
|
||||
{'rrset_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/www/CNAME', # noqa
|
||||
'rrset_name': 'www',
|
||||
'rrset_ttl': 10800,
|
||||
'rrset_type': 'CNAME',
|
||||
|
|
@ -85,7 +85,7 @@ RESPONSES = {
|
|||
'headers': 'application/json',
|
||||
'body': {'message': 'DNS Record Created'},
|
||||
},
|
||||
'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/blog/CNAME': { # noqa
|
||||
'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/blog/CNAME': { # noqa
|
||||
'status': 204,
|
||||
'headers': 'application/json',
|
||||
'body': {},
|
||||
|
|
@ -93,43 +93,43 @@ RESPONSES = {
|
|||
'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys': {
|
||||
'status': 200,
|
||||
'headers': {'content-type': 'application/json',
|
||||
'location': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys/3415833-2314-4a86-ba1c-c3c58608a168'}, # noqa
|
||||
'location': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys/3415833-2314-4a86-ba1c-c3c58608a168'}, # noqa
|
||||
'body': [{'algorithm': 13,
|
||||
'algorithm_name': 'ECDSAP256SHA256',
|
||||
'deleted': False,
|
||||
'ds': 'iheartcli.com. 3600 IN DS 5411 13 2 6153c39cfe4ff8673635490515e19f5336f5b7ee9c5ca4572fc44b24a0e794a', # noqa
|
||||
'ds': 'iheartcli.com. 3600 IN DS 5411 13 2 6153c39cfe4ff8673635490515e19f5336f5b7ee9c5ca4572fc44b24a0e794a', # noqa
|
||||
'flags': 256,
|
||||
'fqdn': 'iheartcli.com',
|
||||
'key_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys/3415833-2314-4a86-ba1c-c3c58608a168', # noqa
|
||||
'key_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys/3415833-2314-4a86-ba1c-c3c58608a168', # noqa
|
||||
'status': 'active',
|
||||
'uuid': '3415833-2314-4a86-ba1c-c3c58608a168'},
|
||||
{'algorithm': 13,
|
||||
'algorithm_name': 'ECDSAP256SHA256',
|
||||
'deleted': False,
|
||||
'ds': 'iheartcli.com. 3600 IN DS 43819 13 2 b4e6ed591f28f4a269b9adfaedec836ea0fe63a8f7f5097108297afa5492b70', # noqa
|
||||
'ds': 'iheartcli.com. 3600 IN DS 43819 13 2 b4e6ed591f28f4a269b9adfaedec836ea0fe63a8f7f5097108297afa5492b70', # noqa
|
||||
'flags': 256,
|
||||
'fqdn': 'iheartcli.com',
|
||||
'key_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys/adaab60-bb17-40ed-a13e-88376fe28c86', # noqa
|
||||
'key_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys/adaab60-bb17-40ed-a13e-88376fe28c86', # noqa
|
||||
'status': 'active',
|
||||
'uuid': 'adaab60-bb17-40ed-a13e-88376fe28c86'}],
|
||||
},
|
||||
'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys/3415833-2314-4a86-ba1c-c3c58608a168': { # noqa
|
||||
'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys/3415833-2314-4a86-ba1c-c3c58608a168': { # noqa
|
||||
'status': 200,
|
||||
'headers': 'application/json',
|
||||
'body': {'algorithm': 13,
|
||||
'algorithm_name': 'ECDSAP256SHA256',
|
||||
'deleted': False,
|
||||
'ds': 'iheartcli.com. 3600 IN DS 5411 13 2 6153c39cfe4ff8673635490515e19f5336f5b7ee9c5ca4572fc44b24a0e794a', # noqa
|
||||
'ds': 'iheartcli.com. 3600 IN DS 5411 13 2 6153c39cfe4ff8673635490515e19f5336f5b7ee9c5ca4572fc44b24a0e794a', # noqa
|
||||
'flags': 256,
|
||||
'fqdn': 'iheartcli.com',
|
||||
'public_key': 'Gnhra3gcNHUL0d05Ia6F/tgBzDD/Km6c2XFZA9RAOcjk/qg9aodc79MQtsTx4/CBlTmCSRIxlXWm1yMmV3LOlw==', # noqa
|
||||
'fingerprint': '626168cae12c674f38958b324e10c7bb63ed74cc9d649bf04766a7c095c865787', # noqa
|
||||
'key_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys/3415833-2314-4a86-ba1c-c3c58608a168', # noqa
|
||||
'public_key': 'Gnhra3gcNHUL0d05Ia6F/tgBzDD/Km6c2XFZA9RAOcjk/qg9aodc79MQtsTx4/CBlTmCSRIxlXWm1yMmV3LOlw==', # noqa
|
||||
'fingerprint': '626168cae12c674f38958b324e10c7bb63ed74cc9d649bf04766a7c095c865787', # noqa
|
||||
'key_href': 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys/3415833-2314-4a86-ba1c-c3c58608a168', # noqa
|
||||
'status': 'active',
|
||||
'tag': 40658,
|
||||
'uuid': '3415833-2314-4a86-ba1c-c3c58608a168'},
|
||||
},
|
||||
'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys/adaab60-bb17-40ed-a13e-88376fe28c86': { # noqa
|
||||
'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/keys/adaab60-bb17-40ed-a13e-88376fe28c86': { # noqa
|
||||
'status': 204,
|
||||
'headers': 'application/json',
|
||||
'body': {},
|
||||
|
|
@ -152,11 +152,11 @@ imap 10800 IN CNAME access.mail.gandi.net.
|
|||
pop 10800 IN CNAME access.mail.gandi.net.
|
||||
smtp 10800 IN CNAME relay.mail.gandi.net.
|
||||
webmail 10800 IN CNAME webmail.gandi.net.
|
||||
www 10800 IN CNAME webredir.vip.gandi.net.""" # noqa
|
||||
www 10800 IN CNAME webredir.vip.gandi.net.""" # noqa
|
||||
content_hdr = kwargs.get('headers', {}).get('Content-Type')
|
||||
if method == 'PUT' and content_hdr == 'text/plain':
|
||||
content = {'message': 'DNS Record Created'}
|
||||
if method == 'PUT' and url == 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/blog/CNAME': # noqa
|
||||
if method == 'PUT' and url == 'https://dns.api.gandi.net/api/v5/domains/iheartcli.com/records/blog/CNAME': # noqa
|
||||
content = {'message': 'DNS Record Created'}
|
||||
mock_resp = mock.Mock()
|
||||
mock_resp.status_code = 200
|
||||
|
|
@ -318,7 +318,7 @@ pop 10800 IN CNAME access.mail.gandi.net.
|
|||
smtp 10800 IN CNAME relay.mail.gandi.net.
|
||||
webmail 10800 IN CNAME webmail.gandi.net.
|
||||
www 10800 IN CNAME webredir.vip.gandi.net.
|
||||
""" # noqa
|
||||
""" # noqa
|
||||
self.assertEqual(result.output, wanted)
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
|
|
@ -487,7 +487,7 @@ Are you sure to delete all records for domain iheartcli.com ? [y/N]: \n"""
|
|||
result = self.invoke_with_exceptions(dns.delete, args, input='\n')
|
||||
|
||||
wanted = """\
|
||||
Are you sure to delete all 'blog' name records for domain iheartcli.com ? [y/N]: \n""" # noqa
|
||||
Are you sure to delete all 'blog' name records for domain iheartcli.com ? [y/N]: \n""" # noqa
|
||||
self.assertEqual(result.output, wanted)
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
|
|
@ -498,7 +498,7 @@ Are you sure to delete all 'blog' name records for domain iheartcli.com ? [y/N]:
|
|||
result = self.invoke_with_exceptions(dns.delete, args, input='\n')
|
||||
|
||||
wanted = """\
|
||||
Are you sure to delete all 'blog' records of type CNAME for domain iheartcli.com ? [y/N]: \n""" # noqa
|
||||
Are you sure to delete all 'blog' records of type CNAME for domain iheartcli.com ? [y/N]: \n""" # noqa
|
||||
self.assertEqual(result.output, wanted)
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
|
|
@ -521,7 +521,7 @@ algorithm_name : ECDSAP256SHA256
|
|||
ds : iheartcli.com. 3600 IN DS 43819 13 2 b4e6ed591f28f4a269b9adfaedec836ea0fe63a8f7f5097108297afa5492b70
|
||||
flags : 256
|
||||
status : active
|
||||
""" # noqa
|
||||
""" # noqa
|
||||
self.assertEqual(result.output, wanted)
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
|
|
@ -540,7 +540,7 @@ public_key : Gnhra3gcNHUL0d05Ia6F/tgBzDD/Km6c2XFZA9RAOcjk/qg9aodc79MQtsTx4/C
|
|||
flags : 256
|
||||
tag : 40658
|
||||
status : active
|
||||
""" # noqa
|
||||
""" # noqa
|
||||
self.assertEqual(result.output, wanted)
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
|
|
@ -559,7 +559,7 @@ public_key : Gnhra3gcNHUL0d05Ia6F/tgBzDD/Km6c2XFZA9RAOcjk/qg9aodc79MQtsTx4/C
|
|||
flags : 256
|
||||
tag : 40658
|
||||
status : active
|
||||
""" # noqa
|
||||
""" # noqa
|
||||
self.assertEqual(result.output, wanted)
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
from .base import CommandTestCase
|
||||
from ..compat import mock
|
||||
from gandi.cli.commands import dnssec
|
||||
|
||||
|
||||
|
|
@ -16,7 +13,7 @@ class DnssecTestCase(CommandTestCase):
|
|||
|
||||
self.maxDiff = None
|
||||
if sys.version_info[0] == 2:
|
||||
self.assertEqual(result.output, """[{'algorithm': 5,\n 'date_created': datetime.datetime(2012, 2, 24, 17, 16, 8),\n 'digest': '457c626c008cc70d68133254abc4ee4eb79e4e6c99f9423b60b543fa8a69e6ac',\n 'digest_type': 2,\n 'flags': 257,\n 'id': 125,\n 'keytag': 9301,\n 'public_key': 'AwEAAdYixYvq9eJLRQcxUeYJWaxAGXiP/K1/C7XHbUWGzA8AHCRp81FAmfwcw1FrJ7bMViEegewPDGciQSv5HotPPOynUmkZbgztOeejH/+3Il/cM8SW4Et0i+99S7l9as+FI3AYOhsllDJK1WM9smn0S/9igfpR2dGmCyDU ZfeR1A49\\n'}]\n""")
|
||||
self.assertEqual(result.output, """[{'algorithm': 5,\n 'date_created': datetime.datetime(2012, 2, 24, 17, 16, 8),\n 'digest': '457c626c008cc70d68133254abc4ee4eb79e4e6c99f9423b60b543fa8a69e6ac',\n 'digest_type': 2,\n 'flags': 257,\n 'id': 125,\n 'keytag': 9301,\n 'public_key': 'AwEAAdYixYvq9eJLRQcxUeYJWaxAGXiP/K1/C7XHbUWGzA8AHCRp81FAmfwcw1FrJ7bMViEegewPDGciQSv5HotPPOynUmkZbgztOeejH/+3Il/cM8SW4Et0i+99S7l9as+FI3AYOhsllDJK1WM9smn0S/9igfpR2dGmCyDU ZfeR1A49\\n'}]\n""") # noqa
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
||||
def test_create(self):
|
||||
|
|
@ -25,9 +22,10 @@ class DnssecTestCase(CommandTestCase):
|
|||
['iheartcli.com',
|
||||
'--flags', 257,
|
||||
'--algorithm', 5,
|
||||
'--public_key', 'AwEAAdYixYvq9eJLRQcxUeYJWaxAGXiP/K1/C7XHbUWGzA8AHCRp81FA'
|
||||
'mfwcw1FrJ7bMViEegewPDGciQSv5HotPPOynUmkZbgztOeejH/+3Il/c'
|
||||
'M8SW4Et0i+99S7l9as+FI3AYOhsllDJK1WM9smn0S/9igfpR2dGmCyDU ZfeR1A49',
|
||||
'--public_key', 'AwEAAdYixYvq9eJLRQcxUeYJWaxAGXiP/K1/C7XHbUWGzA8A'
|
||||
'HCRp81FAmfwcw1FrJ7bMViEegewPDGciQSv5HotPPOynUmkZ'
|
||||
'bgztOeejH/+3Il/cM8SW4Et0i+99S7l9as+FI3AYOhsllDJK'
|
||||
'1WM9smn0S/9igfpR2dGmCyDU ZfeR1A49',
|
||||
])
|
||||
|
||||
self.assertEqual(result.output, """""")
|
||||
|
|
|
|||
|
|
@ -229,11 +229,9 @@ Duration [1]: \n\
|
|||
output = re.sub(r'\[#+\]', '[###]', result.output.strip())
|
||||
if sys.version_info[0] == 2:
|
||||
self.assertEqual(output, """\
|
||||
Duration [1]: \n{'extra': {u'x-aero_ens_authid': u'1234', u'x-aero_ens_authkey': u'password'},\n 'id': 400,\n 'step': 'WAIT'}""")
|
||||
Duration [1]: \n{'extra': {u'x-aero_ens_authid': u'1234', u'x-aero_ens_authkey': u'password'},\n 'id': 400,\n 'step': 'WAIT'}""") # noqa
|
||||
else:
|
||||
self.assertEqual(output, """\
|
||||
Duration [1]: \n{'extra': {'x-aero_ens_authid': '1234', 'x-aero_ens_authkey': 'password'},\n 'id': 400,\n 'step': 'WAIT'}""")
|
||||
|
||||
|
||||
Duration [1]: \n{'extra': {'x-aero_ens_authid': '1234', 'x-aero_ens_authkey': 'password'},\n 'id': 400,\n 'step': 'WAIT'}""") # noqa
|
||||
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
|
|
|
|||
|
|
@ -15,30 +15,30 @@ def _mock_output(git_content, command, *args, **kwargs):
|
|||
config = ConfigParser.ConfigParser()
|
||||
try:
|
||||
config.read_file(buf)
|
||||
except:
|
||||
except Exception:
|
||||
config.readfp(buf)
|
||||
if command == 'git config --local --get remote.gandi.url':
|
||||
try:
|
||||
return config.get('remote "gandi"', 'url')
|
||||
except:
|
||||
except Exception:
|
||||
return ''
|
||||
|
||||
if command == 'git config --local --get remote.origin.url':
|
||||
try:
|
||||
return config.get('remote "origin"', 'url')
|
||||
except:
|
||||
except Exception:
|
||||
return ''
|
||||
|
||||
if command == 'git config --local --get remote.$(git config --local --get branch.stable.remote).url': # noqa
|
||||
try:
|
||||
return config.get('remote "production"', 'url')
|
||||
except:
|
||||
except Exception:
|
||||
return ''
|
||||
|
||||
if command == 'git config --local --get remote.$(git config --local --get branch.master.remote).url': # noqa
|
||||
try:
|
||||
return config.get('remote "origin"', 'url')
|
||||
except:
|
||||
except Exception:
|
||||
return ''
|
||||
|
||||
return ''
|
||||
|
|
|
|||
12
gandi/cli/tests/fixtures/_domain.py
vendored
12
gandi/cli/tests/fixtures/_domain.py
vendored
|
|
@ -88,6 +88,7 @@ def create(domain, params):
|
|||
|
||||
return ret
|
||||
|
||||
|
||||
def renew(domain, params):
|
||||
return {'id': 400, 'step': 'WAIT'}
|
||||
|
||||
|
|
@ -251,15 +252,16 @@ def dnssec_delete(key_id):
|
|||
def dnssec_list(domain):
|
||||
return [{'algorithm': 5,
|
||||
'date_created': datetime(2012, 2, 24, 17, 16, 8),
|
||||
'digest': '457c626c008cc70d68133254abc4ee4eb79e4e6c99f9423b60b543fa8a69e6ac',
|
||||
'digest': '457c626c008cc70d68133254abc4ee4eb79e4e6c99f9423b60b543'
|
||||
'fa8a69e6ac',
|
||||
'digest_type': 2,
|
||||
'flags': 257,
|
||||
'id': 125,
|
||||
'keytag': 9301,
|
||||
'public_key': 'AwEAAdYixYvq9eJLRQcxUeYJWaxAGXiP/K1/C7XHbUWGzA8AHCRp81FA'
|
||||
'mfwcw1FrJ7bMViEegewPDGciQSv5HotPPOynUmkZbgztOeejH/+3Il/c'
|
||||
'M8SW4Et0i+99S7l9as+FI3AYOhsllDJK1WM9smn0S/9igfpR2dGmCyDU ZfeR1A49\n'}]
|
||||
|
||||
'public_key': 'AwEAAdYixYvq9eJLRQcxUeYJWaxAGXiP/K1/C7XHbUWGzA8AHC'
|
||||
'Rp81FAmfwcw1FrJ7bMViEegewPDGciQSv5HotPPOynUmkZbgzt'
|
||||
'OeejH/+3Il/cM8SW4Et0i+99S7l9as+FI3AYOhsllDJK1WM9sm'
|
||||
'n0S/9igfpR2dGmCyDU ZfeR1A49\n'}]
|
||||
|
||||
|
||||
def dnssec_create(domain, params):
|
||||
|
|
|
|||
2
gandi/cli/tests/fixtures/_hosting.py
vendored
2
gandi/cli/tests/fixtures/_hosting.py
vendored
|
|
@ -1377,7 +1377,7 @@ def ssh_list(options):
|
|||
ret = [{'fingerprint': 'b3:11:67:10:2e:1b:a5:66:ed:16:24:98:3e:2e:ed:f5',
|
||||
'id': 134,
|
||||
'name': 'default',
|
||||
'value': 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC63QZAW3tusdv+JuyzOoXTND9/wxKogMwZbxBPPtoN7Hjnyn0kUUHMJ6ji5xpbatRYKOeGAoZDW2TXojvbJdQj7tWsRr7ES0qB9qhDGVSDIJWRQ6f9MQCCLjV5tpBTAwb unknown@lol.cat'}, # noqa
|
||||
'value': 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC63QZAW3tusdv+JuyzOoXTND9/wxKogMwZbxBPPtoN7Hjnyn0kUUHMJ6ji5xpbatRYKOeGAoZDW2TXojvbJdQj7tWsRr7ES0qB9qhDGVSDIJWRQ6f9MQCCLjV5tpBTAwb unknown@lol.cat'}, # noqa
|
||||
{'fingerprint': '09:11:21:e3:90:3c:7d:d5:06:d9:6f:f9:36:e1:99:a6',
|
||||
'id': 141,
|
||||
'name': 'mysecretkey'}]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue