diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb19c1c..7c684ca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,5 +11,4 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Tests - run: docker-compose run --rm php ./run-tests.sh - + run: docker compose run --rm php ./run-tests.sh diff --git a/Makefile b/Makefile index 0a703c1..91a5e97 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,30 @@ # Set up the default (i.e. - first) make entry. test: - docker-compose run --rm php bash -c "./run-tests.sh" + docker compose run --rm php bash -c "./run-tests.sh" bash: - docker-compose run --rm php bash + docker compose run --rm php bash behatappend: - docker-compose run --rm php bash -c "vendor/bin/behat --append-snippets" + docker compose run --rm php bash -c "vendor/bin/behat --append-snippets" behatv: - docker-compose run --rm php bash -c "vendor/bin/behat -v --stop-on-failure" + docker compose run --rm php bash -c "vendor/bin/behat -v --stop-on-failure" clean: - docker-compose kill - docker-compose rm -f + docker compose kill + docker compose rm -f composer: - docker-compose run --rm php bash -c "composer install --no-scripts --no-plugins" + docker compose run --rm php bash -c "composer install --no-scripts --no-plugins" # Example: `make composerrequire NAME=monolog/monolog` composerrequire: - docker-compose run --rm php bash -c "composer require $(NAME) --no-scripts --no-plugins" + docker compose run --rm php bash -c "composer require $(NAME) --no-scripts --no-plugins" composerupdate: - docker-compose run --rm php bash -c "composer update --no-scripts" + docker compose run --rm php bash -c "composer update --no-scripts" ps: - docker-compose ps + docker compose ps diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index b7aea6a..0000000 --- a/Vagrantfile +++ /dev/null @@ -1,59 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -Vagrant.configure(2) do |config| - config.vm.box = "ubuntu/trusty64" - config.vm.network "private_network", ip: "192.168.62.10" - - config.vm.provider "virtualbox" do |vb| - vb.memory = "2048" - - # 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"] - end - - # 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 - # Add NTP so that the LDAP queries don't unexpectedly fail. - sudo apt-get install ntp -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 -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose - chmod +x /usr/local/bin/docker-compose - 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 - - # Run docker-compose (which will update preloaded images, and - # pulls any images not preloaded) - cd /vagrant - - # Set necessary environment variables for shell access. - export COMPOSER_CACHE_DIR=/tmp - export DOCKER_UIDGID="$(id -u):$(id -g)" - - # Set up necessary env. vars to automatically be present each time. - cat << 'EOF' >> /home/vagrant/.bashrc -export COMPOSER_CACHE_DIR=/tmp -export DOCKER_UIDGID="$(id -u):$(id -g)" -EOF - - SHELL - -end diff --git a/docker-compose.yml b/docker-compose.yml index ed6b915..5e9cb6e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "2" - services: php: @@ -7,6 +5,6 @@ services: volumes: - ./:/data extra_hosts: - - "trusted_host.org:10.0.1.1" - - "untrusted_host.org:22.0.1.1" + - "trusted_host.org:10.0.1.1" + - "untrusted_host.org:22.0.1.1" working_dir: /data diff --git a/features/request/RequestContext.php b/features/request/RequestContext.php index c11da2b..251a1cf 100644 --- a/features/request/RequestContext.php +++ b/features/request/RequestContext.php @@ -375,6 +375,14 @@ public function iCallUpdateuser() $this->getIdBrokerClient()->updateUser($this->requestData); } + /** + * @When I call updateUserLastLogin + */ + public function iCallUpdateuserlastlogin() + { + $this->getIdBrokerClient()->updateUserLastLogin($this->requestData['employee_id']); + } + /** * @When I call listUsers and ask for these fields: */ diff --git a/features/request/request.feature b/features/request/request.feature index ffb3c5c..32ac9ec 100644 --- a/features/request/request.feature +++ b/features/request/request.feature @@ -143,6 +143,15 @@ Feature: Formatting requests for sending to the ID Broker API } """ + Scenario: Updating a users last_login_utc + Given I am using a baseUri of "https://api.example.com/" + And I have indicated not to validate the id broker ip + And I provide an "employee_id" of "12345" + When I call updateUserLastLogin + Then the method should be "PUT" + And the url should be "https://api.example.com/user/12345/update-last-login" + And an authorization header should be present + Scenario: Deactivating a user Given I am using a baseUri of "https://api.example.com/" And I have indicated not to validate the id broker ip diff --git a/src/IdBrokerClient.php b/src/IdBrokerClient.php index d33be9a..43a5075 100644 --- a/src/IdBrokerClient.php +++ b/src/IdBrokerClient.php @@ -708,6 +708,26 @@ public function updateUser(array $config = [ ]): array $this->reportUnexpectedResponse($result, 1490808841); } + /** + * Update the User last_login_utc by calling the internal method + * @param string $employeeId + * @return array An array of information about the updated user only including last_login_utc and employee_id + * @throws ServiceException + */ + public function updateUserLastLogin(string $employeeId): array + { + $result = $this->updateUserLastLoginInternal([ + 'employee_id' => $employeeId, + ]); + $statusCode = (int)$result[ 'statusCode' ]; + + if ($statusCode === 200) { + return $this->getResultAsArrayWithoutStatusCode($result); + } + + $this->reportUnexpectedResponse($result, 1490808841); + } + /** * Determine whether any of the Id-broker's IPs are not in the * trusted ranges diff --git a/src/descriptions/id-broker-api.php b/src/descriptions/id-broker-api.php index 838a95d..0be09f2 100644 --- a/src/descriptions/id-broker-api.php +++ b/src/descriptions/id-broker-api.php @@ -470,6 +470,18 @@ ], ], ], + 'updateUserLastLoginInternal' => [ + 'httpMethod' => 'PUT', + 'uri' => '/user/{employee_id}/update-last-login', + 'responseModel' => 'Result', + 'parameters' => [ + 'employee_id' => [ + 'required' => true, + 'type' => 'string', + 'location' => 'uri', + ], + ], + ], 'createMethodInternal' => [ 'httpMethod' => 'POST', 'uri' => '/method',