Home / File/ test_security_scopes_dont_propagate.py — fastapi Source File

test_security_scopes_dont_propagate.py — fastapi Source File

Architecture documentation for test_security_scopes_dont_propagate.py, a python file in the fastapi codebase. 4 imports, 0 dependents.

File python FastAPI Applications 4 imports 5 functions

Entity Profile

Dependency Diagram

graph LR
  30ea7408_25bb_274c_a4d8_3b0e2c4dc4c0["test_security_scopes_dont_propagate.py"]
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  30ea7408_25bb_274c_a4d8_3b0e2c4dc4c0 --> 0dda2280_3359_8460_301c_e98c77e78185
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  30ea7408_25bb_274c_a4d8_3b0e2c4dc4c0 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  35c4ea20_c454_5afd_6cda_f0818bbcc650["__init__.py"]
  30ea7408_25bb_274c_a4d8_3b0e2c4dc4c0 --> 35c4ea20_c454_5afd_6cda_f0818bbcc650
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  30ea7408_25bb_274c_a4d8_3b0e2c4dc4c0 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  style 30ea7408_25bb_274c_a4d8_3b0e2c4dc4c0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

# Ref: https://github.com/tiangolo/fastapi/issues/5623

from typing import Annotated, Any

from fastapi import FastAPI, Security
from fastapi.security import SecurityScopes
from fastapi.testclient import TestClient


async def security1(scopes: SecurityScopes):
    return scopes.scopes


async def security2(scopes: SecurityScopes):
    return scopes.scopes


async def dep3(
    dep1: Annotated[list[str], Security(security1, scopes=["scope1"])],
    dep2: Annotated[list[str], Security(security2, scopes=["scope2"])],
):
    return {"dep1": dep1, "dep2": dep2}


app = FastAPI()


@app.get("/scopes")
def get_scopes(
    dep3: Annotated[dict[str, Any], Security(dep3, scopes=["scope3"])],
):
    return dep3


client = TestClient(app)


def test_security_scopes_dont_propagate():
    response = client.get("/scopes")
    assert response.status_code == 200
    assert response.json() == {
        "dep1": ["scope3", "scope1"],
        "dep2": ["scope3", "scope2"],
    }

Domain

Subdomains

Frequently Asked Questions

What does test_security_scopes_dont_propagate.py do?
test_security_scopes_dont_propagate.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Applications subdomain.
What functions are defined in test_security_scopes_dont_propagate.py?
test_security_scopes_dont_propagate.py defines 5 function(s): dep3, get_scopes, security1, security2, test_security_scopes_dont_propagate.
What does test_security_scopes_dont_propagate.py depend on?
test_security_scopes_dont_propagate.py imports 4 module(s): __init__.py, __init__.py, testclient.py, typing.
Where is test_security_scopes_dont_propagate.py in the architecture?
test_security_scopes_dont_propagate.py is located at tests/test_security_scopes_dont_propagate.py (domain: FastAPI, subdomain: Applications, directory: tests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free