Exemplo n.º 1
0
def test_map_fields_with_validity_years(app):
    from lemur.plugins.lemur_digicert.plugin import map_fields

    names = [u"one.example.com", u"two.example.com", u"three.example.com"]

    options = {
        "common_name": "example.com",
        "owner": "*****@*****.**",
        "description": "test certificate",
        "extensions": {
            "sub_alt_names": {
                "names": [x509.DNSName(x) for x in names]
            }
        },
        "validity_years": 2,
        "validity_end": arrow.get(2017, 10, 30),
    }

    data = map_fields(options, CSR_STR)

    assert data == {
        "certificate": {
            "csr": CSR_STR,
            "common_name": "example.com",
            "dns_names": names,
            "signature_hash": "sha256",
        },
        "organization": {
            "id": 111111
        },
        "validity_years": 2,
    }
Exemplo n.º 2
0
def test_map_fields_with_validity_years(app):
    from lemur.plugins.lemur_digicert.plugin import map_fields

    names = [u'one.example.com', u'two.example.com', u'three.example.com']

    options = {
        'common_name': 'example.com',
        'owner': '*****@*****.**',
        'description': 'test certificate',
        'extensions': {
            'sub_alt_names': {
                'names': [x509.DNSName(x) for x in names]
            }
        },
        'validity_years': 2,
        'validity_end': arrow.get(2017, 10, 30)
    }

    data = map_fields(options, CSR_STR)

    assert data == {
        'certificate': {
            'csr': CSR_STR,
            'common_name': 'example.com',
            'dns_names': names,
            'signature_hash': 'sha256'
        },
        'organization': {
            'id': 111111
        },
        'validity_years': 2
    }
Exemplo n.º 3
0
def test_map_fields_with_validity_years(app):
    from lemur.plugins.lemur_digicert.plugin import map_fields

    names = [u'one.example.com', u'two.example.com', u'three.example.com']

    options = {
        'common_name': 'example.com',
        'owner': '*****@*****.**',
        'description': 'test certificate',
        'extensions': {
            'sub_alt_names': {
                'names': [x509.DNSName(x) for x in names]
            }
        },
        'validity_years': 2,
        'validity_end': arrow.get(2017, 10, 30)
    }

    data = map_fields(options, CSR_STR)

    assert data == {
        'certificate': {
            'csr': CSR_STR,
            'common_name': 'example.com',
            'dns_names': names,
            'signature_hash': 'sha256'
        },
        'organization': {'id': 111111},
        'validity_years': 2
    }
Exemplo n.º 4
0
def test_map_fields_with_validity_years(mock_current_app):
    mock_current_app.config.get = Mock(side_effect=config_mock)

    with patch('lemur.plugins.lemur_digicert.plugin.signature_hash'
               ) as mock_signature_hash:
        mock_signature_hash.return_value = "sha256"

        names = [u"one.example.com", u"two.example.com", u"three.example.com"]
        options = {
            "common_name": "example.com",
            "owner": "*****@*****.**",
            "description": "test certificate",
            "extensions": {
                "sub_alt_names": {
                    "names": [x509.DNSName(x) for x in names]
                }
            },
            "validity_years": 1
        }
        expected = {
            "certificate": {
                "csr": CSR_STR,
                "common_name": "example.com",
                "dns_names": names,
                "signature_hash": "sha256",
            },
            "organization": {
                "id": 111111
            },
            "validity_years": 1,
        }
        assert expected == plugin.map_fields(options, CSR_STR)
Exemplo n.º 5
0
def test_map_fields_with_validity_end_and_start(mock_current_app):
    mock_current_app.config.get = Mock(side_effect=config_mock)
    plugin.determine_end_date = Mock(return_value=arrow.get(2017, 5, 7))

    with patch('lemur.plugins.lemur_digicert.plugin.signature_hash') as mock_signature_hash:
        mock_signature_hash.return_value = "sha256"

        names = [u"one.example.com", u"two.example.com", u"three.example.com"]
        options = {
            "common_name": "example.com",
            "owner": "*****@*****.**",
            "description": "test certificate",
            "extensions": {"sub_alt_names": {"names": [x509.DNSName(x) for x in names]}},
            "validity_end": arrow.get(2017, 5, 7),
            "validity_start": arrow.get(2016, 10, 30),
        }

        expected = {
            "certificate": {
                "csr": CSR_STR,
                "common_name": "example.com",
                "dns_names": names,
                "signature_hash": "sha256",
            },
            "organization": {"id": 111111},
            "custom_expiration_date": arrow.get(2017, 5, 7).format("YYYY-MM-DD"),
        }

        assert expected == plugin.map_fields(options, CSR_STR)
Exemplo n.º 6
0
def test_map_fields(app):
    from lemur.plugins.lemur_digicert.plugin import map_fields

    names = ['one.example.com', 'two.example.com', 'three.example.com']

    options = {
        'common_name': 'example.com',
        'owner': '*****@*****.**',
        'description': 'test certificate',
        'extensions': {
            'sub_alt_names': {
                'names': [{
                    'name_type': 'DNSName',
                    'value': x
                } for x in names]
            }
        },
        'validity_end': arrow.get(2017, 5, 7),
        'validity_start': arrow.get(2016, 10, 30)
    }

    data = map_fields(options, CSR_STR)

    assert data == {
        'certificate': {
            'csr': CSR_STR,
            'common_name': 'example.com',
            'dns_names': names,
            'signature_hash': 'sha256'
        },
        'organization': {
            'id': 111111
        },
        'custom_expiration_date': arrow.get(2017, 5, 7).format('YYYY-MM-DD')
    }