diff options
author | Nick Fong <nickfong@users.noreply.github.com> | 2016-11-09 04:19:05 +0300 |
---|---|---|
committer | Brad Warren <bmw@users.noreply.github.com> | 2016-11-09 04:19:05 +0300 |
commit | dd8772b608d0f21569145e8b502df72d5d73fff1 (patch) | |
tree | e8dae48e2e354c1ad188229653d1288223366704 /certbot-nginx | |
parent | 8c1aa3ef466f2c76b71f236d9c7f777e70e6bfc1 (diff) |
Remove get_all_certs_keys() from Apache and Nginx (#3768)
- Remove get_all_certs_keys() implementation in
- certbot-apache/certbot_apache/configurator.py
- Remove corresponding tests for get_all_certs_keys() in
- certbot-apache/certbot_apache/tests/configurator_test.py
- Remove get_all_certs_keys() implementation in
- certbot-nginx/certbot_nginx/configurator.py
- certbot-nginx/certbot_nginx/parser.py
- Remove corresponding tests for get_all_certs_keys() in:
- certbot-nginx/certbot_nginx/tests/configurator_test.py
- certbot-nginx/certbot_nginx/tests/parser_test.py
Resolves #3762
Diffstat (limited to 'certbot-nginx')
-rw-r--r-- | certbot-nginx/certbot_nginx/configurator.py | 12 | ||||
-rw-r--r-- | certbot-nginx/certbot_nginx/parser.py | 27 | ||||
-rw-r--r-- | certbot-nginx/certbot_nginx/tests/configurator_test.py | 35 | ||||
-rw-r--r-- | certbot-nginx/certbot_nginx/tests/parser_test.py | 20 |
4 files changed, 0 insertions, 94 deletions
diff --git a/certbot-nginx/certbot_nginx/configurator.py b/certbot-nginx/certbot_nginx/configurator.py index 94ac7de86..0c6e1598c 100644 --- a/certbot-nginx/certbot_nginx/configurator.py +++ b/certbot-nginx/certbot_nginx/configurator.py @@ -474,18 +474,6 @@ class NginxConfigurator(common.Plugin): self.parser.add_server_directives( vhost, ssl_block, replace=False) - def get_all_certs_keys(self): - """Find all existing keys, certs from configuration. - - :returns: list of tuples with form [(cert, key, path)] - cert - str path to certificate file - key - str path to associated key file - path - File path to configuration file. - :rtype: set - - """ - return self.parser.get_all_certs_keys() - ################################## # enhancement methods (IInstaller) ################################## diff --git a/certbot-nginx/certbot_nginx/parser.py b/certbot-nginx/certbot_nginx/parser.py index d5664ac29..385635212 100644 --- a/certbot-nginx/certbot_nginx/parser.py +++ b/certbot-nginx/certbot_nginx/parser.py @@ -298,33 +298,6 @@ class NginxParser(object): except errors.MisconfigurationError as err: raise errors.MisconfigurationError("Problem in %s: %s" % (filename, err.message)) - def get_all_certs_keys(self): - """Gets all certs and keys in the nginx config. - - :returns: list of tuples with form [(cert, key, path)] - cert - str path to certificate file - key - str path to associated key file - path - File path to configuration file. - :rtype: set - - """ - c_k = set() - vhosts = self.get_vhosts() - for vhost in vhosts: - tup = [None, None, vhost.filep] - if vhost.ssl: - for directive in vhost.raw: - # A directive can be an empty list to preserve whitespace - if not directive: - continue - if directive[0] == 'ssl_certificate': - tup[0] = directive[1] - elif directive[0] == 'ssl_certificate_key': - tup[1] = directive[1] - if tup[0] is not None and tup[1] is not None: - c_k.add(tuple(tup)) - return c_k - def _do_for_subarray(entry, condition, func, path=None): """Executes a function for a subarray of a nested array if it matches diff --git a/certbot-nginx/certbot_nginx/tests/configurator_test.py b/certbot-nginx/certbot_nginx/tests/configurator_test.py index f7d6ade2d..f165ea23a 100644 --- a/certbot-nginx/certbot_nginx/tests/configurator_test.py +++ b/certbot-nginx/certbot_nginx/tests/configurator_test.py @@ -238,41 +238,6 @@ class NginxConfiguratorTest(util.NginxTest): ], parsed_migration_conf[0]) - def test_get_all_certs_keys(self): - nginx_conf = self.config.parser.abs_path('nginx.conf') - example_conf = self.config.parser.abs_path('sites-enabled/example.com') - migration_conf = self.config.parser.abs_path('sites-enabled/migration.com') - sslon_conf = self.config.parser.abs_path('sites-enabled/sslon.com') - - # Get the default SSL vhost - self.config.deploy_cert( - "www.example.com", - "example/cert.pem", - "example/key.pem", - "example/chain.pem", - "example/fullchain.pem") - self.config.deploy_cert( - "another.alias", - "/etc/nginx/cert.pem", - "/etc/nginx/key.pem", - "/etc/nginx/chain.pem", - "/etc/nginx/fullchain.pem") - self.config.deploy_cert( - "migration.com", - "migration/cert.pem", - "migration/key.pem", - "migration/chain.pem", - "migration/fullchain.pem") - self.config.save() - - self.config.parser.load() - self.assertEqual(set([ - ('example/fullchain.pem', 'example/key.pem', example_conf), - ('/etc/nginx/fullchain.pem', '/etc/nginx/key.pem', nginx_conf), - ('migration/fullchain.pem', 'migration/key.pem', migration_conf), - ('snakeoil.cert', 'snakeoil.key', sslon_conf), - ]), self.config.get_all_certs_keys()) - @mock.patch("certbot_nginx.configurator.tls_sni_01.NginxTlsSni01.perform") @mock.patch("certbot_nginx.configurator.NginxConfigurator.restart") @mock.patch("certbot_nginx.configurator.NginxConfigurator.revert_challenge_config") diff --git a/certbot-nginx/certbot_nginx/tests/parser_test.py b/certbot-nginx/certbot_nginx/tests/parser_test.py index d5593171a..54deffd7a 100644 --- a/certbot-nginx/certbot_nginx/tests/parser_test.py +++ b/certbot-nginx/certbot_nginx/tests/parser_test.py @@ -291,26 +291,6 @@ class NginxParserTest(util.NginxTest): COMMENT_BLOCK, ["\n", "e", " ", "f"]]) - def test_get_all_certs_keys(self): - nparser = parser.NginxParser(self.config_path, self.ssl_options) - filep = nparser.abs_path('sites-enabled/example.com') - mock_vhost = obj.VirtualHost(filep, - None, None, None, - set(['.example.com', 'example.*']), - None, [0]) - nparser.add_server_directives(mock_vhost, - [['ssl_certificate', 'foo.pem'], - ['ssl_certificate_key', 'bar.key'], - ['listen', '443 ssl']], - replace=False) - c_k = nparser.get_all_certs_keys() - migration_file = nparser.abs_path('sites-enabled/migration.com') - sslon_file = nparser.abs_path('sites-enabled/sslon.com') - self.assertEqual(set([('foo.pem', 'bar.key', filep), - ('cert.pem', 'cert.key', migration_file), - ('snakeoil.cert', 'snakeoil.key', sslon_file) - ]), c_k) - def test_parse_server_ssl(self): server = parser.parse_server([ ['listen', '443'] |