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

E2E Tests version 1.0 #731

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
"runArgs": ["--name", "OAPL-DEV"],
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}

},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "/bin/bash .devcontainer/setup.sh",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
20 changes: 20 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

if [ -d ".venv" ]; then
echo "Virtual environment already exists"
else
python3 -m venv .venv
fi
source .venv/bin/activate

apt-get update && apt-get install -y git

pip install --upgrade pip
pip3 install --user -r requirements.txt

cd tests
pip3 install --user -r requirements.txt

pip install pre-commit
pre-commit install
pre-commit run --all-files
80 changes: 42 additions & 38 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
# Byte-compiled / optimized / DLL files
# OPAL specific
opal_test_keys/*
.env
opal-example-policy-repo/*
data/
OPAL_DATASOURCE_TOKEN.tkn
OPAL_CLIENT_TOKEN.tkn

# Temporary and Python cache files
**/*.pyc
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Virtual environments
.venv/
venv/
env/
ENV/
env.bak/
venv.bak/

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
Expand All @@ -18,7 +34,6 @@ lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
Expand All @@ -27,16 +42,14 @@ share/python-wheels/
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# PyInstaller
*.manifest
*.spec

# Unit test / coverage reports
htmlcov/
.tox/
Expand All @@ -50,22 +63,23 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
new_pytest_env/temp

# Translations
*.mo
*.pot

# Django stuff:
# Django
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
# Flask
instance/
.webassets-cache

# Scrapy stuff:
# Scrapy
.scrapy

# Sphinx documentation
Expand All @@ -84,53 +98,43 @@ ipython_config.py
# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
# Pipenv
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
# PEP 582
__pypackages__/

# Celery stuff
# Celery
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
# SageMath
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Editors
.vscode/
.idea
*.iml

# Spyder project settings
# Spyder
.spyderproject
.spyproject

# Rope project settings
# Rope
.ropeproject

# mkdocs documentation
/site
# mkdocs
docs/_build/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
# Pyre
.pyre/

# editors
.vscode/
.idea
*.iml

# System files
.DS_Store
pytest_6dbc.env
tests/pytest_1a09.env
40 changes: 40 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Remote to local",
"type": "debugpy",
"request": "attach",
"justMyCode": false,
"subProcess": true,
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "${cwd}"
}
]
},
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Debug with Args",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"args": [
"--deploy",
"--with_broadcast",
],
"console": "integratedTerminal"
}
]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"cmake.ignoreCMakeListsMissing": true,
"makefile.configureOnOpen": false,
"python.analysis.extraPaths": [
"./packages/opal-common"
]
}
23 changes: 15 additions & 8 deletions app-tests/docker-compose-app-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

services:

broadcast_channel:
image: postgres:alpine
environment:
Expand All @@ -7,15 +9,19 @@ services:
- POSTGRES_PASSWORD=postgres

opal_server:
image: permitio/opal-server:${OPAL_IMAGE_TAG:-latest}
#image: permitio/opal-server:${OPAL_IMAGE_TAG:-latest}
build:
context: ../ # Point to the directory containing your Dockerfile
dockerfile: ./docker/Dockerfile.server # Specify your Dockerfile if it's not named 'Dockerfile'
deploy:
mode: replicated
replicas: 2
replicas: 1
endpoint_mode: vip
environment:
- OPAL_BROADCAST_URI=postgres://postgres:postgres@broadcast_channel:5432/postgres
- UVICORN_NUM_WORKERS=4
- OPAL_POLICY_REPO_URL=${OPAL_POLICY_REPO_URL:[email protected]:permitio/opal-tests-policy-repo.git}
- UVICORN_NUM_WORKERS=0
#- OPAL_POLICY_REPO_URL=${OPAL_POLICY_REPO_URL:[email protected]:permitio/opal-tests-policy-repo.git}
- OPAL_POLICY_REPO_URL=${OPAL_POLICY_REPO_URL:[email protected]:permitio/opal-example-policy-repo.git}
- OPAL_POLICY_REPO_MAIN_BRANCH=${POLICY_REPO_BRANCH}
- OPAL_POLICY_REPO_SSH_KEY=${OPAL_POLICY_REPO_SSH_KEY}
- OPAL_DATA_CONFIG_SOURCES={"config":{"entries":[{"url":"http://opal_server:7002/policy-data","config":{"headers":{"Authorization":"Bearer ${OPAL_CLIENT_TOKEN}"}},"topics":["policy_data"],"dst_path":"/static"}]}}
Expand All @@ -35,9 +41,10 @@ services:

opal_client:
image: permitio/opal-client:${OPAL_IMAGE_TAG:-latest}
scale: 0
deploy:
mode: replicated
replicas: 2
replicas: 0
endpoint_mode: vip
environment:
- OPAL_SERVER_URL=http://opal_server:7002
Expand All @@ -50,9 +57,9 @@ services:
- OPAL_AUTH_JWT_AUDIENCE=https://api.opal.ac/v1/
- OPAL_AUTH_JWT_ISSUER=https://opal.ac/
- OPAL_STATISTICS_ENABLED=true
ports:
- "7766-7767:7000"
- "8181-8182:8181"
#ports:
# - "7766-7767:7000"
# - "8181-8182:8181"
depends_on:
- opal_server
command: sh -c "exec ./wait-for.sh opal_server:7002 --timeout=20 -- ./start.sh"
1 change: 1 addition & 0 deletions app-tests/jwks_dir/jwks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"keys": [{"kty": "RSA", "key_ops": ["verify"], "n": "3HYeEOlS7BXR4x0klclD909fcrjyr4Jkmuixfl8cRmS7q3LPIsl1hIueKK0qBLjc7jIUsPCUEoJTIwMcdFfPQnViexerdx_ekupUwR0IFRzJli5wG0cYW5UkKOKDaXRrN0cnOQLZ_48ol6aEki8lkbGNYmaGtqrNTHsKA8uEP8S7AKnFqseTHJPhKAGzeeFKjWD4wAR0dgXkixLVxcAFohP-WR68oWPlrRnkBfb3ovRgQpo0UVWnjY99DJu9KZCaCGhSyjP42kjY65PykFmWHRUTltfMq7dkGkKuIOn_0YEVFoGhTda934vDqZO2EXgjj2lTCpYkVNK_WsL8ILIeCHEnK2ZYnxl4BgKLOHu2xyk6U4i8VjYpJo0U9UDcvNHaIuPNTxs0LNr1VtSVLxvZHDZ8f0UnmElgSGnAHj1cFamT-erIfIFfSuhzJ2qwcA30Y1B6EO8bBrQ2YgSWm8CNJO9FqWkEK0SPb3xw64KSnGtuAbBpVoNvK8AeHT7m9-11QtS7PWUiUGkSGKtTMlsvz90hb-rbFBIRcDuP2NG6BfoFq-rbcX9A2Djqhpxi6Zfr_5s7GN95UTbUKCLau3jvgTwdSxjCPsiE9t1phlWmTwp_eC8uYVriSPwiQ4ZqBIUE3Gz1PikqRJCt2E2KFMiHjSwlEPMtrbPwnO1B0G1ZXk8", "e": "AQAB"}]}
Loading