Skip to content

Commit

Permalink
Fix comments by PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristiyan Tashev committed Jul 5, 2022
1 parent 6a8b54e commit 7ab7989
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions demo_project/api/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from fastapi.security.api_key import APIKeyHeader

from fastapi_azure_auth import (
B2CAuthorizationCodeBearer,
B2CMultiTenantAuthorizationCodeBearer,
MultiTenantAzureAuthorizationCodeBearer,
SingleTenantAzureAuthorizationCodeBearer,
)
Expand Down Expand Up @@ -73,7 +73,7 @@ async def __call__(self, tid: str) -> str:
auto_error=False,
)

azure_scheme_auto_error_false_b2c = B2CAuthorizationCodeBearer(
azure_scheme_auto_error_false_b2c = B2CMultiTenantAuthorizationCodeBearer(
app_client_id=settings.APP_CLIENT_ID,
openapi_authorization_url=settings.AUTH_URL,
openapi_token_url=settings.TOKEN_URL,
Expand Down
2 changes: 1 addition & 1 deletion fastapi_azure_auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from fastapi_azure_auth.auth import ( # noqa: F401
B2CAuthorizationCodeBearer as B2CAuthorizationCodeBearer,
B2CMultiTenantAuthorizationCodeBearer as B2CMultiTenantAuthorizationCodeBearer,
MultiTenantAzureAuthorizationCodeBearer as MultiTenantAzureAuthorizationCodeBearer,
SingleTenantAzureAuthorizationCodeBearer as SingleTenantAzureAuthorizationCodeBearer,
)
Expand Down
2 changes: 1 addition & 1 deletion fastapi_azure_auth/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def __init__(
self.scheme_name: str = 'Azure AD - PKCE, Multi-tenant'


class B2CAuthorizationCodeBearer(AzureAuthorizationCodeBearerBase):
class B2CMultiTenantAuthorizationCodeBearer(AzureAuthorizationCodeBearerBase):
def __init__(
self,
app_client_id: str,
Expand Down
6 changes: 3 additions & 3 deletions tests/multi_tenant/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@pytest.fixture
def multi_tenant_app():
azure_scheme_overrides = generate_obj()
azure_scheme_overrides = generate_azure_scheme_multi_tenant_object()
app.dependency_overrides[azure_scheme] = azure_scheme_overrides
yield

Expand Down Expand Up @@ -54,9 +54,9 @@ def mock_openid_and_no_valid_keys(respx_mock, mock_openid):
yield


def generate_obj(issuer=None):
def generate_azure_scheme_multi_tenant_object(issuer=None):
"""
This method is used just to generate the B2C Obj
This method is used just to generate the Multi Tenant Obj
"""

async def issuer_fetcher(tid):
Expand Down
4 changes: 2 additions & 2 deletions tests/multi_tenant/test_multi_tenant.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from demo_project.core.config import settings
from demo_project.main import app
from httpx import AsyncClient
from tests.multi_tenant.conftest import generate_obj
from tests.multi_tenant.conftest import generate_azure_scheme_multi_tenant_object
from tests.utils import (
build_access_token,
build_access_token_expired,
Expand Down Expand Up @@ -81,7 +81,7 @@ async def test_iss_callable_raise_error(mock_openid_and_keys):
async def issuer_fetcher(tid):
raise InvalidAuth(f'Tenant {tid} not a valid tenant')

azure_scheme_overrides = generate_obj(issuer_fetcher)
azure_scheme_overrides = generate_azure_scheme_multi_tenant_object(issuer_fetcher)

app.dependency_overrides[azure_scheme] = azure_scheme_overrides
async with AsyncClient(
Expand Down
10 changes: 5 additions & 5 deletions tests/multi_tenant_b2c/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from demo_project.main import app
from tests.utils import build_openid_keys, keys_url, openid_config_url, openid_configuration

from fastapi_azure_auth import B2CAuthorizationCodeBearer
from fastapi_azure_auth import B2CMultiTenantAuthorizationCodeBearer


@pytest.fixture
def multi_tenant_app():
azure_scheme_overrides = generate_obj()
azure_scheme_overrides = generate_azure_scheme_multi_tenant_b2c_object()
app.dependency_overrides[azure_scheme] = azure_scheme_overrides
yield

Expand Down Expand Up @@ -54,9 +54,9 @@ def mock_openid_and_no_valid_keys(respx_mock, mock_openid):
yield


def generate_obj(issuer=None):
def generate_azure_scheme_multi_tenant_b2c_object(issuer=None):
"""
This method is used just to generate the B2C Obj
This method is used just to generate the Multi Tenant B2C Obj
"""

async def issuer_fetcher(tid):
Expand All @@ -66,7 +66,7 @@ async def issuer_fetcher(tid):
current_issuer = issuer_fetcher
if issuer:
current_issuer = issuer
return B2CAuthorizationCodeBearer(
return B2CMultiTenantAuthorizationCodeBearer(
app_client_id=settings.APP_CLIENT_ID,
openapi_authorization_url=settings.AUTH_URL,
openapi_token_url=settings.TOKEN_URL,
Expand Down
4 changes: 2 additions & 2 deletions tests/multi_tenant_b2c/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from fastapi_azure_auth import B2CAuthorizationCodeBearer
from fastapi_azure_auth import B2CMultiTenantAuthorizationCodeBearer


async def iss_callable_do_not_accept_tid_argument(t):
Expand All @@ -10,4 +10,4 @@ async def iss_callable_do_not_accept_tid_argument(t):
@pytest.mark.parametrize('iss_callable', [None, '', True, False, 1, iss_callable_do_not_accept_tid_argument])
def test_non_accepted_issue_fetcher_given(iss_callable):
with pytest.raises(RuntimeError):
B2CAuthorizationCodeBearer(app_client_id='some id', validate_iss=True, iss_callable=iss_callable)
B2CMultiTenantAuthorizationCodeBearer(app_client_id='some id', validate_iss=True, iss_callable=iss_callable)

0 comments on commit 7ab7989

Please sign in to comment.