Skip to content

Commit

Permalink
Fix replay errors test2 replay
Browse files Browse the repository at this point in the history
  • Loading branch information
pablothedude committed Nov 26, 2024
1 parent 4186b13 commit 27761de
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
9 changes: 2 additions & 7 deletions ci/qa/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2665,19 +2665,14 @@ parameters:
count: 2
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/RecoveryTokenProjector.php

-
message: "#^Cannot access property \\$secondFactorIdentifier on Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Entity\\\\UnverifiedSecondFactor\\|null\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SecondFactorProjector.php

-
message: "#^Parameter \\#1 \\$secondFactor of method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\UnverifiedSecondFactorRepository\\:\\:remove\\(\\) expects Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Entity\\\\UnverifiedSecondFactor, Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Entity\\\\UnverifiedSecondFactor\\|null given\\.$#"
count: 3
count: 2
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SecondFactorProjector.php

-
message: "#^Parameter \\#1 \\$secondFactor of method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\VerifiedSecondFactorRepository\\:\\:remove\\(\\) expects Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Entity\\\\VerifiedSecondFactor, Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Entity\\\\VerifiedSecondFactor\\|null given\\.$#"
count: 4
count: 3
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SecondFactorProjector.php

-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\Email;
use Surfnet\Stepup\Identity\Value\EmailVerificationWindow;
use Surfnet\Stepup\Identity\Value\GssfId;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\Locale;
use Surfnet\Stepup\Identity\Value\SecondFactorId;
use Surfnet\Stepup\Identity\Value\SecondFactorIdentifier;
use Surfnet\Stepup\Identity\Value\U2fKeyHandle;
use Surfnet\StepupBundle\Value\SecondFactorType;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable;
Expand Down Expand Up @@ -55,7 +57,7 @@ class U2fDevicePossessionProvenEvent extends IdentityEvent implements Forgettabl
* @param IdentityId $identityId
* @param Institution $identityInstitution
* @param SecondFactorId $secondFactorId
* @param U2fKeyHandle $keyHandle
* @param SecondFactorIdentifier $keyHandle
* @param bool $emailVerificationRequired
* @param EmailVerificationWindow $emailVerificationWindow
* @param string $emailVerificationNonce
Expand All @@ -69,7 +71,7 @@ public function __construct(
IdentityId $identityId,
Institution $identityInstitution,
public SecondFactorId $secondFactorId,
public U2fKeyHandle $keyHandle,
public SecondFactorIdentifier $keyHandle,
public bool $emailVerificationRequired,
public EmailVerificationWindow $emailVerificationWindow,
public string $emailVerificationNonce,
Expand Down Expand Up @@ -143,7 +145,6 @@ public function setSensitiveData(SensitiveData $sensitiveData): void
$this->email = $sensitiveData->getEmail();
$this->commonName = $sensitiveData->getCommonName();
$keyHandle = $sensitiveData->getSecondFactorIdentifier();
assert($keyHandle instanceof U2fKeyHandle);
$this->keyHandle = $keyHandle;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@
/**
* 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
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ public function applyGssfPossessionProvenAndVerifiedEvent(GssfPossessionProvenAn
public function applyEmailVerifiedEvent(EmailVerifiedEvent $event): void
{
$unverified = $this->unverifiedRepository->find($event->secondFactorId->getSecondFactorId());
if (is_null($unverified)) {
return;
}

$verified = new VerifiedSecondFactor();
$verified->id = $event->secondFactorId->getSecondFactorId();
Expand Down Expand Up @@ -247,7 +250,11 @@ protected function applyCompliedWithUnverifiedSecondFactorRevocationEvent(

protected function applyVerifiedSecondFactorRevokedEvent(VerifiedSecondFactorRevokedEvent $event): void
{
$this->verifiedRepository->remove($this->verifiedRepository->find($event->secondFactorId->getSecondFactorId()));
$verifiedSecondFactor = $this->verifiedRepository->find($event->secondFactorId->getSecondFactorId());
if (is_null($verifiedSecondFactor)) {
return;
}
$this->verifiedRepository->remove($verifiedSecondFactor);
}

protected function applyCompliedWithVerifiedSecondFactorRevocationEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ public function fetchByEventTypes(array $eventTypes): DomainEventStream

private function deserializeEvent(array $row): DomainMessage
{
echo '1: |'.(string)$row['payload']."|\n";
echo '2: |';
var_dump(json_decode($row['payload'], true, JSON_THROW_ON_ERROR));
echo "|\n";
$event = $this->payloadSerializer->deserialize(json_decode((string)$row['payload'], true));

if ($event instanceof Forgettable) {
Expand Down

0 comments on commit 27761de

Please sign in to comment.