Skip to content

Commit

Permalink
Merge pull request #79 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 4.4.0 -- Add updateUserLastLogin endpoint
  • Loading branch information
hobbitronics authored Sep 20, 2024
2 parents 425955b + dd65d24 commit 8a3097f
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 75 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
59 changes: 0 additions & 59 deletions Vagrantfile

This file was deleted.

6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
version: "2"

services:

php:
image: silintl/php8:8.1
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
8 changes: 8 additions & 0 deletions features/request/RequestContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*/
Expand Down
9 changes: 9 additions & 0 deletions features/request/request.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions src/IdBrokerClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/descriptions/id-broker-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 8a3097f

Please sign in to comment.