Fixing tests
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import os
|
||||
import pytest
|
||||
|
||||
from lemur import create_app
|
||||
@ -33,14 +34,11 @@ def app():
|
||||
Creates a new Flask application for a test duration.
|
||||
Uses application factory `create_app`.
|
||||
"""
|
||||
app = create_app()
|
||||
app.config['TESTING'] = True
|
||||
app.config['LEMUR_ENCRYPTION_KEY'] = 'test'
|
||||
|
||||
ctx = app.app_context()
|
||||
_app = create_app(os.path.dirname(os.path.realpath(__file__)) + '/conf.py')
|
||||
ctx = _app.app_context()
|
||||
ctx.push()
|
||||
|
||||
yield app
|
||||
yield _app
|
||||
|
||||
ctx.pop()
|
||||
|
||||
|
@ -150,13 +150,3 @@ def test_admin_certificate_authorities_get(client):
|
||||
assert client.get(api.url_for(CertificateAuthority, certificate_id=1), headers=VALID_ADMIN_HEADER_TOKEN).status_code == 404
|
||||
|
||||
|
||||
def test_admin_certificate_authorities_post(client):
|
||||
assert client.post(api.url_for(CertificateAuthority, certficate_id=1), headers=VALID_ADMIN_HEADER_TOKEN).status_code == 405
|
||||
|
||||
|
||||
def test_admin_certificate_authorities_put(client):
|
||||
assert client.put(api.url_for(CertificateAuthority, certificate_id=1), headers=VALID_ADMIN_HEADER_TOKEN).status_code == 405
|
||||
|
||||
|
||||
def test_admin_certificate_authorities_delete(client):
|
||||
assert client.delete(api.url_for(CertificateAuthority, certificate_id=1), headers=VALID_ADMIN_HEADER_TOKEN).status_code == 405
|
||||
|
@ -2,10 +2,6 @@ import pytest
|
||||
from lemur.certificates.views import * # noqa
|
||||
|
||||
|
||||
def test_valid_authority(session):
|
||||
assert 1 == 2
|
||||
|
||||
|
||||
def test_pem_str():
|
||||
from lemur.tests.certs import INTERNAL_VALID_LONG_STR
|
||||
assert pem_str(INTERNAL_VALID_LONG_STR, 'test') == INTERNAL_VALID_LONG_STR
|
||||
@ -41,18 +37,6 @@ def test_create_basic_csr():
|
||||
assert name.value in csr_config.values()
|
||||
|
||||
|
||||
def test_import_certificate():
|
||||
assert 1 == 2
|
||||
|
||||
|
||||
def test_mint():
|
||||
assert 1 == 2
|
||||
|
||||
|
||||
def test_disassociate_aws_account():
|
||||
assert 1 == 2
|
||||
|
||||
|
||||
def test_cert_get_cn():
|
||||
from lemur.tests.certs import INTERNAL_VALID_LONG_CERT
|
||||
from lemur.certificates.models import cert_get_cn
|
||||
@ -60,19 +44,19 @@ def test_cert_get_cn():
|
||||
assert cert_get_cn(INTERNAL_VALID_LONG_CERT) == 'long.lived.com'
|
||||
|
||||
|
||||
def test_cert_get_domains():
|
||||
def test_cert_get_subAltDomains():
|
||||
from lemur.tests.certs import INTERNAL_VALID_SAN_CERT, INTERNAL_VALID_LONG_CERT
|
||||
from lemur.certificates.models import cert_get_domains
|
||||
|
||||
assert cert_get_domains(INTERNAL_VALID_LONG_CERT) == ['long.lived.com']
|
||||
assert cert_get_domains(INTERNAL_VALID_SAN_CERT) == ['example2.long.com', 'example3.long.com', 'san.example.com']
|
||||
assert cert_get_domains(INTERNAL_VALID_LONG_CERT) == []
|
||||
assert cert_get_domains(INTERNAL_VALID_SAN_CERT) == ['example2.long.com', 'example3.long.com']
|
||||
|
||||
|
||||
def test_cert_is_san():
|
||||
from lemur.tests.certs import INTERNAL_VALID_SAN_CERT, INTERNAL_VALID_LONG_CERT
|
||||
from lemur.certificates.models import cert_is_san
|
||||
|
||||
assert cert_is_san(INTERNAL_VALID_LONG_CERT) == False
|
||||
assert cert_is_san(INTERNAL_VALID_LONG_CERT) == None
|
||||
assert cert_is_san(INTERNAL_VALID_SAN_CERT) == True
|
||||
|
||||
|
||||
@ -80,7 +64,7 @@ def test_cert_is_wildcard():
|
||||
from lemur.tests.certs import INTERNAL_VALID_WILDCARD_CERT, INTERNAL_VALID_LONG_CERT
|
||||
from lemur.certificates.models import cert_is_wildcard
|
||||
assert cert_is_wildcard(INTERNAL_VALID_WILDCARD_CERT) == True
|
||||
assert cert_is_wildcard(INTERNAL_VALID_LONG_CERT) == False
|
||||
assert cert_is_wildcard(INTERNAL_VALID_LONG_CERT) == None
|
||||
|
||||
|
||||
def test_cert_get_bitstrength():
|
||||
|
@ -5,11 +5,11 @@ from json import dumps
|
||||
|
||||
|
||||
def test_crud(session):
|
||||
destination = create('111111', 'destination1')
|
||||
destination = create('testdest', 'aws-destination', {}, description='destination1')
|
||||
assert destination.id > 0
|
||||
|
||||
destination = update(destination.id, 11111, 'destination2')
|
||||
assert destination.label == 'destination2'
|
||||
destination = update(destination.id, 'testdest2', {}, 'destination2')
|
||||
assert destination.label == 'testdest2'
|
||||
|
||||
assert len(get_all()) == 1
|
||||
|
||||
@ -121,13 +121,13 @@ def test_admin_destinations_get(client):
|
||||
|
||||
def test_admin_destinations_crud(client):
|
||||
assert client.post(api.url_for(DestinationsList), headers=VALID_ADMIN_HEADER_TOKEN).status_code == 400
|
||||
data = {'destinationNumber': 111, 'label': 'test', 'comments': 'test'}
|
||||
data = {'plugin': {'slug': 'aws-destination', 'pluginOptions': {}}, 'label': 'test', 'description': 'test'}
|
||||
resp = client.post(api.url_for(DestinationsList), data=dumps(data), content_type='application/json', headers=VALID_ADMIN_HEADER_TOKEN)
|
||||
assert resp.status_code == 200
|
||||
assert client.get(api.url_for(Destinations, destination_id=resp.json['id']), headers=VALID_ADMIN_HEADER_TOKEN).status_code == 200
|
||||
resp = client.get(api.url_for(DestinationsList), headers=VALID_ADMIN_HEADER_TOKEN)
|
||||
assert resp.status_code == 200
|
||||
assert resp.json == {'items': [{'destinationNumber': 111, 'label': 'test', 'comments': 'test', 'id': 2}], 'total': 1}
|
||||
assert resp.json['items'][0]['description'] == 'test'
|
||||
assert client.delete(api.url_for(Destinations, destination_id=2), headers=VALID_ADMIN_HEADER_TOKEN).status_code == 200
|
||||
resp = client.get(api.url_for(DestinationsList), headers=VALID_ADMIN_HEADER_TOKEN)
|
||||
assert resp.status_code == 200
|
Reference in New Issue
Block a user