Skip to content

Commit

Permalink
Repair IdentityCommandHandlerTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
MKodde committed Feb 28, 2024
1 parent 4d634f7 commit 84a70b1
Show file tree
Hide file tree
Showing 40 changed files with 116 additions and 168 deletions.
24 changes: 12 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use ArrayIterator;
use Broadway\Serializer\Serializable as SerializableInterface;
use Iterator;
use IteratorAggregate;
use JsonSerializable;
use Surfnet\StepupBundle\Value\SecondFactorType;
Expand Down Expand Up @@ -94,7 +95,7 @@ public function equals(AllowedSecondFactorList $other): bool
return true;
}

public static function deserialize(array $data)
public static function deserialize(array $data): self
{
$secondFactorTypes = array_map(
fn($secondFactorString): SecondFactorType => new SecondFactorType($secondFactorString),
Expand All @@ -116,7 +117,7 @@ public function serialize(): array
];
}

public function getIterator()
public function getIterator(): Iterator
{
return new ArrayIterator($this->allowedSecondFactors);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Surfnet/Stepup/Configuration/Value/RaLocationList.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace Surfnet\Stepup\Configuration\Value;

use ArrayIterator;
use Iterator;
use IteratorAggregate;
use Surfnet\Stepup\Configuration\Entity\RaLocation;
use Surfnet\Stepup\Exception\LogicException;
Expand Down Expand Up @@ -103,7 +104,7 @@ public function getById(RaLocationId $raLocationId)
);
}

public function getIterator()
public function getIterator(): Iterator
{
return new ArrayIterator($this->raLocations);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use ArrayIterator;
use Broadway\Serializer\Serializable as SerializableInterface;
use Iterator;
use IteratorAggregate;
use JsonSerializable;
use Surfnet\Stepup\Exception\RuntimeException;
Expand Down Expand Up @@ -100,12 +101,12 @@ public function removeAllIn(InstitutionCollection $institutionCollection): void
}
}

public function jsonSerialize()
public function jsonSerialize(): array
{
return ['institutions' => $this->elements];
}

public static function deserialize(array $data)
public static function deserialize(array $data): self
{
$institutions = array_map(fn($institution): Institution => new Institution($institution), $data);

Expand All @@ -117,7 +118,7 @@ public function serialize(): array
return array_map(fn(Institution $institution): string => (string)$institution, $this->elements);
}

public function getIterator()
public function getIterator(): Iterator
{
return new ArrayIterator($this->elements);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ public function remove(VettingTypeHint $hint): void
$this->elements = $elements;
}

public function jsonSerialize()
public function jsonSerialize(): array
{
return $this->elements;
}

