Skip to content

itk-dev/dokk1gh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dokk1-gæstehåndtering

Installation

docker compose pull
docker compose up --detach --remove-orphans
docker compose exec phpfpm composer install

Define default local settings:

cp config/services.local.yaml.dist config/services.local.yaml

Edit config/services.local.yaml as needed (cf. Mocks).

Set up database:

docker compose exec phpfpm bin/console doctrine:migrations:migrate --no-interaction

Create super administrator:

docker compose exec phpfpm bin/console user:create [email protected]
docker compose exec phpfpm bin/console user:promote [email protected] ROLE_SUPER_ADMIN
docker compose exec phpfpm bin/console user:set-password [email protected]

Create administrator:

docker compose exec phpfpm bin/console user:create [email protected]
docker compose exec phpfpm bin/console user:promote [email protected] ROLE_ADMIN

Create user:

docker compose exec phpfpm bin/console user:create [email protected]

Open the site:

open "http://$(docker compose port nginx 8080)"

Translations

docker compose exec phpfpm composer update-translations
# Open Danish translations in Poedit (https://poedit.net/)
# Run `brew install poedit` to install Poedit.
open translations/messages+intl-icu.da.xlf

Build assets

docker compose run --rm node yarn install
docker compose run --rm node yarn build

During development, use

docker compose run --rm node yarn watch

to watch for changes.

Fixtures

Load fixtures to populate your test database:

docker compose exec phpfpm composer fixtures:load

After loading fixtures, the following users exist (cf. fixtures/user.yaml):

Email Password Roles API key
[email protected] password ROLE_SUPER_ADMIN
[email protected] user-password ROLE_USER user-api-key

Cron jobs

The app:aeos:code-cleanup console command can be used to delete expires codes:

bin/console app:aeos:code-cleanup --help

A couple of commands can clean up guest and apps

bin/console app:expire-guests
bin/console app:expire-inactive-apps --app-sent-before='-24 hours'

Set up a cron job to have expired codes deleted daily at 02:00 (adjust paths to match your actual setup):

0 2 * * * /usr/bin/php /home/www/dokk1gh/htdocs/bin/console --env=prod app:aeos:code-cleanup

API

A user can create an API key via the user menu: @TODO

API documentation:

open "http://$(docker compose port nginx 8080)/api/doc"

In the following examples, the API key of the fixture user [email protected] is used.

Get a list of templates available to the user:

curl --silent --header "Authorization: Bearer user-api-key" "http://$(docker compose port nginx 8080)/api/templates"

Get list of codes created by user:

curl --silent --header "Authorization: Bearer user-api-key" "http://$(docker compose port nginx 8080)/api/codes"

An administrator can get all codes by adding all=1:

curl --silent --header "Authorization: Bearer user-api-key" "http://$(docker compose port nginx 8080)/api/codes?all=1"

Create a code:

curl --silent --silent --header "Authorization: Bearer user-api-key" "http://$(docker compose port nginx 8080)/api/codes" --header "content-type: application/json" --data @- <<'JSON'
{
    "template": 1,
    "startTime": "2017-08-14T08:00:00+02:00",
    "endTime": "2017-08-14T16:00:00+02:00"
}
JSON

On success the result will look like this:

{
   "status" : "ok",
   "code" : "21347994",
   "endTime" : "2017-08-14T16:00:00+0200",
   "startTime" : "2017-08-14T08:00:00+0200",
   "template" : {
      "name" : "Gæst ITK",
      "id" : 1
   }
}

Test and debugging

Emails

Debug email sent to user when created:

bin/console app:debug notify-user-created [user email]

e.g.

bin/console app:debug notify-user-created [email protected]

Open test mail UI:

open "http://$(docker compose port mail 8025)"

Mocks

docker compose exec phpfpm bin/console doctrine:schema:update --em=mock --force --complete

Mock AEOS web service

Use this during local testing and development.

# config/services.local.yaml
parameters:
    aeos_location: 'http://nginx:8080/mock/aeosws'
    aeos_username: null
    aeos_password: null
  • List mock AEOS templates to use when editing templates:

    open "http://$(docker compose port nginx 8080)/admin/api/templates"
  • List mock AEOS users to use when editing users:

    open "http://$(docker compose port nginx 8080)/admin/api/people"

See messages sent to the mock AEOS web service:

open "http://$(docker compose port nginx 8080)/mock/aeosws/log"

Show only the latest message:

open "http://$(docker compose port nginx 8080)/mock/aeosws/log/latest"

Mock SMS gateway

Use this during local testing and development.

Sms2Go

https://pushapi.ecmr.biz/docs/index.html?url=/swagger/v1/swagger.json#tag/SMS-gateway

curl --verbose --location "$(docker compose port nginx 8080)/mock/sms2go/sms2go-gateway-id" --header "authorization: Bearer sms2go-api-key" --header "content-type: application/json"  --data @- <<'JSON'
{
 "body":"Hello!",
 "to": [
   "4512345678"
 ]
}
JSON

The values sms2go-gateway-id and sms2go-api-key above must match the values of the SMS2GO_GATEWAY_ID and SMS2GO_API_KEY environment variables.

See messages sent to the mock SMS gateway:

open "http://$(docker compose port nginx 8080)/mock/sms/log"

Show only the latest message:

open "http://$(docker compose port nginx 8080)/mock/sms/log/latest"

Acceptance tests

Clear out the acceptance test cache and set up the database:

SYMFONY_ENV=acceptance bin/console cache:clear --no-warmup
SYMFONY_ENV=acceptance bin/console cache:warmup
SYMFONY_ENV=acceptance bin/console doctrine:database:create

Run API tests:

./vendor/bin/behat

Coding standards

PHP

docker compose exec phpfpm composer coding-standards-apply
docker compose exec phpfpm composer coding-standards-check

Markdown

docker compose run --rm node yarn install
docker compose run --rm node yarn coding-standards-apply
docker compose run --rm node yarn coding-standards-check

Rector

docker compose exec phpfpm vendor/bin/rector process

Code analysis

docker compose exec phpfpm composer code-analysis