Skip to content

Commit

Permalink
better about closing session and teardown in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
neovintage committed Nov 30, 2015
1 parent fb69b72 commit 6ec3a70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions airflow/contrib/auth/backends/password_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ def login(self, request):
user = session.query(PasswordUser).filter(
PasswordUser.username == username).first()
if not user:
session.close()
raise AuthenticationError()

if not user.authenticate(password):
session.close()
raise AuthenticationError()
LOG.info("User %s successfully authenticated", username)

Expand Down
4 changes: 4 additions & 0 deletions tests/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,10 @@ def test_unauthorized_password_auth(self):

def tearDown(self):
configuration.test_mode()
session = Session()
session.query(models.User).delete()
session.commit()
session.close()
configuration.conf.set("webserver", "authenticate", "False")


Expand Down

0 comments on commit 6ec3a70

Please sign in to comment.