diff --git a/ci/qa/phpstan-baseline.neon b/ci/qa/phpstan-baseline.neon index 3190610d6..5a12babb9 100644 --- a/ci/qa/phpstan-baseline.neon +++ b/ci/qa/phpstan-baseline.neon @@ -2450,11 +2450,6 @@ parameters: count: 1 path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NameIdType.php - - - message: "#^Cannot cast mixed to int\\.$#" - count: 1 - path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NumberOfTokensPerIdentityType.php - - message: "#^Parameter \\#1 \\$raLocationName of class Surfnet\\\\Stepup\\\\Configuration\\\\Value\\\\RaLocationName constructor expects string, mixed given\\.$#" count: 1 diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index 3e5e61643..0db800f56 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -135,6 +135,8 @@ doctrine: dir: "%kernel.project_dir%/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration" prefix: Surfnet\StepupMiddleware\ManagementBundle\Configuration is_bundle: false + schema_ignore_classes: + - Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaCandidate gateway: connection: gateway naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware diff --git a/src/Surfnet/Migrations/Version20241128131107.php b/src/Surfnet/Migrations/Version20241128131107.php new file mode 100644 index 000000000..c045d9107 --- /dev/null +++ b/src/Surfnet/Migrations/Version20241128131107.php @@ -0,0 +1,55 @@ +addSql('DROP TABLE institution_with_ra_locations'); + $this->addSql('ALTER TABLE institution_configuration_options CHANGE number_of_tokens_per_identity_option number_of_tokens_per_identity_option INT DEFAULT 0 NOT NULL'); + $this->addSql('ALTER TABLE vetted_second_factor CHANGE vetting_type vetting_type VARCHAR(255) DEFAULT NULL'); + $this->addSql('CREATE INDEX idx_vetted_second_factor_vetting_type ON vetted_second_factor (vetting_type)'); + $this->addSql('ALTER TABLE vetting_type_hint CHANGE hints hints JSON NOT NULL COMMENT \'(DC2Type:stepup_vetting_type_hints)\''); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE TABLE institution_with_ra_locations (institution VARCHAR(255) CHARACTER SET utf8mb3 NOT NULL COLLATE `utf8mb3_unicode_ci`, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8mb3 COLLATE `utf8mb3_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('ALTER TABLE institution_configuration_options CHANGE number_of_tokens_per_identity_option number_of_tokens_per_identity_option TINYINT(1) DEFAULT 0 NOT NULL'); + $this->addSql('DROP INDEX idx_vetted_second_factor_vetting_type ON vetted_second_factor'); + $this->addSql('ALTER TABLE vetted_second_factor CHANGE vetting_type vetting_type VARCHAR(255) DEFAULT \'unknown\''); + $this->addSql('ALTER TABLE vetting_type_hint CHANGE hints hints LONGTEXT NOT NULL'); + } +} diff --git a/src/Surfnet/Migrations/Version20241128131108.php b/src/Surfnet/Migrations/Version20241128131108.php new file mode 100644 index 000000000..62529e049 --- /dev/null +++ b/src/Surfnet/Migrations/Version20241128131108.php @@ -0,0 +1,55 @@ +getGatewaySchema(); + + // this up() migration is auto-generated, please modify it to your needs + $this->addSql(sprintf('ALTER TABLE %s.second_factor CHANGE identity_vetted identity_vetted TINYINT(1) DEFAULT 1 NOT NULL', $gatewaySchema)); + } + + public function down(Schema $schema): void + { + $gatewaySchema = $this->getGatewaySchema(); + + // this down() migration is auto-generated, please modify it to your needs + $this->addSql(sprintf('ALTER TABLE %s.second_factor CHANGE identity_vetted identity_vetted TINYINT(1) DEFAULT 1', $gatewaySchema)); + } +} diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NumberOfTokensPerIdentityType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NumberOfTokensPerIdentityType.php index 91d0c4de8..1bbfb6b74 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NumberOfTokensPerIdentityType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NumberOfTokensPerIdentityType.php @@ -20,6 +20,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\ConversionException; +use Doctrine\DBAL\Types\IntegerType; use Doctrine\DBAL\Types\Type; use Surfnet\Stepup\Configuration\Value\NumberOfTokensPerIdentityOption; use Surfnet\Stepup\Exception\InvalidArgumentException; @@ -27,7 +28,7 @@ /** * Custom Type for the NumberOfTokensPerIdentityOption Value Object */ -class NumberOfTokensPerIdentityType extends Type +class NumberOfTokensPerIdentityType extends IntegerType { public const NAME = 'stepup_number_of_tokens_per_identity_option'; diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfAssertedTokensOptionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfAssertedTokensOptionType.php index b6297d277..3d24cfd23 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfAssertedTokensOptionType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfAssertedTokensOptionType.php @@ -20,14 +20,16 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\ConversionException; +use Doctrine\DBAL\Types\IntegerType; use Doctrine\DBAL\Types\Type; +use phpseclib3\Math\PrimeField\Integer; use Surfnet\Stepup\Configuration\Value\SelfAssertedTokensOption; use TypeError; /** * Custom Type for the SelfAssertedTokens options Value Object */ -class SelfAssertedTokensOptionType extends Type +class SelfAssertedTokensOptionType extends IntegerType { public const NAME = 'stepup_self_asserted_tokens_option'; diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfVetOptionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfVetOptionType.php index ba8006124..1202b099a 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfVetOptionType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfVetOptionType.php @@ -20,6 +20,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\ConversionException; +use Doctrine\DBAL\Types\IntegerType; use Doctrine\DBAL\Types\Type; use Surfnet\Stepup\Configuration\Value\SelfVetOption; use TypeError; @@ -27,7 +28,7 @@ /** * Custom Type for the SelfVetOption Value Object */ -class SelfVetOptionType extends Type +class SelfVetOptionType extends IntegerType { public const NAME = 'stepup_self_vet_option'; diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SsoOn2faOptionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SsoOn2faOptionType.php index dcac72b54..904cee34d 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SsoOn2faOptionType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SsoOn2faOptionType.php @@ -20,6 +20,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\ConversionException; +use Doctrine\DBAL\Types\IntegerType; use Doctrine\DBAL\Types\Type; use Surfnet\Stepup\Configuration\Value\SsoOn2faOption; use TypeError; @@ -27,7 +28,7 @@ /** * Custom Type for the SsoOn2faOption Value Object */ -class SsoOn2faOptionType extends Type +class SsoOn2faOptionType extends IntegerType { public const NAME = 'stepup_sso_on_2fa_option'; diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VerifyEmailOptionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VerifyEmailOptionType.php index ef7fa4a3d..5ade89796 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VerifyEmailOptionType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VerifyEmailOptionType.php @@ -19,6 +19,7 @@ namespace Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Types\BooleanType; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; use Surfnet\Stepup\Configuration\Value\VerifyEmailOption; @@ -27,7 +28,7 @@ /** * Custom Type for the VerifyEmailOption Value Object */ -class VerifyEmailOptionType extends Type +class VerifyEmailOptionType extends BooleanType { public const NAME = 'stepup_verify_email_option'; diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VettingTypeHintsType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VettingTypeHintsType.php index 3b0847c44..f58c7006b 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VettingTypeHintsType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VettingTypeHintsType.php @@ -20,6 +20,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\ConversionException; +use Doctrine\DBAL\Types\JsonType; use Doctrine\DBAL\Types\Type; use Surfnet\Stepup\Exception\InvalidArgumentException; use Surfnet\Stepup\Identity\Collection\VettingTypeHintCollection; @@ -27,7 +28,7 @@ /** * Custom Type for the vetting type hints Value Object */ -class VettingTypeHintsType extends Type +class VettingTypeHintsType extends JsonType { public const NAME = 'stepup_vetting_type_hints'; @@ -36,11 +37,6 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st return $platform->getJsonTypeDeclarationSQL($column); } - public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed - { - return $value; - } - public function convertToPHPValue($value, AbstractPlatform $platform): ?VettingTypeHintCollection { if (is_null($value)) { diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaCandidate.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaCandidate.php index 4a3d8c327..3c4f9fb54 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaCandidate.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaCandidate.php @@ -30,14 +30,7 @@ /** * Be aware that this entity is used for the RA Candidate presentation only. This entity shouldn't be used to store any RA candidates. */ -#[ORM\Table] #[ORM\Entity(repositoryClass: RaCandidateRepository::class, readOnly: true)] -#[ORM\Index(name: "idx_ra_candidate_institution", columns: ["institution"])] -#[ORM\Index(name: "idx_ra_candidate_name_id", columns: ["name_id"])] -#[ORM\Index(name: "idxft_ra_candidate_email", columns: ["email"], flags: ['FULLTEXT'])] -#[ORM\Index(name: "idxft_ra_candidate_commonname", columns: ["common_name"], flags: ['FULLTEXT'])] -#[ORM\Index(name: "idx_ra_institution", columns: ["ra_institution"])] -#[ORM\UniqueConstraint(name: "idx_ra_candidate_unique_identity_institution", columns: ["identity_id", "ra_institution"])] class RaCandidate implements JsonSerializable { /** diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/ConfiguredInstitutionControllerTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/ConfiguredInstitutionControllerTest.php index c55d85d92..160a9ccfe 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/ConfiguredInstitutionControllerTest.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/ConfiguredInstitutionControllerTest.php @@ -65,6 +65,7 @@ public function setUp(): void $this->databaseTool->setObjectManagerName('middleware'); // Initialises schema. + $this->databaseTool->setExcludedDoctrineTables(['ra_candidate']); $this->databaseTool->loadFixtures(); diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/SraaControllerTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/SraaControllerTest.php index 0bef81039..dce2051c0 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/SraaControllerTest.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/SraaControllerTest.php @@ -53,6 +53,7 @@ public function setUp(): void $this->databaseTool = $databaseTool->get(); // Initialises schema. + $this->databaseTool->setExcludedDoctrineTables(['ra_candidate']); $this->databaseTool->loadFixtures([]); diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/InstitutionConfiguration.php b/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/InstitutionConfiguration.php index 2afca69db..1af95c2af 100644 --- a/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/InstitutionConfiguration.php +++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/InstitutionConfiguration.php @@ -29,7 +29,7 @@ class InstitutionConfiguration { public function __construct( #[ORM\Id] - #[ORM\Column(length: 200)] + #[ORM\Column(length: 255)] public string $institution, /** * @var bool is the SSO on 2FA feature enabled? diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/ConfigurationControllerTest.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/ConfigurationControllerTest.php index 3ca1fd63c..80d28853a 100644 --- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/ConfigurationControllerTest.php +++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/ConfigurationControllerTest.php @@ -47,6 +47,7 @@ public function setUp(): void } $this->databaseTool = $databaseTool->get(); // Initialises schema. + $this->databaseTool->setExcludedDoctrineTables(['ra_candidate']); $this->databaseTool->loadFixtures([]); $managementPassword = $this->client->getKernel()->getContainer()->getParameter('management_password'); diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/InstitutionConfigurationControllerTest.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/InstitutionConfigurationControllerTest.php index 427124229..93647b23a 100644 --- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/InstitutionConfigurationControllerTest.php +++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/InstitutionConfigurationControllerTest.php @@ -48,6 +48,7 @@ public function setUp(): void } $this->databaseTool = $databaseTool->get(); // Initialises schema. + $this->databaseTool->setExcludedDoctrineTables(['ra_candidate']); $this->databaseTool->loadFixtures([]); $managementPassword = $this->client->getKernel()->getContainer()->getParameter('management_password');