Compare commits
4 Commits
759bab3ff3
...
db218cb8c2
Author | SHA1 | Date |
---|---|---|
Jimmy | db218cb8c2 | |
Jimmy | fd5fc0a85d | |
Jimmy | 7307abf7d8 | |
Jimmy | b6f41f4d0a |
2
Pipfile
2
Pipfile
|
@ -24,5 +24,5 @@ mypy = "*"
|
||||||
python_version = "3.9"
|
python_version = "3.9"
|
||||||
|
|
||||||
[scripts]
|
[scripts]
|
||||||
test = "pytest app/test/test_main.py -s"
|
test = "pytest app/test/test_auth.py app/test/test_server.py -W ignore::DeprecationWarning -s"
|
||||||
dev = "uvicorn app.main:app --reload"
|
dev = "uvicorn app.main:app --reload"
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
from fastapi import FastAPI, Depends
|
from fastapi import FastAPI, Depends
|
||||||
from app import auth, user, server
|
from app import auth, user, server
|
||||||
|
from os import getenv
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
dependencies = list()
|
||||||
|
if not getenv('DISABLE_AUTH'):
|
||||||
|
dependencies.append(Depends(auth.authorise))
|
||||||
app.include_router(auth.router)
|
app.include_router(auth.router)
|
||||||
app.include_router(user.router)
|
app.include_router(user.router)
|
||||||
app.include_router(server.router, dependencies=[Depends(auth.authorise)])
|
app.include_router(server.router, dependencies=dependencies)
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#curl -i -X POST http://localhost:8000/token -H "Content-Type: application/x-www-form-urlencoded" -d "username=johndoe&password=secret"
|
||||||
|
|
||||||
|
# curl -X 'GET' \
|
||||||
|
# 'http://localhost:8000/users/me/' \
|
||||||
|
# -H 'accept: application/json' \
|
||||||
|
# -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqb2huZG9lIiwiZXhwIjoxNjMxNDQ4MjQ1fQ.DrM92jgRiry0uXBXn-61rRehATW4zDhHUWoGR6lv6Us'
|
||||||
|
from fastapi import FastAPI
|
||||||
|
from fastapi.testclient import TestClient
|
||||||
|
import docker
|
||||||
|
|
||||||
|
from server import *
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
app.include_router(router)
|
||||||
|
testclient = TestClient(app)
|
||||||
|
|
||||||
|
def test_start():
|
||||||
|
#response = testclient.post("/server/minecraft/start")
|
||||||
|
#assert response.status_code == 200
|
||||||
|
pass
|
||||||
|
|
|
@ -9,6 +9,3 @@ async def read_users_me(current_user: User = Depends(get_current_active_user)):
|
||||||
return current_user
|
return current_user
|
||||||
|
|
||||||
|
|
||||||
@router.get("/users/me/items/")
|
|
||||||
async def read_own_items(current_user: User = Depends(get_current_active_user)):
|
|
||||||
return [{"item_id": "Foo", "owner": current_user.username}]
|
|
||||||
|
|
Loading…
Reference in New Issue