diff --git a/.docheader b/.docheader index 7868722a..a12ddf88 100644 --- a/.docheader +++ b/.docheader @@ -1,5 +1,5 @@ /** - * Copyright 2019 SURFnet B.V. + * Copyright %regexp:\d{4}% SURFnet %regexp:(B.V.|bv)% * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 86210ffe..968b779e 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -4,23 +4,17 @@ on: [pull_request] jobs: run-qa-tests: runs-on: ubuntu-latest - defaults: - run: - working-directory: /var/www/html/ - container: - image: ghcr.io/openconext/openconext-basecontainers/php82-apache2-node20-composer2:latest - volumes: - - .:/var/www/html - + timeout-minutes: 30 steps: - name: Checkout uses: actions/checkout@v4 - - name: Composer install - run: composer install + - name: Init environment + run: cd ci/docker && ./init.sh - name: Build frontend assets run: yarn && yarn encore production - name: Run QA tests - run: composer check + run: | + cd ci/docker && docker compose exec -T webauthn bash -c 'composer check' \ No newline at end of file diff --git a/ci/docker/docker-compose.yml b/ci/docker/docker-compose.yml index 08801532..572f2d4d 100644 --- a/ci/docker/docker-compose.yml +++ b/ci/docker/docker-compose.yml @@ -1,7 +1,5 @@ --- -version: '3.7' - services: haproxy: image: ghcr.io/openconext/openconext-basecontainers/haproxy26:latest @@ -14,7 +12,7 @@ services: - "webauthn.dev.openconext.local" webauthn: stdin_open: true - image: ghcr.io/openconext/stepup-webauthn/stepup-webauthn:dev + image: ghcr.io/openconext/openconext-basecontainers/php82-apache2-node20-composer2:latest volumes: - ../../:/var/www/html - ${PWD}/webauthn:/config diff --git a/ci/docker/init.sh b/ci/docker/init.sh new file mode 100755 index 00000000..34022843 --- /dev/null +++ b/ci/docker/init.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +echo "pulling the images" +docker compose pull +echo "starting the images" +docker compose up -d +echo "intialising the environment" +docker compose exec -T webauthn bash -c ' + cp /var/www/html/config/openconext/parameters.yaml.dist /var/www/html/config/openconext/parameters.yaml && \ + composer install --prefer-dist -n -o --no-scripts && \ + ./bin/console assets:install --verbose && \ + ./bin/console cache:clear && \ + chown -R www-data:www-data /var/www/html/var/ && \ + ./bin/console doctrine:migrations:migrate --no-interaction +' diff --git a/ci/docker/readme.md b/ci/docker/readme.md new file mode 100644 index 00000000..e411c21f --- /dev/null +++ b/ci/docker/readme.md @@ -0,0 +1 @@ +## Don't use this docker setup in production this is solely for testing purposes! diff --git a/ci/qa/doctrine-schema-validate b/ci/qa/doctrine-schema-validate new file mode 100755 index 00000000..74e16098 --- /dev/null +++ b/ci/qa/doctrine-schema-validate @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +cd $(dirname $0)/../../ + +printf "Doctrine schema validate\n" +./bin/console doctrine:schema:validate diff --git a/composer.json b/composer.json index a26818d5..e71df15c 100644 --- a/composer.json +++ b/composer.json @@ -89,7 +89,8 @@ "@phpcpd", "@phpmd", "@phpstan", - "@unit-tests" + "@unit-tests", + "@doctrine-schema-validate" ], "composer-validate": "./ci/qa/validate", "docheader": "./ci/qa/docheader", @@ -101,6 +102,7 @@ "phpstan": "./ci/qa/phpstan", "phpstan-baseline": "./ci/qa/phpstan-update-baseline", "unit-tests": "ci/qa/phpunit", + "doctrine-schema-validate": "ci/qa/doctrine-schema-validate", "frontend-install": [ "yarn install" ], diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index e10778fc..68092e2c 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -2,7 +2,7 @@ doctrine: dbal: # configure these for your database server driver: 'pdo_mysql' - server_version: '5.6' + server_version: '10.6.19-MariaDB' charset: utf8mb4 default_table_options: charset: utf8mb4 diff --git a/config/services_test.yaml b/config/services_test.yaml index a3ced9dc..3eea2f4c 100644 --- a/config/services_test.yaml +++ b/config/services_test.yaml @@ -1,6 +1,5 @@ parameters: locale: nl_NL - database_url: sqlite:///%kernel.project_dir%/var/webauthn.db services: # default configuration for services in *this* file @@ -14,6 +13,9 @@ services: $supportEmail: '%support_email%' $locales: '%locales%' $userDisplayName: '%user_display_name%' + $jwtMdsBlobFileName: '%fido2_jwt_mds_blob_file_name%' + $jwtMdsRootCertFileName: '%fido2_jwt_mds_root_certificate_file_name%' + $mdsCacheDir: '%fido2_mds_cache_dir%' # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name diff --git a/src/Entity/PublicKeyCredentialSource.php b/src/Entity/PublicKeyCredentialSource.php index 8ff4f7b7..0a3e1dbd 100644 --- a/src/Entity/PublicKeyCredentialSource.php +++ b/src/Entity/PublicKeyCredentialSource.php @@ -38,12 +38,14 @@ class PublicKeyCredentialSource extends BasePublicKeyCredentialSource #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type:"integer")] - private string $id; + private int $id; /** - * Override the $uvInitialized field which we do not use, but needs + * Override the $backupEligible, $backupStatus and $uvInitialized fields which we do not use, but needs * to be initialized. Needed to prevent read before written errors. */ + public ?bool $backupEligible = null; + public ?bool $backupStatus = null; public ?bool $uvInitialized = false; public function __construct( diff --git a/src/Migrations/Version20250106150814.php b/src/Migrations/Version20250106150814.php new file mode 100644 index 00000000..df8971ab --- /dev/null +++ b/src/Migrations/Version20250106150814.php @@ -0,0 +1,47 @@ +addSql('ALTER TABLE public_key_credential_sources ADD backup_eligible TINYINT(1) DEFAULT NULL, ADD backup_status TINYINT(1) DEFAULT NULL, ADD uv_initialized TINYINT(1) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE public_key_credential_sources DROP backup_eligible, DROP backup_status, DROP uv_initialized'); + } +} diff --git a/tests/Integration/Repository/PublicKeyCredentialSourceRepositoryTest.php b/tests/Integration/Repository/PublicKeyCredentialSourceRepositoryTest.php new file mode 100644 index 00000000..af0be792 --- /dev/null +++ b/tests/Integration/Repository/PublicKeyCredentialSourceRepositoryTest.php @@ -0,0 +1,75 @@ +entityManager = $kernel->getContainer() + ->get('doctrine') + ->getManager(); + } + + + protected function tearDown(): void + { + parent::tearDown(); + + $this->entityManager->close(); + $this->entityManager = null; + } + + public function testRepo() + { + /** @var PublicKeyCredentialSourceRepository $repo */ + $repo = $this->entityManager->getRepository(PublicKeyCredentialSource::class); + + $item = new PublicKeyCredentialSource( + 'id', + 'type', + ['transports'], + 'attestationType', + new EmptyTrustPath(), + UuidV4::v4(), + 'credentialPublicKey', + 'userHandle', + 1, + 'fmt' + ); + + $repo->saveCredentialSource($item); + + $result = $repo->allForUser(new User('userHandle', 'foo', 'bar')); + + $this->assertNotEmpty($result); + } + +}