From bb784989356b0e870af3a3621c3caedd64754521 Mon Sep 17 00:00:00 2001 From: briskt <3172830+briskt@users.noreply.github.com> Date: Wed, 31 Jul 2024 09:23:08 +0800 Subject: [PATCH 1/6] disable LDAP tests; the ldap image is broken due to CentOS EOL --- Makefile | 2 +- actions-services.yml | 2 +- application/tests/unit/common/components/LdapTest.php | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 410f5efd..dbd6ca7c 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ test: testlocal testintegration testlocal: testunit testapi -testunit: composer rmTestDb upTestDb broker ldapload yiimigratetestDb +testunit: composer rmTestDb upTestDb broker yiimigratetestDb docker-compose run --rm unittest testapi: upTestDb yiimigratetestDb diff --git a/actions-services.yml b/actions-services.yml index 572674f7..1cb1e2e3 100644 --- a/actions-services.yml +++ b/actions-services.yml @@ -19,7 +19,7 @@ services: - db - zxcvbn - broker - - ldapload +# - ldapload environment: MYSQL_HOST: db MYSQL_DATABASE: test diff --git a/application/tests/unit/common/components/LdapTest.php b/application/tests/unit/common/components/LdapTest.php index 5316a3ca..71c1b644 100644 --- a/application/tests/unit/common/components/LdapTest.php +++ b/application/tests/unit/common/components/LdapTest.php @@ -226,6 +226,9 @@ public function testSetPasswordWithoutSpecifyingMatchingAttributeAndValue() */ public function getClient() { + // FIXME (IDP-1156) + $this->markTestSkipped('ldap image is broken due to CentOS EOL'); + $ldap = new Ldap(); $ldap->host = 'ldap'; $ldap->port = 389; From 4b9f179791287680008d36f2b706feac5dd5223d Mon Sep 17 00:00:00 2001 From: briskt <3172830+briskt@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:10:42 +0800 Subject: [PATCH 2/6] remove version from docker-compose.yml --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1e08a162..e531eaef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -version: '2' services: data: image: silintl/data-volume:latest From 6fb19da2c5ca932c33428a533a7bd8787ce4fcff Mon Sep 17 00:00:00 2001 From: briskt <3172830+briskt@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:13:00 +0800 Subject: [PATCH 3/6] remove Vagrantfile and related text in README --- README.md | 16 ++-------- Vagrantfile | 87 ----------------------------------------------------- 2 files changed, 2 insertions(+), 101 deletions(-) delete mode 100644 Vagrantfile diff --git a/README.md b/README.md index a1d2ddf9..1f956aaa 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,6 @@ Backend API for Identity Provider Password Management ### Mac 1. Docker for Mac -### Windows -1. VirtualBox -2. Vagrant -3. Alternative to using vagrant you can install Docker Toolbox, but Docker Compose - still has issues with Windows and doesn't support interactive mode at this time. - ## Setup 1. Clone this repo 2. Copy ```local.env.dist``` to ```local.env``` and ```email.local.env.dist``` @@ -56,18 +50,12 @@ The content of the configuration profile takes the form of a typical .env file, `#` for comments and `=` for variable assignment. Any variables read from AppConfig will overwrite variables set in the execution environment. -### Additional setup for Linux & Mac +### Additional setup + 1. Add entry to ```/etc/hosts``` for ```127.0.0.1 idp-pw-api.local``` 2. Run ```docker build -t idp-pw-api .``` 3. Run ```make start``` -### Additional setup for Windows -1. Add entry to ```c:\windows\system32\drivers\etc\hosts``` for - ```192.168.37.37 idp-pw-api.local``` -2. Run ```vagrant up``` -3. In order to run docker commands directly, SSH into the vagrant box ```vagrant ssh``` - change to /vagrant folder ```cd /vagrant``` and run ```make start``` - ### Makefile script aliases To simplify common tasks there is a Makefile in place. The most common tasks will likely be: diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index 7fda7c1b..00000000 --- a/Vagrantfile +++ /dev/null @@ -1,87 +0,0 @@ -#@IgnoreInspection BashAddShebang -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure(2) do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://atlas.hashicorp.com/search. - config.vm.box = "ubuntu/trusty64" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - config.vm.network "private_network", ip: "192.168.37.37" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - config.vm.provider "virtualbox" do |vb| - # Customize the amount of memory on the VM: - vb.memory = "1536" - - # A fix for speed issues with DNS resolution: - # http://serverfault.com/questions/453185/vagrant-virtualbox-dns-10-0-2-3-not-working?rq=1 - vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] - - # Set the timesync threshold to 59 seconds, instead of the default 20 minutes. - # 59 seconds chosen to ensure SimpleSAML never gets too far out of date. - vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 59000] - end - # - # View the documentation for the provider you are using for more - # information on available options. - - # This provisioner runs on the first `vagrant up`. - config.vm.provision "install", type: "shell", inline: <<-SHELL - # Add Docker apt repository - sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D - sudo sh -c 'echo deb https://apt.dockerproject.org/repo ubuntu-trusty main > /etc/apt/sources.list.d/docker.list' - sudo apt-get update -y - # Uninstall old lxc-docker - apt-get purge lxc-docker - apt-cache policy docker-engine - # Install docker and dependencies - sudo apt-get install -y linux-image-extra-$(uname -r) - sudo apt-get install -y docker-engine - # Add user vagrant to docker group - sudo groupadd docker - sudo usermod -aG docker vagrant - # Install Docker Compose - curl -LsS https://github.com/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose - chmod +x /usr/local/bin/docker-compose - - # Create /home/vagrant/.bash_profile for env vars - cat << EOF > /home/vagrant/.bash_profile -#!/bin/bash -COMPOSER_HOME=/home/vagrant/.composer; export COMPOSER_HOME -COMPOSER_CONFIG_FILE="${COMPOSER_HOME}/config.json"; export COMPOSER_CONFIG_FILE -COMPOSER_CACHE_DIR="${COMPOSER_HOME}/cache"; export COMPOSER_CACHE_DIR -# Get GID for DOCKER_UIDGID env var -GID=`id -g` -DOCKER_UIDGID="${UID}:${GID}"; export DOCKER_UIDGID -EOF - - chown vagrant:vagrant /home/vagrant/.bash_profile - chmod +x /home/vagrant/.bash_profile - - SHELL - - # This provisioner runs on every `vagrant reload' (as well as the first - # `vagrant up`), reinstalling from local directories - config.vm.provision "recompose", type: "shell", - run: "always", inline: <<-SHELL - - # Ensure env vars are loaded from bash_profile - source /home/vagrant/.bash_profile - - SHELL - -end \ No newline at end of file From 2d4b1191836199fc4d9d2d8b0c69a7a6d888a974 Mon Sep 17 00:00:00 2001 From: briskt <3172830+briskt@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:14:05 +0800 Subject: [PATCH 4/6] remove version from actions-services.yml --- actions-services.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/actions-services.yml b/actions-services.yml index 1cb1e2e3..39087ec7 100644 --- a/actions-services.yml +++ b/actions-services.yml @@ -1,4 +1,3 @@ -version: '3' services: db: image: mariadb:latest From 52d5b0b7c04aebbb8b54f88ac473101659c4b42b Mon Sep 17 00:00:00 2001 From: briskt <3172830+briskt@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:14:33 +0800 Subject: [PATCH 5/6] add missing $ from variable in run-tests-api.sh --- application/run-tests-api.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/run-tests-api.sh b/application/run-tests-api.sh index 0775f9fe..64afff32 100755 --- a/application/run-tests-api.sh +++ b/application/run-tests-api.sh @@ -21,5 +21,5 @@ TESTRESULTS_API=$? echo "Note: If there are unexpected errors, try 'make clean' or manually redo id-broker test migration." if [[ "TESTRESULTS_API" -ne 0 ]]; then - exit TESTRESULTS_API + exit $TESTRESULTS_API fi From da888c95a7a4dfe9150ddc62aad9f3b702631167 Mon Sep 17 00:00:00 2001 From: briskt <3172830+briskt@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:15:28 +0800 Subject: [PATCH 6/6] remove hyphen from docker compose --- .github/workflows/test-and-publish.yml | 6 +-- Makefile | 64 +++++++++++++------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.github/workflows/test-and-publish.yml b/.github/workflows/test-and-publish.yml index e447c533..064611a7 100644 --- a/.github/workflows/test-and-publish.yml +++ b/.github/workflows/test-and-publish.yml @@ -11,11 +11,11 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Check PSR2 - run: docker-compose -f actions-services.yml run --rm app ./check-psr2.sh + run: docker compose -f actions-services.yml run --rm app ./check-psr2.sh - name: Run unit tests - run: docker-compose -f actions-services.yml run --rm app ./run-tests.sh + run: docker compose -f actions-services.yml run --rm app ./run-tests.sh - name: Run API tests - run: docker-compose -f actions-services.yml run --rm app ./run-tests-api.sh + run: docker compose -f actions-services.yml run --rm app ./run-tests-api.sh build-and-publish: name: Build and Publish diff --git a/Makefile b/Makefile index dbd6ca7c..781c0a4a 100644 --- a/Makefile +++ b/Makefile @@ -5,86 +5,86 @@ test: testlocal testintegration testlocal: testunit testapi testunit: composer rmTestDb upTestDb broker yiimigratetestDb - docker-compose run --rm unittest + docker compose run --rm unittest testapi: upTestDb yiimigratetestDb - docker-compose kill broker - docker-compose up -d broker - docker-compose run --rm apitest + docker compose kill broker + docker compose up -d broker + docker compose run --rm apitest testintegration: - docker-compose run --rm integrationtest + docker compose run --rm integrationtest api: upDb broker composer yiimigrate - docker-compose up -d api zxcvbn phpmyadmin brokerpma emailpma + docker compose up -d api zxcvbn phpmyadmin brokerpma emailpma composer: - docker-compose run --rm cli composer install + docker compose run --rm cli composer install composershow: - docker-compose run --rm cli bash -c 'composer show --format=json --no-dev --no-ansi --locked | jq ".locked[] | { \"name\": .name, \"version\": .version }" > dependencies.json' + docker compose run --rm cli bash -c 'composer show --format=json --no-dev --no-ansi --locked | jq ".locked[] | { \"name\": .name, \"version\": .version }" > dependencies.json' composerupdate: - docker-compose run --rm cli bash -c "composer update" + docker compose run --rm cli bash -c "composer update" make composershow email: - docker-compose up -d email + docker compose up -d email emailcron: - docker-compose up -d emailcron + docker compose up -d emailcron rmDb: - docker-compose kill db - docker-compose rm -f db + docker compose kill db + docker compose rm -f db upDb: - docker-compose up -d db + docker compose up -d db yiimigrate: - docker-compose run --rm cli whenavail db 3306 100 ./yii migrate --interactive=0 + docker compose run --rm cli whenavail db 3306 100 ./yii migrate --interactive=0 yiimigratelocal: - docker-compose run --rm cli whenavail db 3306 100 ./yii migrate --migrationPath=console/migrations-local/ --interactive=0 + docker compose run --rm cli whenavail db 3306 100 ./yii migrate --migrationPath=console/migrations-local/ --interactive=0 basemodels: - docker-compose run --rm cli whenavail db 3306 100 ./rebuildbasemodels.sh + docker compose run --rm cli whenavail db 3306 100 ./rebuildbasemodels.sh yiimigratetestDb: - docker-compose run --rm cli bash -c 'MYSQL_HOST=testDb MYSQL_DATABASE=test whenavail testDb 3306 100 ./yii migrate --interactive=0' + docker compose run --rm cli bash -c 'MYSQL_HOST=testDb MYSQL_DATABASE=test whenavail testDb 3306 100 ./yii migrate --interactive=0' yiimigratetestDblocal: - docker-compose run --rm cli bash -c 'MYSQL_HOST=testDb MYSQL_DATABASE=test whenavail testDb 3306 100 ./yii migrate --migrationPath=console/migrations-test/ --interactive=0' + docker compose run --rm cli bash -c 'MYSQL_HOST=testDb MYSQL_DATABASE=test whenavail testDb 3306 100 ./yii migrate --migrationPath=console/migrations-test/ --interactive=0' rmTestDb: - docker-compose kill testDb - docker-compose rm -f testDb + docker compose kill testDb + docker compose rm -f testDb upTestDb: - docker-compose up -d testDb + docker compose up -d testDb broker: - docker-compose up -d broker + docker compose up -d broker ldap: - docker-compose up -d ldap + docker compose up -d ldap ldapload: - docker-compose kill ldap - docker-compose rm -f ldap - docker-compose run --rm ldapload + docker compose kill ldap + docker compose rm -f ldap + docker compose run --rm ldapload bounce: - docker-compose up -d api + docker compose up -d api clean: - docker-compose kill - docker-compose rm -f + docker compose kill + docker compose rm -f raml2html: api.html api.html: api.raml - docker-compose run --rm raml2html + docker compose run --rm raml2html psr2: - docker-compose run --rm cli bash -c "vendor/bin/php-cs-fixer fix ." + docker compose run --rm cli bash -c "vendor/bin/php-cs-fixer fix ."