Browse Source

Renamed from Atheneum to Corvus

merge-requests/1/merge
Drew Short 7 years ago
parent
commit
349fd14570
  1. 1
      .gitignore
  2. 6
      .gitlab-ci.yml
  3. 22
      Dockerfile
  4. 2
      server/.env
  5. 1
      server/atheneum/api/__init__.py
  6. 1
      server/atheneum/model/__init__.py
  7. 18
      server/corvus/__init__.py
  8. 1
      server/corvus/api/__init__.py
  9. 8
      server/corvus/api/authentication_api.py
  10. 2
      server/corvus/api/decorators.py
  11. 0
      server/corvus/api/model.py
  12. 0
      server/corvus/default_settings.py
  13. 0
      server/corvus/middleware/__init__.py
  14. 2
      server/corvus/middleware/authentication_middleware.py
  15. 1
      server/corvus/model/__init__.py
  16. 2
      server/corvus/model/user_model.py
  17. 0
      server/corvus/service/__init__.py
  18. 4
      server/corvus/service/authentication_service.py
  19. 6
      server/corvus/service/user_service.py
  20. 6
      server/corvus/service/user_token_service.py
  21. 0
      server/corvus/utility.py
  22. 4
      server/entrypoint.sh
  23. 8
      server/manage.py
  24. 6
      server/run_tests.sh
  25. 12
      server/server.iml
  26. 6
      server/setup.py
  27. 4
      server/tests/api/test_decorators.py
  28. 6
      server/tests/conftest.py
  29. 4
      server/tests/middleware/test_authentication_middleware.py

1
.gitignore

@ -1,5 +1,6 @@
instance/ instance/
.idea .idea
*.iml
.admin_credentials .admin_credentials
*__pycache__/ *__pycache__/
.pytest_cache/ .pytest_cache/

6
.gitlab-ci.yml

@ -11,9 +11,9 @@ Atheneum:Tests:
- python3 -m pipenv --version - python3 -m pipenv --version
- cd server - cd server
- pipenv install --dev --system - 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 - coverage report --fail-under=85 -m --skip-covered
tags: tags:
- docker - docker

22
Dockerfile

@ -1,23 +1,23 @@
FROM python:3.6-slim-stretch FROM python:3.6-slim-stretch
MAINTAINER Drew Short <warrick@sothr.com> MAINTAINER Drew Short <warrick@sothr.com>
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 && 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 && pipenv install --system --deploy --ignore-pipfile
WORKDIR ${ATHENEUM_APP_DIRECTORY}
WORKDIR ${CORVUS_APP_DIRECTORY}
CMD ./entrypoint.sh CMD ./entrypoint.sh

2
server/.env

@ -1 +1 @@
FLASK_APP=atheneum
FLASK_APP=corvus

1
server/atheneum/api/__init__.py

@ -1 +0,0 @@
from atheneum.api.authentication_api import auth_blueprint

1
server/atheneum/model/__init__.py

@ -1 +0,0 @@
from atheneum.model.user_model import User, UserToken

18
server/atheneum/__init__.py → server/corvus/__init__.py

