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
2 changes: 1 addition & 1 deletion tests/fixtures/policy_stores.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pytest
from images import cedar_image, opa_image
from testcontainers.core.network import Network

from tests.containers.cedar_container import CedarContainer
from tests.containers.opa_container import OpaContainer, OpaSettings
from tests.containers.settings.cedar_settings import CedarSettings
from tests.fixtures.images import cedar_image, opa_image


@pytest.fixture(scope="session")
Expand Down
2 changes: 2 additions & 0 deletions tests/genopalkeys.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This is utility script to generate OPAL keys - Use it for your needs

# This function generates a pair of RSA keys using ssh-keygen, extracts the public key into OPAL_AUTH_PUBLIC_KEY,
# formats the private key by replacing newlines with underscores and stores it in OPAL_AUTH_PRIVATE_KEY,
# and then removes the key files. It outputs messages indicating the start and completion of key generation.
Expand Down
7 changes: 4 additions & 3 deletions tests/install_opal.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# This is a helper script to install opal-server and opal-client

# Installs opal-server and opal-client using pip.
# If the installation fails or the commands are not available,
# it exits with an error message.
# Installs opal-server and opal-client using pip.
# If the installation fails or the commands are not available,
# it exits with an error message.

function install_opal_server_and_client {
echo "- Installing opal-server and opal-client from pip..."
Expand Down
26 changes: 0 additions & 26 deletions tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,8 @@ if [[ -f ".env" ]]; then
source .env
fi


# Deletes pytest-generated .env files so they don't interfere with other tests.
function cleanup {

PATTERN="pytest_[a-f,0-9]*.env"
echo "Looking for auto-generated .env files matching pattern '$PATTERN'..."

for file in $PATTERN; do
if [[ -f "$file" ]]; then
echo "Deleting file: $file"
rm "$file"
else
echo "No matching files found for pattern '$PATTERN'."
break
fi
done

echo "Cleanup complete!\n"
}

function main {

# Cleanup before starting, maybe some leftovers from previous runs
cleanup

echo "Running tests..."

# Check if a specific test is provided
Expand All @@ -43,9 +20,6 @@ function main {
fi

echo "Done!"

# Cleanup at the end
cleanup
}

main "$@"
9 changes: 7 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ def build_docker_image(docker_file: str, image_name: str, session_matrix: dict):
image = docker_client.images.get(image_name)

if not image:
# context_path=os.path.join(os.path.dirname(__file__), ".."), # Expands the context
context_path = ".."
if "tests" in os.path.abspath(__file__):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use pathlib instead, as its clearer and more modern

logger.info(f"Right now the file is {os.path.abspath(__file__)}")
context_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), "..", "..", "opal")
)
else:
context_path = ".."
dockerfile_path = os.path.join(os.path.dirname(__file__), "docker", docker_file)
logger.info(f"Context path: {context_path}, Dockerfile path: {dockerfile_path}")

Expand Down