-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from OpenConext/feature/update_schema
Fix doctrine mapping & add integration test that fails on invalid schema
- Loading branch information
Showing
12 changed files
with
162 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## Don't use this docker setup in production this is solely for testing purposes! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
cd $(dirname $0)/../../ | ||
|
||
printf "Doctrine schema validate\n" | ||
./bin/console doctrine:schema:validate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2024 SURFnet B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
final class Version20250106150814 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->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'); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
tests/Integration/Repository/PublicKeyCredentialSourceRepositoryTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
/** | ||
* Copyright 2024 SURFnet B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace Test\Integration\Repository; | ||
|
||
use Doctrine\ORM\EntityManager; | ||
use Surfnet\Webauthn\Entity\PublicKeyCredentialSource; | ||
use Surfnet\Webauthn\Entity\User; | ||
use Surfnet\Webauthn\Repository\PublicKeyCredentialSourceRepository; | ||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | ||
use Symfony\Component\Uid\Uuid; | ||
use Symfony\Component\Uid\UuidV4; | ||
use Webauthn\TrustPath\EmptyTrustPath; | ||
|
||
class PublicKeyCredentialSourceRepositoryTest extends KernelTestCase | ||
{ | ||
private ?EntityManager $entityManager; | ||
|
||
protected function setUp(): void | ||
{ | ||
$kernel = self::bootKernel(); | ||
|
||
$this->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(), | ||
new Uuid('580c810d-d82f-43ce-9796-6fd000be454a'), | ||
'credentialPublicKey', | ||
'userHandle', | ||
1, | ||
'fmt' | ||
); | ||
|
||
$repo->saveCredentialSource($item); | ||
|
||
$result = $repo->allForUser(new User('userHandle', 'foo', 'bar')); | ||
|
||
$this->assertNotEmpty($result); | ||
} | ||
|
||
} |