Skip to content

Commit

Permalink
Share app instance between Kerberos tests (apache#15141)
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr authored Apr 16, 2021
1 parent e7c642b commit 54edbaa
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions tests/api/auth/backend/test_kerberos_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,46 @@
import json
import os
import socket
import unittest
from datetime import datetime
from unittest import mock

import pytest

from airflow.api.auth.backend.kerberos_auth import CLIENT_AUTH
from airflow.models import DagBag
from airflow.www import app as application
from airflow.www import app
from tests.test_utils.config import conf_vars
from tests.test_utils.db import clear_db_dags

KRB5_KTNAME = os.environ.get("KRB5_KTNAME")


@pytest.mark.integration("kerberos")
class TestApiKerberos(unittest.TestCase):
@classmethod
def setUpClass(cls):
dagbag = DagBag(include_examples=True)
for dag in dagbag.dags.values():
dag.sync_to_db()

@conf_vars(
@pytest.fixture(scope="module")
def app_for_kerberos():
with conf_vars(
{
("api", "auth_backend"): "airflow.api.auth.backend.kerberos_auth",
("kerberos", "keytab"): KRB5_KTNAME,
('api', 'enable_experimental_api'): 'true',
}
)
def setUp(self):
self.app = application.create_app(testing=True)
):
yield app.create_app(testing=True)


@pytest.fixture(scope="module", autouse=True)
def dagbag_to_db():
dagbag = DagBag(include_examples=True)
for dag in dagbag.dags.values():
dag.sync_to_db()
yield
clear_db_dags()

@classmethod
def tearDownClass(cls) -> None:
clear_db_dags()

@pytest.mark.integration("kerberos")
class TestApiKerberos:
@pytest.fixture(autouse=True)
def _set_attrs(self, app_for_kerberos):
self.app = app_for_kerberos

def test_trigger_dag(self):
with self.app.test_client() as client:
Expand Down

0 comments on commit 54edbaa

Please sign in to comment.