diff --git a/.gitignore b/.gitignore index 65752d4..ef19105 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ instance/ .idea +*.iml .admin_credentials *__pycache__/ .pytest_cache/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3f6cb05..9b48a47 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,9 +11,9 @@ Atheneum:Tests: - python3 -m pipenv --version - cd server - pipenv install --dev --system - - pycodestyle atheneum tests - - mypy atheneum tests - - PYTHONPATH=$(pwd) coverage run --source atheneum -m pytest + - pycodestyle corvus tests + - mypy corvus tests + - PYTHONPATH=$(pwd) coverage run --source corvus -m pytest - coverage report --fail-under=85 -m --skip-covered tags: - docker diff --git a/Dockerfile b/Dockerfile index 582ded4..d763d66 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,23 @@ FROM python:3.6-slim-stretch MAINTAINER Drew Short -ENV ATHENEUM_APP_DIRECTORY /opt/atheneum -ENV ATHENEUM_CONFIG_DIRECTORY /srv/atheneum/config -ENV ATHENEUM_DATA_DIRECTORY /srv/atheneum/data +ENV CORVUS_APP_DIRECTORY /opt/corvus +ENV CORVUS_CONFIG_DIRECTORY /srv/corvus/config +ENV CORVUS_DATA_DIRECTORY /srv/corvus/data -RUN mkdir -p ${ATHENEUM_APP_DIRECTORY} \ -&& mkdir -p ${ATHENEUM_CONFIG_DIRECTORY} \ -&& mkdir -p ${ATHENEUM_DATA_DIRECTORY} \ +RUN mkdir -p ${CORVUS_APP_DIRECTORY} \ +&& mkdir -p ${CORVUS_CONFIG_DIRECTORY} \ +&& mkdir -p ${CORVUS_DATA_DIRECTORY} \ && pip install pipenv gunicorn -VOLUME ${ATHENEUM_CONFIG_DIRECTORY} -VOLUME ${ATHENEUM_DATA_DIRECTORY} +VOLUME ${CORVUS_CONFIG_DIRECTORY} +VOLUME ${CORVUS_DATA_DIRECTORY} -COPY ./server/ ${ATHENEUM_APP_DIRECTORY}/ +COPY ./server/ ${CORVUS_APP_DIRECTORY}/ -RUN cd ${ATHENEUM_APP_DIRECTORY} \ +RUN cd ${CORVUS_APP_DIRECTORY} \ && pipenv install --system --deploy --ignore-pipfile -WORKDIR ${ATHENEUM_APP_DIRECTORY} +WORKDIR ${CORVUS_APP_DIRECTORY} CMD ./entrypoint.sh diff --git a/server/.env b/server/.env index 62fbcfb..eb2a908 100644 --- a/server/.env +++ b/server/.env @@ -1 +1 @@ -FLASK_APP=atheneum \ No newline at end of file +FLASK_APP=corvus diff --git a/server/atheneum/api/__init__.py b/server/atheneum/api/__init__.py deleted file mode 100644 index 7802de1..0000000 --- a/server/atheneum/api/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from atheneum.api.authentication_api import auth_blueprint diff --git a/server/atheneum/model/__init__.py b/server/atheneum/model/__init__.py deleted file mode 100644 index 7949bd4..0000000 --- a/server/atheneum/model/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from atheneum.model.user_model import User, UserToken diff --git a/server/atheneum/__init__.py b/server/corvus/__init__.py similarity index 77% rename from server/atheneum/__init__.py rename to server/corvus/__init__.py index a9f68a6..c5b1a12 100644 --- a/server/atheneum/__init__.py +++ b/server/corvus/__init__.py @@ -5,7 +5,7 @@ from flask import Flask from flask_migrate import Migrate, upgrade from flask_sqlalchemy import SQLAlchemy -from atheneum import utility +from corvus import utility db: SQLAlchemy = SQLAlchemy() @@ -28,12 +28,12 @@ dictConfig({ def create_app(test_config: dict = None) -> Flask: app = Flask(__name__, instance_relative_config=True) - app.logger.debug('Creating Atheneum Server') + app.logger.debug('Creating Corvus Server') - data_directory = os.getenv('ATHENEUM_DATA_DIRECTORY', '/tmp') - app.logger.debug('Atheneum Data Directory: %s', data_directory) + data_directory = os.getenv('CORVUS_DATA_DIRECTORY', '/tmp') + app.logger.debug('Corvus Data Directory: %s', data_directory) - default_database_uri = 'sqlite:///{}/atheneum.db'.format(data_directory) + default_database_uri = 'sqlite:///{}/corvus.db'.format(data_directory) app.config.from_mapping( SECRET_KEY='dev', SQLALCHEMY_DATABASE_URI=default_database_uri, @@ -42,10 +42,10 @@ def create_app(test_config: dict = None) -> Flask: if test_config is None: app.logger.debug('Loading configurations') - app.config.from_object('atheneum.default_settings') + app.config.from_object('corvus.default_settings') app.config.from_pyfile('config.py', silent=True) - if os.getenv('ATHENEUM_SETTINGS', None): - app.config.from_envvar('ATHENEUM_SETTINGS') + if os.getenv('CORVUS_SETTINGS', None): + app.config.from_envvar('CORVUS_SETTINGS') else: app.logger.debug('Loading test configuration') app.config.from_object(test_config) @@ -66,7 +66,7 @@ def create_app(test_config: dict = None) -> Flask: def register_blueprints(app: Flask) -> None: - from atheneum.api import auth_blueprint + from corvus.api import auth_blueprint app.register_blueprint(auth_blueprint) diff --git a/server/corvus/api/__init__.py b/server/corvus/api/__init__.py new file mode 100644 index 0000000..34f18a4 --- /dev/null +++ b/server/corvus/api/__init__.py @@ -0,0 +1 @@ +from corvus.api.authentication_api import auth_blueprint diff --git a/server/atheneum/api/authentication_api.py b/server/corvus/api/authentication_api.py similarity index 83% rename from server/atheneum/api/authentication_api.py rename to server/corvus/api/authentication_api.py index e2143c6..9574c31 100644 --- a/server/atheneum/api/authentication_api.py +++ b/server/corvus/api/authentication_api.py @@ -1,9 +1,9 @@ from flask import Blueprint, g -from atheneum.api.decorators import return_json -from atheneum.api.model import APIResponse -from atheneum.middleware import authentication_middleware -from atheneum.service import user_token_service, authentication_service +from corvus.api.decorators import return_json +from corvus.api.model import APIResponse +from corvus.middleware import authentication_middleware +from corvus.service import user_token_service, authentication_service auth_blueprint = Blueprint( name='auth', import_name=__name__, url_prefix='/auth') diff --git a/server/atheneum/api/decorators.py b/server/corvus/api/decorators.py similarity index 93% rename from server/atheneum/api/decorators.py rename to server/corvus/api/decorators.py index 8d3e9b2..938a1ac 100644 --- a/server/atheneum/api/decorators.py +++ b/server/corvus/api/decorators.py @@ -3,7 +3,7 @@ from typing import Callable, Any from flask import jsonify, Response -from atheneum.api.model import APIResponse +from corvus.api.model import APIResponse def return_json(func: Callable) -> Callable: diff --git a/server/atheneum/api/model.py b/server/corvus/api/model.py similarity index 100% rename from server/atheneum/api/model.py rename to server/corvus/api/model.py diff --git a/server/atheneum/default_settings.py b/server/corvus/default_settings.py similarity index 100% rename from server/atheneum/default_settings.py rename to server/corvus/default_settings.py diff --git a/server/atheneum/middleware/__init__.py b/server/corvus/middleware/__init__.py similarity index 100% rename from server/atheneum/middleware/__init__.py rename to server/corvus/middleware/__init__.py diff --git a/server/atheneum/middleware/authentication_middleware.py b/server/corvus/middleware/authentication_middleware.py similarity index 98% rename from server/atheneum/middleware/authentication_middleware.py rename to server/corvus/middleware/authentication_middleware.py index 3113a13..6d54deb 100644 --- a/server/atheneum/middleware/authentication_middleware.py +++ b/server/corvus/middleware/authentication_middleware.py @@ -6,7 +6,7 @@ from flask import request, Response, g from werkzeug.datastructures import Authorization from werkzeug.http import bytes_to_wsgi, wsgi_to_bytes -from atheneum.service import ( +from corvus.service import ( authentication_service, user_service, user_token_service diff --git a/server/corvus/model/__init__.py b/server/corvus/model/__init__.py new file mode 100644 index 0000000..395b14b --- /dev/null +++ b/server/corvus/model/__init__.py @@ -0,0 +1 @@ +from corvus.model.user_model import User, UserToken diff --git a/server/atheneum/model/user_model.py b/server/corvus/model/user_model.py similarity index 98% rename from server/atheneum/model/user_model.py rename to server/corvus/model/user_model.py index ce839e0..5daec09 100644 --- a/server/atheneum/model/user_model.py +++ b/server/corvus/model/user_model.py @@ -1,4 +1,4 @@ -from atheneum import db +from corvus import db class User(db.Model): diff --git a/server/atheneum/service/__init__.py b/server/corvus/service/__init__.py similarity index 100% rename from server/atheneum/service/__init__.py rename to server/corvus/service/__init__.py diff --git a/server/atheneum/service/authentication_service.py b/server/corvus/service/authentication_service.py similarity index 94% rename from server/atheneum/service/authentication_service.py rename to server/corvus/service/authentication_service.py index d859be1..060af6e 100644 --- a/server/atheneum/service/authentication_service.py +++ b/server/corvus/service/authentication_service.py @@ -5,8 +5,8 @@ from typing import Optional, Tuple from nacl import pwhash from nacl.exceptions import InvalidkeyError -from atheneum.model import User, UserToken -from atheneum.service import user_service, user_token_service +from corvus.model import User, UserToken +from corvus.service import user_service, user_token_service def generate_token() -> uuid.UUID: diff --git a/server/atheneum/service/user_service.py b/server/corvus/service/user_service.py similarity index 91% rename from server/atheneum/service/user_service.py rename to server/corvus/service/user_service.py index dd96b81..a3031f1 100644 --- a/server/atheneum/service/user_service.py +++ b/server/corvus/service/user_service.py @@ -1,9 +1,9 @@ from datetime import datetime from typing import Optional -from atheneum import app, db -from atheneum.model import User -from atheneum.service import authentication_service +from corvus import app, db +from corvus.model import User +from corvus.service import authentication_service def register(name: str, password: str, role: str) -> User: diff --git a/server/atheneum/service/user_token_service.py b/server/corvus/service/user_token_service.py similarity index 92% rename from server/atheneum/service/user_token_service.py rename to server/corvus/service/user_token_service.py index 65b4dad..2704108 100644 --- a/server/atheneum/service/user_token_service.py +++ b/server/corvus/service/user_token_service.py @@ -1,9 +1,9 @@ from datetime import datetime from typing import Optional -from atheneum import db -from atheneum.model import User, UserToken -from atheneum.service import authentication_service +from corvus import db +from corvus.model import User, UserToken +from corvus.service import authentication_service def create( diff --git a/server/atheneum/utility.py b/server/corvus/utility.py similarity index 100% rename from server/atheneum/utility.py rename to server/corvus/utility.py diff --git a/server/entrypoint.sh b/server/entrypoint.sh index 033507e..6f41948 100755 --- a/server/entrypoint.sh +++ b/server/entrypoint.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash # Migrate the Database -FLASK_APP=atheneum:app flask db upgrade +FLASK_APP=corvus:app flask db upgrade # Make sure an administrator is registered python manage.py user register-admin # Start the application -gunicorn -b 0.0.0.0:8080 atheneum:app \ No newline at end of file +gunicorn -b 0.0.0.0:8080 corvus:app \ No newline at end of file diff --git a/server/manage.py b/server/manage.py index cb8d238..02086e6 100644 --- a/server/manage.py +++ b/server/manage.py @@ -7,9 +7,9 @@ from os import path import click from click import Context -from atheneum import app -from atheneum.model import User -from atheneum.service import user_service +from corvus import app +from corvus.model import User +from corvus.service import user_service logging.basicConfig() @@ -71,7 +71,7 @@ def register_user( def register_admin_user(ctx: Context): admin_users = User.query.filter_by(role=User.ROLE_ADMIN).all() if len(admin_users) == 0: - name = 'atheneum_administrator' + name = 'corvus_administrator' password = ''.join( random.choices(string.ascii_letters + string.digits, k=32)) ctx.invoke( diff --git a/server/run_tests.sh b/server/run_tests.sh index e770818..32966d0 100755 --- a/server/run_tests.sh +++ b/server/run_tests.sh @@ -3,7 +3,7 @@ set -e set -x -pycodestyle atheneum tests -mypy atheneum tests -PYTHONPATH=$(pwd) coverage run --source atheneum -m pytest +pycodestyle corvus tests +mypy corvus tests +PYTHONPATH=$(pwd) coverage run --source corvus -m pytest coverage report --fail-under=85 -m --skip-covered \ No newline at end of file diff --git a/server/server.iml b/server/server.iml deleted file mode 100644 index 8fc9fb7..0000000 --- a/server/server.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/server/setup.py b/server/setup.py index 8abfb43..c812472 100644 --- a/server/setup.py +++ b/server/setup.py @@ -1,10 +1,10 @@ from setuptools import setup setup( - name='atheneum', - packages=['atheneum'], + name='corvus', + packages=['corvus'], include_package_data=True, install_requires=[ 'flask', ], -) \ No newline at end of file +) diff --git a/server/tests/api/test_decorators.py b/server/tests/api/test_decorators.py index cf1ed57..440ce44 100644 --- a/server/tests/api/test_decorators.py +++ b/server/tests/api/test_decorators.py @@ -2,8 +2,8 @@ from typing import Any from flask import Response, Flask -from atheneum.api.decorators import return_json -from atheneum.api.model import APIResponse +from corvus.api.decorators import return_json +from corvus.api.model import APIResponse @return_json diff --git a/server/tests/conftest.py b/server/tests/conftest.py index c14305d..35b786b 100644 --- a/server/tests/conftest.py +++ b/server/tests/conftest.py @@ -10,9 +10,9 @@ from flask import Flask from flask.testing import FlaskClient, FlaskCliRunner from werkzeug.test import Client -from atheneum import create_app, init_db, register_blueprints -from atheneum.model import User -from atheneum.service import user_service +from corvus import create_app, init_db, register_blueprints +from corvus.model import User +from corvus.service import user_service def add_test_user() -> Tuple[str, str]: diff --git a/server/tests/middleware/test_authentication_middleware.py b/server/tests/middleware/test_authentication_middleware.py index d962df0..17929b0 100644 --- a/server/tests/middleware/test_authentication_middleware.py +++ b/server/tests/middleware/test_authentication_middleware.py @@ -1,9 +1,9 @@ from mock import patch, MagicMock, Mock -from atheneum.middleware.authentication_middleware import \ +from corvus.middleware.authentication_middleware import \ authenticate_with_password, authenticate_with_token -middleware_module = 'atheneum.middleware.authentication_middleware' +middleware_module = 'corvus.middleware.authentication_middleware' @patch(middleware_module + '.g')