Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
Импорт изменений для стабильной версии 0.2.0 (#164)
Browse files Browse the repository at this point in the history
* Updating Python to version 3.10 (#122)

also updated uvicorn, fastapi, jinja2, websockets

* Переход на python 3.10 (замена If-Else на Match-Case) и переделка системы генерации ошибок (#123)

* feat(error): error dictionary is replaced by the function 

new function "check_error_pattern" checking the error status against the class HTTPStatus or ServerStatus

* fix(controller): error codes are replaced by their text descriptions

* feat(test_error): added new test for error.py

* fix(error): "check_error_pattern" function has been fixed

* fix(test_error): minor edits to the test code

* refactor: minor changes

* BREAKING CHANGE(controller): if-else is replaced by match-case

- the "check_auth_token function" is converted into decorator
- methods requiring user authentication wrapped in "check_auth_token" decorator

* feat(controller): Added new classes Error and User

- the __catch_error method functionality will be moved to the Error class
- the __check_auth_token method functionality will be moved to the User class
- minor changes

* fix(test_controller) fixed tests "check_auth" class method

* fix(test_controller): fixed all tests in class TestCheckAuthToken

* feat(controller): the check_login method has been moved to the User class

* refactor(test): small corrections in the code

* fix(controller) Fixed bug in UUID generation for flow

* refactor: minor changes

* Изменения для выполнения тикетов #98 #50 (#124)

* fix(test): added client_id in "api.json"

* fix(api): validation is enabled

a separate validation class for requests and responses is added

* BREAKING CHANGE(controller): methods and "Errors" class have been changed

- to all methods of the class, the passed parameter "request", and the returned object "response" are added.
- the "catching_error" method now returns "api.Errors" object
- the "get_response" method now returns a validated json object.

* BREAKING CHANGE(api): separate validation for requests and responses

* refactor(controller): renaming calls to instances of classes responsible

 for validating queries and responses

* fix(test): fixed in test_api

* fix(controller): small corrections

* fix(api) small corrections in the declaration of "data" and "client_id"

* fix(test): test fixes after modifying controller.py

* Исправления в системе тестирования кода, закрытие тикетов #125 #126 #101 #100 (#127)

* feat(test_api): added  test for wrong json
* feat(test): added test for wrong response and request and added new fixtures for tests
* feat(test): New tests for validation have been added
* fix(error): corrected the "check_error_pattern" function
- added exception catching related to wrong type of "status" parameter and a non-existent error name
* fix(test): Fixed tests for the "check_error_pattern" function
* refactor(test): remove unused import
* refactor(lib): minor changes
* fix(test): added cleint_id in fixtures
* fix(test): code readability improved
* fix(lib): added decorator property
* feat(test): added new test
- checking false status in password_check
- checking get_key and get_salt
* fix(test): Move the test JSON objects
from the test_controller.py file to the directory with the fixtures.
* fix(controller): the class method call is replaced by the attribute
* refactor(test): delete unused object
* feat(config): added setup.cfg to configure flake8 and coverage
* fix(test): minor changes
* feat(setup.cfg): the skip test setting has been added for coverage
* fix(api): delete print scheme
* fix(controller): small improvements to increase code coverage by tests
* fix(pipfile): update dependencies
* fix(pipfile) added coverage to pipfile.lock

* Добавлена панель администратора (#129)

* init admin

* add logging uvicorn setting

* add bootstrap in admin

* add fastapi-login libary in pipfile

* add login.py

* fix

* fix

* fix cookies

* add logout and exception handler

* fix bug login exception

* add login form

* fix bug

* fix

* fix bug

* add status.html

* add logs view

* add delete user

* fix

* refactoring manage.py and change password to hashPassword

* Squashed commit of the following:

commit 33d192f
Author: Stepan Skriabin <[email protected]>
Date:   Tue Oct 26 20:40:42 2021 +0300

    Исправления в системе тестирования кода, закрытие тикетов #125 #126 #101 #100 (#127)

    * feat(test_api): added  test for wrong json
    * feat(test): added test for wrong response and request and added new fixtures for tests
    * feat(test): New tests for validation have been added
    * fix(error): corrected the "check_error_pattern" function
    - added exception catching related to wrong type of "status" parameter and a non-existent error name
    * fix(test): Fixed tests for the "check_error_pattern" function
    * refactor(test): remove unused import
    * refactor(lib): minor changes
    * fix(test): added cleint_id in fixtures
    * fix(test): code readability improved
    * fix(lib): added decorator property
    * feat(test): added new test
    - checking false status in password_check
    - checking get_key and get_salt
    * fix(test): Move the test JSON objects
    from the test_controller.py file to the directory with the fixtures.
    * fix(controller): the class method call is replaced by the attribute
    * refactor(test): delete unused object
    * feat(config): added setup.cfg to configure flake8 and coverage
    * fix(test): minor changes
    * feat(setup.cfg): the skip test setting has been added for coverage
    * fix(api): delete print scheme
    * fix(controller): small improvements to increase code coverage by tests
    * fix(pipfile): update dependencies
    * fix(pipfile) added coverage to pipfile.lock

* merge develop into this banch

* fix

* add license notification in new file

* fix

* Update Pipfile.lock

* fix

* fix

* fix typehintings

* fix

* fix test_admin.py

* fix config example

* fix

* fix naming log_list to log_string

* change name manage.py to control.py

* Добавление дополнительной абстракции для работы с бд #128 (#136)

* feat(dbhandlers): add new class DbHelpers for work with database
* fix(dbhandler): Added an indication of type of returned data
* feat(dbhandler): added new error exceptions and new attribute
* feat(dbhandler): additional methods to the class
- added __repr__ and __str__
- added methods with date filtering (more, less or equal)
- small changes in code readability

* feat(dbhandler): added new property "debug"
- added new attribute - debug, logger, loglevel

* Реализация единой точки обработки конфигурационного файла (#137)

* feat: added config.py as a single point to read settings from config.ini
* fix(dbhandler): Fixed an error in writing table fields from parameters passed to the method

* Разделение кода протокола и контроллера #139 (#141)

* feat(controller): Creating the MainHandler method in which the protocol selection is implemented
-- main code from controller moved to worker.py of the mtp module
-- api.py is now part of the mtp module
-- added the matrix module as a stub

* BREAKING CHANGE(error): result of check_error_pattern function is now replaced by namedtuple
* feat(server): fixed name ProtocolMethod to MainHandler
* fix(tests): fixed file name
* feat(tests): new test fo controller.py
* fix(server): fixed type of response object
* fix(controller): added get_response method
fixed types returned in mtp_handler and matrix_handler
* fix(mtp.worker): fixed catch_error object in MTPErrorResponse
* fix(fixtures): fixed name in type
* fix(fixtures): fixed test
- rename ProtocolMethods to MTProtocol
- rename ErrorResponse to MTPErrorResponse
* fix(dbhandler): removed the default parameter with the database address
* fix(dbhandler): fixed default parameter to 'sqlite:/:memory:'
* fix(controller): Copyright's year is corrected

* Небольшие правки кода перед переносов в мастер и релизом версии 0.1.0 (#143)

* feat(contoller): added class Clients for collect clients session
* fix(server): the ability to account for connected clients has been completely removed
* fix: added ebala
* fix: minor changes and error fixed
* fix(controller): added docstring for MainHandler
* fix(dbhandler): added docstring for DBHandler and minor changes in methods
* fix(server): fixed bugs in static directory
* fix(mtp): fixed errors
* feat(tests): added one test for MatrixProtocol
* fix(setup.cfg): fixed name
* BREAKING CHANGE:(pipfile): bump'ed dependencies (fastapi, uvicorn, jinja2, websockets, pydantic, requests)
* refactor:(readme): update readme.md
* fix: fixed some errors
* fix(server): fixed type of response
* fix(client): added auth_id
* fix(readme): delete link to Trello

* delete "t.py" in .gitignore

* update Pipfile.lock and add bpython package

* delete header in example_config.ini

* fix bug #149

* fix bug #148

* fix bug #147

* Create python-app.yml

* Update and rename python-app.yml to test_and_linting.yml

* Update test_and_linting.yml

* Update test_and_linting.yml

* fix tests bugs

* Update test_and_linting.yml

* Update test_and_linting.yml

* Update test_and_linting.yml

* Update test_and_linting.yml

* add Dockerfile

* fix Dockerfile

* Create docker-image.yml

* Delete docker-image.yml

* fix bug config load

* add tests for server.py

* Update README.md

* Update test_and_linting.yml

* Update README.md

* Create docker-publish-image.yaml

* Delete docker-publish-image.yaml

* Create coveralls.yml

* Update coveralls.yml

* Delete coveralls.yml

* Update test_and_linting.yml

* Update test_and_linting.yml

* Update test_and_linting.yml

* Update README.md

* Update test_and_linting.yml

* Create docker-publish-image.yml

* Update docker-publish-image.yml

* Update docker-publish-image.yml

* Update docker-publish-image.yml

* Update docker-publish-image.yml

* Update docker-publish-image.yml

* Update docker-publish-image.yml

* Update docker-publish-image.yml

* Update docker-publish-image.yml

* Update docker-publish-image.yml

* Update docker-publish-image.yml

* Update docker-publish-image.yml

* Update docker-publish-image.yml

* Rename docker-publish-image.yml to docker-publish-image-unstable.yml

* Create docker-publish-image-stable.yml

* Update docker-publish-image-unstable.yml

* Update docker-publish-image-stable.yml

* Update docker-publish-image-stable.yml

* Update docker-publish-image-unstable.yml

* Update docker-publish-image-unstable.yml

* Update docker-publish-image-stable.yml

* Update docker-publish-image-unstable.yml

* Update docker-publish-image-unstable.yml

* feat(doc): initial commit for added documentation in project

* fixed(config): move config.py to the root of the project

* refactor(controller): delete unused imports

* feat(Pipfile): added "furo" theme and fixing package version

* fixed(Pipfile): update Pipfile.lock

* refactor(matrix): delete unused imports

* feat(sphinx): added extension module - duration, autodoc, autosummary

* feat(sphinx): added new pages development, doc, install

* feat(sphinx): added extension "napoleon" to use Google style docstring

* refactor: refactoring docstrings and fixed errors

* feat(doc): update index.rst and doc.rst which added new documentation about project

* feat(gitignore): add "log" in "docs" directory

* docs(models): correcting and expanding existing documentation

* docs(logging): correcting and expanding existing documentation

* docs(matrix): correcting and expanding existing documentation

* docs(error): correcting and expanding existing documentation

* docs(lib): correcting and expanding existing documentation

* docs(controller): correcting and expanding existing documentation

* docs(server): correcting and expanding existing documentation

* docs(mtp): correcting and expanding existing documentation

* docs(mtp): correcting and expanding existing documentation

* docs(dbhandler): correcting and expanding existing documentation

* docs(sphinx): added new documents description

* feat(sphinx): added extension which generated ".nojekyll" for GitHub Pages

* docs(readme): fixed minor errors

* docs(licence): added new licence.rst file

* docs(development): added full info about project development

* docs(install): added full info about project install and run

* docs(index): added new section "Contacts" and other minor changes

* docs(sphinx) corrected text in doc.rst

* docs(doc): minor changes

* fixed(tests): fixed minor errors

* fixed: added two modules ("db", "protocol") in init file in "mod"

* updated version of loguru to 0.6.0, fixing vulnerability CVE-2022-0329

* feat: added "revision" in MTP api and worker

* feat: added "token_ttl" in database models and dbhandler class

* feat(error): added new status code 505 "VERSION_NOT_SUPPORTED"

* fixed(tests): added new test for jsonapi and minor changes

* feat(tests): added checking new fields: "token_ttl", "client_id", "key", "salt", "revision"

* fixed(tests): added new test for jsonapi and minor changes

* feat(tests): added checking new fields: "token_ttl", "client_id", "key", "salt", "revision"

* add test main page for server.py

* fix

* fix

* fix

* Create docs.yml

* Update docs.yml

* Update docs.yml

* Update docs.yml

* Update docs.yml

* Update docs.yml

* Update docs.yml

* Update docs.yml

* Update docs.yml

* Update docs.yml

* Update docs.yml

* Update docs.yml

* Update test_and_linting.yml

* Update test_and_linting.yml

* Update test_and_linting.yml

* Update and rename test_and_linting.yml to tests.yml

* add python-coveralls in dev-dependencies and update Pipfile.lock

* Update tests.yml

* fix

* fix

* add test

* fix test

* fix test

* fix test

* Update README_ENG.md

* fix test

* fix test

* fix test

* fix docs

* fix docs

* fix docs

* fix docs

* fix docs

* fix test_server.py

* fix test_server.py

* fix test_server.py

* fix test_server.py

* fix test_server.py

* fix docs

* fix docs

Co-authored-by: Stepan Skriabin <[email protected]>
  • Loading branch information
NekrodNIK and stepanskryabin authored Feb 15, 2022
1 parent 59bd6ed commit 1b8ed0b
Show file tree
Hide file tree
Showing 42 changed files with 2,598 additions and 281 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/docker-publish-image-stable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build and publish docker image
on:
push:
tags: '*.*.*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}_stable

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
44 changes: 44 additions & 0 deletions .github/workflows/docker-publish-image-unstable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build and publish docker image
on:
push:
branches: [ develop ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}_unstable

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y.%m.%d')"

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}_${{ steps.date.outputs.date }}
labels: ${{ steps.meta.outputs.labels }}
41 changes: 41 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and push docs
on:
push:
branches: [ master, develop ]

jobs:
build-and-deploy:
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install pipenv
run: |
pip install pipenv
- name: Install dependencies
run: |
pipenv install --dev
- name: Create config for server
run: |
mv example_config.ini config.ini
- name: Build docs
run: |
cd docs
pipenv run make html
- name: Deploy
uses: JamesIves/[email protected]
with:
branch: docs
folder: ./docs/build/html/
target-folder: ${{ github.ref_name }}
36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test and Push coverage to Coveralls

on: [push, pull_request]

jobs:
tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install pipenv
run: |
pip install pipenv
- name: Install dependencies
run: |
pipenv install --dev
- name: Create config for server
run: |
mv example_config.ini config.ini
- name: Run tests
run: |
pipenv run coverage run -m unittest discover tests
- name: Push report to coveralls.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pipenv run coveralls --service=github
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,5 @@ dmypy.json
## Morelia stuff
db_sqlite.db
config.ini
t.py
ngrok.exe
/docs/log/
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# syntax=docker/dockerfile:1

FROM python:3.10.2-slim-bullseye

WORKDIR /morelia-server

COPY Pipfile Pipfile
COPY Pipfile.lock Pipfile.lock

RUN pip3 install pipenv
RUN pipenv install --ignore-pipfile

COPY example_config.ini config.ini

COPY . .

CMD [ "pipenv", "run", \
"python", "-m", \
"uvicorn", "server:app", \
"--host", "0.0.0.0", \
"--port", "8000", \
"--reload", "--use-colors", \
"--http", "h11", "--ws", "websockets" \
]
5 changes: 4 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ flake8 = "*"
pyflakes = "*"
pycodestyle = "*"
mccabe = "*"
coveralls = "==3.3.1"

[packages]
fastapi = "==0.71.0"
Expand All @@ -16,7 +17,7 @@ jinja2 = "==3.0.3"
aiofiles = "==0.7.0"
email-validator = "==1.1.3"
sqlobject = "==3.9.1"
loguru = "==0.5.3"
loguru = "==0.6.0"
websockets = "==10.1"
pydantic = "==1.9.0"
fastapi-login = "==1.7.3"
Expand All @@ -25,6 +26,8 @@ websocket-client = "==1.2.3"
coverage = "==6.2"
requests = "==2.27.1"
win32-setctime = "*"
sphinx = "==4.4.0"
furo = "==2022.1.2"

[requires]
python_version = "3.10"
Loading

0 comments on commit 1b8ed0b

Please sign in to comment.