Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add authentication #7

Merged
merged 7 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ style_checks:
poetry run pydocstyle -v

tests:
@rm -f .tmp.pid coverage.lcov data_services.db
poetry run pytest
poetry run coverage run -a -m sanic --debug --single-process renku_crac.main:create_app --factory & echo $$! > .tmp.pid
@rm -f .tmp.pid coverage.lcov .coverage data_services.db
-poetry run pytest
DUMMY_STORES=true poetry run coverage run -a -m sanic --debug --single-process renku_crac.main:create_app --factory & echo $$! > .tmp.pid
@sleep 10
-poetry run st run http://localhost:8000/api/data/spec.json --validate-schema True --checks all --hypothesis-max-examples 20 --data-generation-method all --show-errors-tracebacks --hypothesis-suppress-health-check data_too_large --max-response-time 100 -v
-poetry run st run http://localhost:8000/api/data/spec.json --validate-schema True --checks all --hypothesis-max-examples 20 --data-generation-method all --show-errors-tracebacks --hypothesis-suppress-health-check data_too_large --max-response-time 100 -v --header "Authorization: bearer some-random-key-123456"
cat .tmp.pid | xargs kill
@rm -f .tmp.pid
@echo "===========================================FINAL COMBINED COVERAGE FOR ALL TESTS==========================================="
poetry run coverage report
poetry run coverage report --show-missing
poetry run coverage lcov -o coverage.lcov

pre_commit_checks:
poetry run pre-commit run --all-files
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ A set of services that handle reading and writing data from Postgres about compu

1. `poetry install`
2. `pre-commit install` to install pre commit hooks
4. `make migrations` to execute any outstanding database migrations
3. `poetry run python src/renku_crac/main.py --debug --dev --fast`
3. `DUMMY_STORES=true poetry run python src/renku_crac/main.py --debug --dev --fast`

## Developing

1. Write code
2. Run tests: `make tests`
3. Style checks: `make style_checks`
4. Run schemathesis by first running the server and then executing `make schemathesis`
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""Create tables

Revision ID: f52872eca13f
Revision ID: f31087d667f3
Revises:
Create Date: 2023-05-02 23:35:56.698082
Create Date: 2023-05-09 00:13:12.542679

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "f52872eca13f"
revision = "f31087d667f3"
down_revision = None
branch_labels = None
depends_on = None
Expand All @@ -21,9 +21,11 @@ def upgrade() -> None:
op.create_table(
"resource_pools",
sa.Column("name", sa.String(length=40), nullable=False),
sa.Column("default", sa.Boolean(), nullable=False),
sa.Column("id", sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(op.f("ix_resource_pools_default"), "resource_pools", ["default"], unique=False)
op.create_index(op.f("ix_resource_pools_name"), "resource_pools", ["name"], unique=False)
op.create_table(
"users",
Expand Down Expand Up @@ -88,5 +90,6 @@ def downgrade() -> None:
op.drop_index(op.f("ix_users_keycloak_id"), table_name="users")
op.drop_table("users")
op.drop_index(op.f("ix_resource_pools_name"), table_name="resource_pools")
op.drop_index(op.f("ix_resource_pools_default"), table_name="resource_pools")
op.drop_table("resource_pools")
# ### end Alembic commands ###
169 changes: 168 additions & 1 deletion poetry.lock

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ datamodel-code-generator = "^0.17.2"
sqlalchemy = {extras = ["asyncio"], version = "^2.0.9"}
alembic = "^1.10.3"
asyncpg = "^0.27.0"
pyjwt = {extras = ["crypto"], version = "^2.6.0"}
tenacity = "^8.2.2"

[tool.poetry.group.dev.dependencies]
bandit = "^1.7.5"
Expand Down Expand Up @@ -75,7 +77,7 @@ exclude = [
]

[tool.pytest.ini_options]
addopts = "--black --cov src/ --cov-report=term-missing --cov-report lcov -v"
addopts = "--black --cov src/ --cov-report=term-missing -v"
doctest_optionflags = "ALLOW_UNICODE"
testpaths = ["src", "tests"]
markers = [
Expand Down Expand Up @@ -112,6 +114,3 @@ ignore_missing_imports = true

[tool.coverage.run]
source = [ "src/" ]

[tool.coverage.lcov]
output = "coverage.lcov"