Skip to content

Commit

Permalink
Fixing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgliss committed Nov 19, 2016
1 parent 9fff284 commit 2a3816b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 15 deletions.
1 change: 1 addition & 0 deletions lemur/certificates/models.py
Expand Up @@ -79,6 +79,7 @@ class Certificate(db.Model):
secondaryjoin=id == certificate_replacement_associations.c.replaced_certificate_id, # noqa
backref='replaced')

views = relationship("View", backref="certificate")
endpoints = relationship("Endpoint", backref='certificate')

def __init__(self, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions lemur/certificates/service.py
Expand Up @@ -138,8 +138,8 @@ def log_private_key_view(certificate, user):
:param user:
:return:
"""
view = View(user=user)
certificate.views.append(view)
view = View(user_id=user.id, certificate_id=certificate.id)
database.add(view)
database.commit()


Expand Down
11 changes: 1 addition & 10 deletions lemur/tests/test_certificates.py
Expand Up @@ -430,7 +430,7 @@ def test_private_key_audit(client, certificate):


@pytest.mark.parametrize("token,status", [
(VALID_USER_HEADER_TOKEN, 403),
(VALID_USER_HEADER_TOKEN, 200),
(VALID_ADMIN_HEADER_TOKEN, 200),
('', 401)
])
Expand Down Expand Up @@ -528,15 +528,6 @@ def test_certificates_patch(client, token, status):
assert client.patch(api.url_for(CertificatesList), data={}, headers=token).status_code == status


@pytest.mark.parametrize("token,status", [
(VALID_USER_HEADER_TOKEN, 403),
(VALID_ADMIN_HEADER_TOKEN, 200),
('', 401)
])
def test_certificate_credentials_get(client, token, status):
assert client.get(api.url_for(CertificatePrivateKey, certificate_id=1), headers=token).status_code == status


@pytest.mark.parametrize("token,status", [
(VALID_USER_HEADER_TOKEN, 405),
(VALID_ADMIN_HEADER_TOKEN, 405),
Expand Down
2 changes: 0 additions & 2 deletions lemur/users/models.py
Expand Up @@ -85,10 +85,8 @@ class View(db.Model):
__tablename__ = 'views'
id = Column(Integer, primary_key=True)
certificate_id = Column(Integer, ForeignKey('certificates.id'))
certificates = relationship("Certificate", backref='views')
viewed_at = Column(ArrowType(), PassiveDefault(func.now()), nullable=False)
user_id = Column(Integer, ForeignKey('users.id'))
users = relationship("User", backref="views")


listen(User, 'before_insert', hash_password)
2 changes: 1 addition & 1 deletion tox.ini
@@ -1,2 +1,2 @@
[tox]
envlist = py27,py35
envlist = py35

0 comments on commit 2a3816b

Please sign in to comment.