Example #1
0
def test_ssl_blueprint_no_common_name(tmp_path):
    blueprint_content = u"""
---
name: auto_tst.autossl.example.com

servers:
  - type: autossl.server.local.LocalServer
    parameters:
        path: /etc/ssl/my_certificates

certificate:
  type: DV
  certificate_authority: LetsEncrypt
  san:
    - tst.autossl.example.com
    - uat.tst.autossl.example.com
    - pit.tst.autossl.example.com
...
    """
    blueprint_path = tmp_path / 'blueprint.yaml'
    blueprint_path.write_text(blueprint_content, encoding='utf-8')

    ssl_blueprint = ssl.SslBlueprint(str(blueprint_path))
    assert ssl_blueprint.certificate.common_name is None
    assert len(ssl_blueprint.certificate.sans) == 3
Example #2
0
def test_get_config():
    ssl_blueprint = ssl.SslBlueprint(tests_util.DATA_PATH /
                                     'tst.dv.example.com.yaml')

    assert ssl_blueprint.get_config(name='tracking',
                                    path=['dummy_path'],
                                    default=[]) == []
    assert ssl_blueprint.get_config(name='tracking', path=None,
                                    default=None) is None
    assert ssl_blueprint.get_config(
        name='storage', path=None, default=None) == {
            'credentials': 'credential_1',
            'data': [{
                'type': 'key'
            }, {
                'type': 'csr'
            }, {
                'type': 'crt'
            }],
            'parameters': {
                'git_url':
                'https://git.autossl.com/git/scm/ssl/certificates.git',
                'config_user_name': 'Test User',
                'config_user_email': '*****@*****.**',
            },
            'type': 'autossl.storage.gitscm.GitStorage'
        }
Example #3
0
def test_ssl_blueprint_no_server():
    ssl_blueprint = ssl.SslBlueprint(tests_util.DATA_PATH /
                                     'tst.ov.example.com_no-server.yaml')
    assert ssl_blueprint.name == 'auto_tst.autossl.example.com'
    assert ssl_blueprint.certificate.certificate_type == 'OV'
    assert ssl_blueprint.certificate.certificate_authority == 'Sectigo'
    assert ssl_blueprint.certificate.common_name == 'tst.autossl.example.com'
    assert len(ssl_blueprint.servers) == 0
Example #4
0
def test_get_domains():
    ssl_blueprint = ssl.SslBlueprint(tests_util.DATA_PATH /
                                     'tst.dv.example.com.yaml')
    assert ssl_blueprint.domains == {
        'tst.autossl.example.com', 'uat.tst.autossl.example.com',
        'pit.tst.autossl.example.com', 'cit.tst.autossl.example.com',
        'mgt.tst.autossl.example.com'
    }
Example #5
0
def test_dv_ssl_blueprint():
    ssl_blueprint = ssl.SslBlueprint(tests_util.DATA_PATH /
                                     'tst.dv.example.com.yaml')
    assert ssl_blueprint.name == 'auto_tst.autossl.example.com'
    assert ssl_blueprint.certificate.certificate_type == 'DV'
    assert ssl_blueprint.certificate.certificate_authority == 'LetsEncrypt'
    assert ssl_blueprint.certificate.common_name == 'tst.autossl.example.com'
    assert ssl_blueprint.certificate.renewal_delay == 30
    assert len(ssl_blueprint.servers) == 2
    assert len(ssl_blueprint.certificate.sans) == 5
    assert ssl_blueprint.certificate.organization is None
Example #6
0
def test_ssl_blueprint_validate_common_name(tmp_path, common_name, is_valid):
    blueprint_content = u"""
---
name: auto_tst.autossl.example.com

servers:
  - type: autossl.server.local.LocalServer
    parameters:
        path: /etc/ssl/my_certificates

certificate:
  type: DV
  certificate_authority: LetsEncrypt
  common_name: '{}'
...
        """.format(common_name)
    blueprint_path = tmp_path / 'blueprint.yaml'
    blueprint_path.write_text(blueprint_content, encoding='utf-8')

    if is_valid:
        ssl.SslBlueprint(str(blueprint_path))
    else:
        with pytest.raises(ValueError):
            ssl.SslBlueprint(str(blueprint_path))
Example #7
0
def test_ov_ssl_blueprint():
    ssl_blueprint = ssl.SslBlueprint(tests_util.DATA_PATH /
                                     'tst.ov.example.com.yaml')
    assert ssl_blueprint.name == 'auto_tst.autossl.example.com'
    assert ssl_blueprint.certificate.certificate_type == 'OV'
    assert ssl_blueprint.certificate.certificate_authority == 'Sectigo'
    assert ssl_blueprint.certificate.common_name == 'tst.autossl.example.com'
    assert ssl_blueprint.certificate.renewal_delay == 30
    assert len(ssl_blueprint.servers) == 1
    assert len(ssl_blueprint.certificate.sans) == 5
    assert ssl_blueprint.certificate.organization[
        'company_name'] == 'Autossl corporation'
    assert ssl_blueprint.certificate.organization[
        'street_address'] == 'Newbury street'
    assert ssl_blueprint.certificate.organization['city'] == 'Boston'
    assert ssl_blueprint.certificate.organization['state'] == 'Massachusetts'
    assert ssl_blueprint.certificate.organization['postal_code'] == '02115'
    assert ssl_blueprint.certificate.organization['country_code'] == 'US'
Example #8
0
def test_ssl_blueprint_no_commmon_name_no_san(tmp_path):
    blueprint_content = u"""
---
name: auto_tst.autossl.example.com

servers:
  - type: autossl.server.local.LocalServer
    parameters:
        path: /etc/ssl/my_certificates

certificate:
  type: DV
  certificate_authority: LetsEncrypt
...
        """
    blueprint_path = tmp_path / 'blueprint.yaml'
    blueprint_path.write_text(blueprint_content, encoding='utf-8')

    with pytest.raises(ValueError):
        ssl.SslBlueprint(str(blueprint_path))
Example #9
0
def test_ssl_blueprint_with_global_config():
    ssl_blueprint = ssl.SslBlueprint(
        yaml_path=tests_util.DATA_PATH / 'tst.ov.example.com_minimal.yaml',
        global_config_path=tests_util.DATA_PATH / 'global_config.yaml',
    )
    assert ssl_blueprint.name == 'auto_tst.autossl.example.com'
    assert ssl_blueprint.certificate.certificate_type == 'DV'
    assert ssl_blueprint.certificate.certificate_authority == 'LetsEncrypt'
    assert ssl_blueprint.certificate.common_name == 'tst.autossl.example.com'
    assert ssl_blueprint.certificate.renewal_delay == 30
    assert len(ssl_blueprint.servers) == 1
    assert len(ssl_blueprint.certificate.sans) == 5
    assert ssl_blueprint.certificate.organization[
        'company_name'] == 'Autossl corporation'
    assert ssl_blueprint.certificate.organization[
        'street_address'] == 'Newbury street'
    assert ssl_blueprint.certificate.organization['city'] == 'Boston'
    assert ssl_blueprint.certificate.organization['state'] == 'Massachusetts'
    assert ssl_blueprint.certificate.organization['postal_code'] == '02115'
    assert ssl_blueprint.certificate.organization['country_code'] == 'US'
Example #10
0
def ssl_blueprint():
    """Provide bluepring instance using local apis"""
    yield ssl.SslBlueprint(yaml_path=tests_util.DATA_PATH /
                           'local.example.com.yaml')
Example #11
0
def test_missing_blueprint():
    with pytest.raises(IOError):
        ssl.SslBlueprint('dummy/path')