@ -5,7 +5,7 @@ from flask import Flask
from flask_migrate import Migrate, upgrade from flask_migrate import Migrate, upgrade
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from atheneum import utility
from corvus import utility
db: SQLAlchemy = SQLAlchemy() db: SQLAlchemy = SQLAlchemy()
@ -28,12 +28,12 @@ dictConfig({
def create_app(test_config: dict = None) -> Flask: def create_app(test_config: dict = None) -> Flask:
app = Flask(__name__, instance_relative_config=True) 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( app.config.from_mapping(
SECRET_KEY='dev', SECRET_KEY='dev',
SQLALCHEMY_DATABASE_URI=default_database_uri, SQLALCHEMY_DATABASE_URI=default_database_uri,
@ -42,10 +42,10 @@ def create_app(test_config: dict = None) -> Flask:
if test_config is None: if test_config is None:
app.logger.debug('Loading configurations') 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) 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: else:
app.logger.debug('Loading test configuration') app.logger.debug('Loading test configuration')
app.config.from_object(test_config) app.config.from_object(test_config)
@ -66,7 +66,7 @@ def create_app(test_config: dict = None) -> Flask:
def register_blueprints(app: Flask) -> None: def register_blueprints(app: Flask) -> None:
from atheneum.api import auth_blueprint
from corvus.api import auth_blueprint
app.register_blueprint(auth_blueprint) app.register_blueprint(auth_blueprint)

1
server/corvus/api/__init__.py

@ -0,0 +1 @@
from corvus.api.authentication_api import auth_blueprint

8
server/atheneum/api/authentication_api.py → server/corvus/api/authentication_api.py

@ -1,9 +1,9 @@
from flask import Blueprint, g 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( auth_blueprint = Blueprint(
name='auth', import_name=__name__, url_prefix='/auth') name='auth', import_name=__name__, url_prefix='/auth')

2
server/atheneum/api/decorators.py → server/corvus/api/decorators.py

@ -3,7 +3,7 @@ from typing import Callable, Any
from flask import jsonify, Response from flask import jsonify, Response
from atheneum.api.model import APIResponse
from corvus.api.model import APIResponse
def return_json(func: Callable) -> Callable: def return_json(func: Callable) -> Callable:

0
server/atheneum/api/model.py → server/corvus/api/model.py

0
server/atheneum/default_settings.py → server/corvus/default_settings.py

0
server/atheneum/middleware/__init__.py → server/corvus/middleware/__init__.py

2
server/atheneum/middleware/authentication_middleware.py → server/corvus/middleware/authentication_middleware.py

@ -6,7 +6,7 @@ from flask import request, Response, g
from werkzeug.datastructures import Authorization from werkzeug.datastructures import Authorization
from werkzeug.http import bytes_to_wsgi, wsgi_to_bytes from werkzeug.http import bytes_to_wsgi, wsgi_to_bytes
from atheneum.service import (
from corvus.service import (
authentication_service, authentication_service,
user_service, user_service,
user_token_service user_token_service

1
server/corvus/model/__init__.py

@ -0,0 +1 @@
from corvus.model.user_model import User, UserToken

2
server/atheneum/model/user_model.py → server/corvus/model/user_model.py

@ -1,4 +1,4 @@
from atheneum import db
from corvus import db
class User(db.Model): class User(db.Model):

0
server/atheneum/service/__init__.py → server/corvus/service/__init__.py

4
server/atheneum/service/authentication_service.py → server/corvus/service/authentication_service.py

@ -5,8 +5,8 @@ from typing import Optional, Tuple
from nacl import pwhash from nacl import pwhash
from nacl.exceptions import InvalidkeyError 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: def generate_token() -> uuid.UUID:

6
server/atheneum/service/user_service.py → server/corvus/service/user_service.py

@ -1,9 +1,9 @@
from datetime import datetime from datetime import datetime
from typing import Optional 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: def register(name: str, password: str, role: str) -> User:

6
server/atheneum/service/user_token_service.py → server/corvus/service/user_token_service.py

@ -1,9 +1,9 @@
from datetime import datetime from datetime import datetime
from typing import Optional 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( def create(

0
server/atheneum/utility.py → server/corvus/utility.py

4
server/entrypoint.sh

@ -1,10 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Migrate the Database # Migrate the Database
FLASK_APP=atheneum:app flask db upgrade
FLASK_APP=corvus:app flask db upgrade
# Make sure an administrator is registered # Make sure an administrator is registered
python manage.py user register-admin python manage.py user register-admin
# Start the application # Start the application
gunicorn -b 0.0.0.0:8080 atheneum:app
gunicorn -b 0.0.0.0:8080 corvus:app

8
server/manage.py

@ -7,9 +7,9 @@ from os import path
import click import click
from click import Context 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() logging.basicConfig()
@ -71,7 +71,7 @@ def register_user(
def register_admin_user(ctx: Context): def register_admin_user(ctx: Context):
admin_users = User.query.filter_by(role=User.ROLE_ADMIN).all() admin_users = User.query.filter_by(role=User.ROLE_ADMIN).all()
if len(admin_users) == 0: if len(admin_users) == 0:
name = 'atheneum_administrator'
name = 'corvus_administrator'
password = ''.join( password = ''.join(
random.choices(string.ascii_letters + string.digits, k=32)) random.choices(string.ascii_letters + string.digits, k=32))
ctx.invoke( ctx.invoke(

6
server/run_tests.sh

@ -3,7 +3,7 @@
set -e set -e
set -x 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 coverage report --fail-under=85 -m --skip-covered

12
server/server.iml

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/atheneum" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
server/setup.py

@ -1,10 +1,10 @@
from setuptools import setup from setuptools import setup
setup( setup(
name='atheneum',
packages=['atheneum'],
name='corvus',
packages=['corvus'],
include_package_data=True, include_package_data=True,
install_requires=[ install_requires=[
'flask', 'flask',
], ],
)
)

4
server/tests/api/test_decorators.py

@ -2,8 +2,8 @@ from typing import Any
from flask import Response, Flask 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 @return_json

6
server/tests/conftest.py

@ -10,9 +10,9 @@ from flask import Flask
from flask.testing import FlaskClient, FlaskCliRunner from flask.testing import FlaskClient, FlaskCliRunner
from werkzeug.test import Client 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]: def add_test_user() -> Tuple[str, str]:

4
server/tests/middleware/test_authentication_middleware.py

@ -1,9 +1,9 @@
from mock import patch, MagicMock, Mock from mock import patch, MagicMock, Mock
from atheneum.middleware.authentication_middleware import \
from corvus.middleware.authentication_middleware import \
authenticate_with_password, authenticate_with_token authenticate_with_password, authenticate_with_token
middleware_module = 'atheneum.middleware.authentication_middleware'
middleware_module = 'corvus.middleware.authentication_middleware'
@patch(middleware_module + '.g') @patch(middleware_module + '.g')

Loading…
Cancel
Save