public static function deserialize(array $data)
public static function deserialize(array $data): self
{
$institutions = array_map(
fn(array $hint): VettingTypeHint => new VettingTypeHint($hint['locale'], $hint['hint']),
Expand Down

This file was deleted.

24 changes: 21 additions & 3 deletions src/Surfnet/Stepup/Identity/Entity/AbstractSecondFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,27 @@

use Broadway\EventSourcing\SimpleEventSourcedEntity;
use Surfnet\Stepup\Identity\Value\SecondFactorIdentifier;
use Surfnet\Stepup\Identity\Value\UnknownVettingType;
use Surfnet\Stepup\Identity\Value\VettingType;
use Surfnet\StepupBundle\Service\SecondFactorTypeService;
use Surfnet\StepupBundle\Value\SecondFactorType;
use Surfnet\StepupBundle\Value\VettingType as StepupBundleVettingType;

abstract class AbstractSecondFactor extends SimpleEventSourcedEntity implements SecondFactor
{
public function hasEqualOrHigherLoaComparedTo(SecondFactor $comparable, SecondFactorTypeService $service): bool
{
return $comparable->hasTypeWithEqualOrLowerLoaComparedTo($this->getType(), $service);
return $comparable->hasTypeWithEqualOrLowerLoaComparedTo($this->getType(), $this->vettingType(), $service);
}

public function hasTypeWithEqualOrLowerLoaComparedTo(SecondFactorType $type, SecondFactorTypeService $service): bool
public function hasTypeWithEqualOrLowerLoaComparedTo(SecondFactorType $type, VettingType $vettingType, SecondFactorTypeService $service): bool
{
return $service->hasEqualOrLowerLoaComparedTo($this->getType(), $type);
// SecondFactorTypeService works with the vetting type value objects
// from the stepup bundle, so convert them.
$ownVettingType = new StepupBundleVettingType($this->vettingType()->type());
$otherVettingType = new StepupBundleVettingType($vettingType->type());

return $service->hasEqualOrLowerLoaComparedTo($this->getType(), $ownVettingType, $type, $otherVettingType);
}

public function typeAndIdentifierAreEqual(SecondFactorType $type, SecondFactorIdentifier $identifier): bool
Expand All @@ -41,4 +49,14 @@ public function typeAndIdentifierAreEqual(SecondFactorType $type, SecondFactorId
$identifierIsEqual = $this->getIdentifier()->equals($identifier);
return $typeIsEqual && $identifierIsEqual;
}

/**
* By default the vetting type of a token is unknown UNITL it has been vetted
* So only the VettedSecondFactor implementation returns anything other than
* the UnknownVettingType
*/
public function vettingType(): VettingType
{
return new UnknownVettingType();
}
}
4 changes: 4 additions & 0 deletions src/Surfnet/Stepup/Identity/Entity/SecondFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace Surfnet\Stepup\Identity\Entity;

use Surfnet\Stepup\Identity\Value\SecondFactorIdentifier;
use Surfnet\Stepup\Identity\Value\VettingType;
use Surfnet\StepupBundle\Service\SecondFactorTypeService;
use Surfnet\StepupBundle\Value\SecondFactorType;

Expand All @@ -28,6 +29,7 @@ public function hasEqualOrHigherLoaComparedTo(SecondFactor $comparable, SecondFa

public function hasTypeWithEqualOrLowerLoaComparedTo(
SecondFactorType $type,
VettingType $vettingType,
SecondFactorTypeService $service,
): bool;

Expand All @@ -36,4 +38,6 @@ public function typeAndIdentifierAreEqual(SecondFactorType $type, SecondFactorId
public function getType(): SecondFactorType;

public function getIdentifier(): SecondFactorIdentifier;

public function vettingType(): VettingType;
}
1 change: 1 addition & 0 deletions src/Surfnet/Stepup/Identity/Entity/VettedSecondFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Surfnet\Stepup\Identity\Value\SecondFactorId;
use Surfnet\Stepup\Identity\Value\SecondFactorIdentifier;
use Surfnet\Stepup\Identity\Value\VettingType;
use Surfnet\StepupBundle\Service\SecondFactorTypeService;
use Surfnet\StepupBundle\Value\SecondFactorType;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Surfnet/Stepup/Identity/Event/IdentityCreatedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getAuditLogMetadata(): Metadata
return $metadata;
}

public static function deserialize(array $data): IdentityCreatedEvent
public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['id']),
Expand Down
2 changes: 1 addition & 1 deletion src/Surfnet/Stepup/Identity/Value/ContactInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getContactInformation()
return $this->contactInformation;
}

public function jsonSerialize()
public function jsonSerialize(): string
{
return $this->contactInformation;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function __toString(): string
return (string)$this->role;
}

public static function deserialize(array $data)
public static function deserialize(array $data): self
{
return new self($data['role']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static function create(
return $raLocation;
}

public function jsonSerialize()
public function jsonSerialize(): array
{
return [
'id' => $this->id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st
return $platform->getClobTypeDeclarationSQL($column);
}

public function convertToDatabaseValue($value, AbstractPlatform $platform)
public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
{
if (is_null($value)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st
return $platform->getVarcharTypeDeclarationSQL($column);
}

public function convertToDatabaseValue($value, AbstractPlatform $platform)
public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
{
if (is_null($value)) {
return $value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st
return $platform->getClobTypeDeclarationSQL($column);
}

public function convertToDatabaseValue($value, AbstractPlatform $platform)
public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
{
if (is_null($value)) {
return $value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st
return $platform->getClobTypeDeclarationSQL($column);
}

public function convertToDatabaseValue($value, AbstractPlatform $platform)
public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
{
if (is_null($value)) {
return $value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st
return $platform->getVarcharTypeDeclarationSQL($column);
}

public function convertToDatabaseValue($value, AbstractPlatform $platform)
public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
{
if (is_null($value)) {
return $value;
Expand Down
Loading

0 comments on commit 84a70b1

Please sign in to comment.