From 3cc28b30fd3705ced8204c70a21c52204494db6a Mon Sep 17 00:00:00 2001 From: Maarten de Waard <maarten@greenhost.nl> Date: Tue, 15 Jun 2021 17:12:42 +0200 Subject: [PATCH] change docker-compose.yml so it works for me --- .gitlab-ci.yml | 1 + README.md | 2 +- docker-compose.yml | 12 +++++---- test/create-hydra-client.bash | 2 +- test/integration_tests/README.md | 43 ++++++++++++-------------------- user-panel | 2 +- 6 files changed, 27 insertions(+), 35 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 581cbb1..e20c3d8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -61,6 +61,7 @@ integration_test: only: changes: - test/integration_tests/test/**/* + - test/integration_tests/test/Dockerfile - .gitlab-ci.yml pylint: diff --git a/README.md b/README.md index cfe29c7..9f02f8f 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -Please refer to the [online documentation](...) for all the details +Please refer to the [online documentation](https://docs.openappstack.net/projects/single-sign-on/) for all the details diff --git a/docker-compose.yml b/docker-compose.yml index 546bb2d..dda6b6d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,13 +7,13 @@ version: '3' services: hydra: - image: oryd/hydra:latest + image: oryd/hydra:v1.8 ports: - "4444:4444" # Public port - "4445:4445" # Admin port - "5555:5555" # Port for hydra token user command: - serve all --dangerous-force-http --dangerous-allow-insecure-redirect-urls "http://127.0.0.1:13337/callback, http://127.0.0.1:13337/" + serve all --dangerous-force-http --dangerous-allow-insecure-redirect-urls "http://localhost:13337/callback, http://localhost:13337/" environment: - URLS_SELF_ISSUER=http://localhost:4444/ - URLS_CONSENT=http://localhost:5001/consent @@ -73,16 +73,18 @@ services: - "5432:5432" oauth: build: ./test/integration_tests + network_mode: host + depends_on: + - hydra environment: - BASE_URL=http://localhost:4444/ - KEY=testapp - SECRET=secret - FLASK_ENV=development # with this settings run: - ## `bash test/create-hydra-client.bash testapp clientsecret http://localhost:4445 http://127.0.0.1:13337/callback http://127.0.0.1:13337 http:/127.0.0.1:13337/logout + ## `bash test/create-hydra-client.bash testapp clientsecret http://localhost:4445 http://localhost:13337/callback http://localhost:13337/ http://localhost:13337/logout ## to register a corresponding oauth client with hydra ports: - "13337:13337" - command: flask run --port 13337 --host "0.0.0.0" + command: flask run --port 13337 restart: unless-stopped - diff --git a/test/create-hydra-client.bash b/test/create-hydra-client.bash index 7801703..56f63e4 100755 --- a/test/create-hydra-client.bash +++ b/test/create-hydra-client.bash @@ -1,7 +1,7 @@ #!/bin/bash if [[ $1 == "" ]] || [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then - echo "usage: $0 OAUTH_CLIENT_ID OAUCH_CLIENT_SECRET HOST_URL REDIRECT_URI"; + echo "usage: $0 OAUTH_CLIENT_ID OAUTH_CLIENT_SECRET HOST_URL REDIRECT_URI"; exit 0; fi diff --git a/test/integration_tests/README.md b/test/integration_tests/README.md index 83e20ab..d5c9101 100644 --- a/test/integration_tests/README.md +++ b/test/integration_tests/README.md @@ -4,15 +4,18 @@ work together according to [OpenID Connect Standards](https://openid.net/develop ## Prerequisites The single sign-on application needs to be up and running. Instructions on how to accomplish -that can be found in `../../README.md`. +that can be found [in the +documentation](https://docs.openappstack.net/projects/single-sign-on/en/latest/local_development.html). ### Create oAuth Client + You also need to create an oAuth2-Client to enable this application to communicate with the oAuth server. To do that you can run the `create-hydra-client` script in this repository: + ``` -bash ../create-hydra-client.bash testapplication clientsecret http://localhost:4445 http://localhost:13337/callback http://localhost:13337/ http://localhost:13337/logout +bash ../create-hydra-client.bash testapp clientsecret http://localhost:4445 http://localhost:13337/callback http://localhost:13337/ http://localhost:13337/logout ``` `http://localhost:4445` refers to the hydra-admin service. `http://localhost:13337/callback` is the @@ -34,11 +37,11 @@ out for is called `--dangerous-allow-insecure-redirect-urls`: In the default setup, users can be created by executing the scripts contained in `../../user-panel/backend/utils/` ``` -bash ../../user-panel/backend/utils/create-user.bash admin <choose-password-here> admin@example.net -bash ../../user-panel/backend/utils/create-application.bash testapplication -bash ../../user-panel/backend/utils/grant-access.bash admin testapplication -bash ../../user-panel/backend/utils/create-role.bash admin -bash ../../user-panel/backend/utils/assign-role.bash admin admin +docker-compose exec backend ./utils/create-user.bash admin <choose-password-here> admin@example.net +docker-compose exec backend ./utils/create-application.bash testapp "this is a test application" +docker-compose exec backend ./utils/grant-access.bash admin testapp +docker-compose exec backend ./utils/create-role.bash admin +docker-compose exec backend ./utils/assign-role.bash admin admin ``` ## Installation @@ -50,24 +53,8 @@ python3 -m venv venv pip3 install -r requrements.txt ``` -## Configuration - -Make sure you export the following -environment variables with values according to your setup. Use the default values provided here -if you run your setup locally. - -``` -export BASE_URL=http://localhost:4444/ # Hydra public API Base -export KEY=testapplication # name of your oauth/openID Connect client (application) -export SECRET=clientsecret # secret of your oauth/openID Connect client (application) -``` - - ## Run the tests -Start the application with: -``` -flask run --port=13337 -``` + Navigate to `http://localhost:13337/` to trigger the openID connect authentication flow. During the login process your agent's browser will be redirected multiple times. If successful, you will see a json reply containing your oAuth token. @@ -78,6 +65,7 @@ Connect scopes. ### Run auto tests Run the following commands to run the tests + ``` export TESTUSER_USERNAME=user export TESTUSER_PASSWORD=secret @@ -86,8 +74,8 @@ export TESTUSER_EMAIL=test@example.net export ROLE=admin bash ../../user-panel/utils/create-user.bash $TESTUSER_USERNAME $TESTUSER_PASSWORD $TESTUSER_EMAIL bash ../../user-panel/utils/create-user.bash $TESTUSER_USERNAME2 RANDOMPW $TESTUSER_EMAIL -bash ../../user-panel/utils/create-application.bash testapplication -bash ../../user-panel/utils/grant-access.bash $TESTUSER_USERNAME testapplication +bash ../../user-panel/utils/create-application.bash testapp +bash ../../user-panel/utils/grant-access.bash $TESTUSER_USERNAME testapp bash ../../user-panel/utils/create-role.bash $ROLE bash ../../user-panel/utils/assign-role.bash $TESTUSER_USERNAME $ROLE python3 -m behave \ @@ -99,4 +87,5 @@ python3 -m behave \ -D email=${TESTUSER_EMAIL} \ -D role=${ROLE} ``` -Note: You need to have chromedriver isntalled to run the tests + +Note: You need to have chromedriver installed to run the tests diff --git a/user-panel b/user-panel index fc81c23..9a16055 160000 --- a/user-panel +++ b/user-panel @@ -1 +1 @@ -Subproject commit fc81c23c8c0673f58a0790485be3e702859bfc70 +Subproject commit 9a16055973a2b36acf361e853eb55b4cfbd0c6f4 -- GitLab