Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
poging testen
Browse files Browse the repository at this point in the history
  • Loading branch information
Vucis committed Mar 13, 2024
1 parent 769fc2f commit ab63ab0
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 153 deletions.
2 changes: 1 addition & 1 deletion backend/Dockerfile_auth → backend/Dockerfile_auth_test
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM python:3.9
RUN mkdir /auth-app
WORKDIR /auth-app
ADD ./test_auth_server /auth-app/
COPY requirements.txt /auth-app/requirements.txt
COPY auth_requirements.txt /auth-app/requirements.txt
RUN pip3 install -r requirements.txt
COPY . /auth-app
ENTRYPOINT ["python"]
Expand Down
4 changes: 4 additions & 0 deletions backend/auth_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
flask~=3.0.2
flask-restful
python-dotenv~=1.0.1
psycopg2-binary
36 changes: 0 additions & 36 deletions backend/test_auth_server/__init__.py

This file was deleted.

46 changes: 42 additions & 4 deletions backend/test_auth_server/__main__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,48 @@
"""Main entry point for the application."""

from dotenv import load_dotenv
from test_auth_server import create_app_with_db
from test_auth_server.db_in import url
from flask import Flask

"""Index api point"""
from flask import Blueprint, request
from flask_restful import Resource, Api

index_bp = Blueprint("index", __name__)
index_endpoint = Api(index_bp)

token_dict = {
"teacher1":{
"id":"brinkmann",
"jobCategory":"teacher"
},
"teacher2":{
"id":"laermans",
"jobCategory":"teacher"
}
}

class Index(Resource):
"""Api endpoint for the / route"""

def get(self):
auth = request.headers.get("Authorization")
if not auth:
return {"message":"Please give authorization"}, 401
bearer, token = auth.split(" ")
if bearer != "Bearer":
return {"message":"Not this kind of authorization"}, 401
if token in token_dict.keys():
return token_dict[token], 200
return {"message":"Wrong address"}, 401


index_bp.add_url_rule("/", view_func=Index.as_view("index"))

if __name__ == "__main__":
load_dotenv()
app = create_app_with_db(url)
app.run(debug=True, host='0.0.0.0')

app = Flask(__name__)
app.register_blueprint(index_bp)

app.run(debug=True, host='0.0.0.0')

6 changes: 0 additions & 6 deletions backend/test_auth_server/db_construct.sql

This file was deleted.

20 changes: 0 additions & 20 deletions backend/test_auth_server/db_in.py

This file was deleted.

36 changes: 0 additions & 36 deletions backend/test_auth_server/index.py

This file was deleted.

15 changes: 0 additions & 15 deletions backend/test_auth_server/sessionmaker.py

This file was deleted.

12 changes: 0 additions & 12 deletions backend/test_auth_server/user_data.py

This file was deleted.

27 changes: 4 additions & 23 deletions backend/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,15 @@ services:
start_period: 5s
volumes:
- ./db_construct.sql:/docker-entrypoint-initdb.d/init.sql
auth-db:
image: postgres:latest
environment:
POSTGRES_USER: auth-user
POSTGRES_PASSWORD: auth-password
POSTGRES_DB: auth-database
healthcheck:
test: ["CMD-SHELL", "pg_isready -U auth-user -d auth-database"]
interval: 5s
timeout: 3s
retries: 3
start_period: 5s
volumes:
- ./test_auth_server/db_construct.sql:/docker-entrypoint-initdb.d/init.sql
auth-server:
build:
context: .
dockerfile: ./Dockerfile_auth
depends_on:
auth-db:
condition: service_healthy
dockerfile: ./Dockerfile_auth_test
environment:
POSTGRES_HOST: auth-db # Use the service name defined in Docker Compose
POSTGRES_USER: auth-user
POSTGRES_PASSWORD: auth-password
POSTGRES_DB: auth-database
API_HOST: http://auth-server
volumes:
- .:/auth-app
command: ["test_auth_server"]
command: ["CMD", "flask run"]


test-runner:
Expand All @@ -54,6 +33,8 @@ services:
depends_on:
postgres:
condition: service_healthy
auth-server:
condition: service_started
environment:
POSTGRES_HOST: postgres # Use the service name defined in Docker Compose
POSTGRES_USER: test_user
Expand Down

0 comments on commit ab63ab0

Please sign in to comment.