Some checks failed
Create and publish Docker images with specific build args / build-main-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-main-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda126-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda126-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-slim-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-slim-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / merge-main-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-cuda-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-cuda126-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-ollama-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-slim-images (push) Has been cancelled
Python CI / Format Backend (3.11.x) (push) Has been cancelled
Python CI / Format Backend (3.12.x) (push) Has been cancelled
Frontend Build / Format & Build Frontend (push) Has been cancelled
Frontend Build / Frontend Unit Tests (push) Has been cancelled
Close inactive issues / close-issues (push) Has been cancelled
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
from contextlib import contextmanager
|
|
|
|
from fastapi import FastAPI
|
|
|
|
|
|
@contextmanager
|
|
def mock_webui_user(**kwargs):
|
|
from open_webui.routers.webui import app
|
|
|
|
with mock_user(app, **kwargs):
|
|
yield
|
|
|
|
|
|
@contextmanager
|
|
def mock_user(app: FastAPI, **kwargs):
|
|
from open_webui.utils.auth import (
|
|
get_current_user,
|
|
get_verified_user,
|
|
get_admin_user,
|
|
get_current_user_by_api_key,
|
|
)
|
|
from open_webui.models.users import User
|
|
|
|
def create_user():
|
|
user_parameters = {
|
|
"id": "1",
|
|
"name": "John Doe",
|
|
"email": "john.doe@openwebui.com",
|
|
"role": "user",
|
|
"profile_image_url": "/user.png",
|
|
"last_active_at": 1627351200,
|
|
"updated_at": 1627351200,
|
|
"created_at": 162735120,
|
|
**kwargs,
|
|
}
|
|
return User(**user_parameters)
|
|
|
|
app.dependency_overrides = {
|
|
get_current_user: create_user,
|
|
get_verified_user: create_user,
|
|
get_admin_user: create_user,
|
|
get_current_user_by_api_key: create_user,
|
|
}
|
|
yield
|
|
app.dependency_overrides = {}
|