-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
423 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
graft src/pas | ||
graft docs | ||
global-exclude *.pyc | ||
include *.md | ||
include *.txt | ||
include *.yaml | ||
include .coveragerc | ||
include Makefile | ||
recursive-include tests *.py | ||
recursive-include tests *.gitkeep | ||
recursive-include tests *.json | ||
recursive-include tests *.yml | ||
# -- | ||
include *.yml | ||
include base.cfg | ||
include bobtemplate.cfg | ||
include buildout.cfg | ||
include test_plone52.cfg | ||
include test_plone60.cfg | ||
include *.md | ||
include *.txt | ||
include *.yml | ||
recursive-include src *.gitkeep | ||
recursive-include src *.po | ||
recursive-include src *.pot | ||
recursive-include src *.robot | ||
recursive-include src *.rst | ||
recursive-include src *.sh | ||
recursive-include src *.xml | ||
recursive-include src *.zcml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,42 @@ | ||
from plone.app.robotframework.testing import REMOTE_LIBRARY_BUNDLE_FIXTURE | ||
from plone.app.testing import applyProfile | ||
from plone.app.testing import FunctionalTesting | ||
from plone.app.testing import IntegrationTesting | ||
from plone.app.testing import PLONE_FIXTURE | ||
from plone.app.testing import PloneSandboxLayer | ||
from plone.testing import z2 | ||
from plone.testing.zope import WSGI_SERVER_FIXTURE | ||
|
||
import pas.plugins.passwordstrength | ||
|
||
|
||
class PasPluginsPasswordstrengthLayer(PloneSandboxLayer): | ||
class TestLayer(PloneSandboxLayer): | ||
defaultBases = (PLONE_FIXTURE,) | ||
|
||
def setUpZope(self, app, configurationContext): | ||
# Load any other ZCML that is required for your tests. | ||
# The z3c.autoinclude feature is disabled in the Plone fixture base | ||
# layer. | ||
import plone.app.dexterity | ||
|
||
self.loadZCML(package=plone.app.dexterity) | ||
import plone.restapi | ||
|
||
self.loadZCML(package=plone.restapi) | ||
self.loadZCML(package=pas.plugins.passwordstrength) | ||
|
||
def setUpPloneSite(self, portal): | ||
applyProfile(portal, "plone.restapi:default") | ||
applyProfile(portal, "pas.plugins.passwordstrength:default") | ||
|
||
|
||
PAS_PLUGINS_PASSWORDSTRENGTH_FIXTURE = PasPluginsPasswordstrengthLayer() | ||
FIXTURE = TestLayer() | ||
|
||
|
||
PAS_PLUGINS_PASSWORDSTRENGTH_INTEGRATION_TESTING = IntegrationTesting( | ||
bases=(PAS_PLUGINS_PASSWORDSTRENGTH_FIXTURE,), | ||
INTEGRATION_TESTING = IntegrationTesting( | ||
bases=(FIXTURE,), | ||
name="PasPluginsPasswordstrengthLayer:IntegrationTesting", | ||
) | ||
|
||
|
||
PAS_PLUGINS_PASSWORDSTRENGTH_FUNCTIONAL_TESTING = FunctionalTesting( | ||
bases=(PAS_PLUGINS_PASSWORDSTRENGTH_FIXTURE,), | ||
FUNCTIONAL_TESTING = FunctionalTesting( | ||
bases=(FIXTURE,), | ||
name="PasPluginsPasswordstrengthLayer:FunctionalTesting", | ||
) | ||
|
||
|
||
PAS_PLUGINS_PASSWORDSTRENGTH_ACCEPTANCE_TESTING = FunctionalTesting( | ||
bases=( | ||
PAS_PLUGINS_PASSWORDSTRENGTH_FIXTURE, | ||
REMOTE_LIBRARY_BUNDLE_FIXTURE, | ||
z2.ZSERVER_FIXTURE, | ||
), | ||
name="PasPluginsPasswordstrengthLayer:AcceptanceTesting", | ||
RESTAPI_TESTING = FunctionalTesting( | ||
bases=(FIXTURE, WSGI_SERVER_FIXTURE), | ||
name="PasPluginsPasswordstrengthLayer:RestAPITesting", | ||
) |
Empty file.
66 changes: 0 additions & 66 deletions
66
src/pas/plugins/passwordstrength/tests/robot/test_example.robot
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from pas.plugins.passwordstrength.testing import FUNCTIONAL_TESTING | ||
from pas.plugins.passwordstrength.testing import INTEGRATION_TESTING | ||
from pas.plugins.passwordstrength.testing import RESTAPI_TESTING | ||
from pathlib import Path | ||
from pytest_plone import fixtures_factory | ||
from requests.exceptions import ConnectionError | ||
|
||
import pytest | ||
import requests | ||
|
||
|
||
pytest_plugins = ["pytest_plone"] | ||
|
||
|
||
globals().update( | ||
fixtures_factory( | ||
( | ||
(INTEGRATION_TESTING, "integration"), | ||
(FUNCTIONAL_TESTING, "functional"), | ||
(RESTAPI_TESTING, "restapi"), | ||
) | ||
) | ||
) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def docker_compose_file(pytestconfig): | ||
"""Fixture pointing to the docker-compose file to be used.""" | ||
return Path(str(pytestconfig.rootdir)).resolve() / "tests" / "docker-compose.yml" | ||
|
||
|
||
def is_responsive(url: str) -> bool: | ||
try: | ||
response = requests.get(url) | ||
if response.status_code == 200: | ||
return True | ||
except ConnectionError: | ||
return False | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def keycloak_service(docker_ip, docker_services): | ||
"""Ensure that keycloak service is up and responsive.""" | ||
# `port_for` takes a container port and returns the corresponding host port | ||
port = docker_services.port_for("keycloak", 8080) | ||
url = f"http://{docker_ip}:{port}" | ||
docker_services.wait_until_responsive( | ||
timeout=50.0, pause=0.1, check=lambda: is_responsive(url) | ||
) | ||
return url | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def keycloak(keycloak_service): | ||
return { | ||
"issuer": f"{keycloak_service}/realms/plone-test", | ||
"client_id": "plone", | ||
"client_secret": "12345678", # nosec B105 | ||
"scope": ("openid", "profile", "email"), | ||
} | ||
|
||
|
||
@pytest.fixture | ||
def wait_for(): | ||
def func(thread): | ||
if not thread: | ||
return | ||
thread.join() | ||
|
||
return func |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
version: "3.9" | ||
|
||
services: | ||
keycloak: | ||
build: | ||
context: keycloak | ||
args: | ||
KEYCLOAK_VERSION: 22.0.0 | ||
command: ['start-dev', '--import-realm'] | ||
depends_on: | ||
- db | ||
environment: | ||
JAVA_OPTS_APPEND: -Dkeycloak.profile.feature.upload_scripts=enabled | ||
KC_DB: postgres | ||
KC_DB_PASSWORD: postgres | ||
KC_DB_URL: jdbc:postgresql://db/keycloak | ||
KC_DB_USERNAME: postgres | ||
KC_HEALTH_ENABLED: false | ||
KC_HTTP_ENABLED: true | ||
KC_METRICS_ENABLED: false | ||
KC_HOSTNAME_URL: http://127.0.0.1:8180/ | ||
KC_PROXY: reencrypt | ||
KEYCLOAK_ADMIN: admin | ||
KEYCLOAK_ADMIN_PASSWORD: admin | ||
volumes: | ||
- ./keycloak/import:/opt/keycloak/data/import | ||
ports: | ||
- 8180:8080 | ||
|
||
db: | ||
image: postgres:14.9 | ||
healthcheck: | ||
test: [ "CMD", "pg_isready", "-q", "-d", "postgres", "-U", "root" ] | ||
timeout: 45s | ||
interval: 5s | ||
retries: 10 | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: keycloak | ||
POSTGRES_HOST: postgres |
Oops, something went wrong.