Skip to content

Commit

Permalink
Add compatability with symfony 6.4 and prepare for 7.0
Browse files Browse the repository at this point in the history
Add attributes to tenant entity
fix deprecations
  • Loading branch information
Matth-- committed Jan 5, 2024
1 parent 4bfebc2 commit 31d61cf
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
- description: 'PHP 8.1 - SF 6.0.*'
php: '8.1'
symfony_version: '6.0.*'
- description: 'PHP 8.3 - SF 6.4.*'
php: '8.3'
symfony_version: '6.4.*'
name: Tests ${{ matrix.description }}
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Repository/TenantRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testSaveTenant(): void
$tenant->setEventType('event');
$repository->save($tenant);

self::getContainer()->get(EntityManagerInterface::class)->clear(Tenant::class);
self::getContainer()->get(EntityManagerInterface::class)->clear();

$this->assertNotNull($repository->findByClientKey('new_client_key'));
}
Expand Down
2 changes: 2 additions & 0 deletions Tests/Functional/app/config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ doctrine:
driver: pdo_sqlite
path: "%kernel.cache_dir%/test-database.sqlite"
orm:
enable_lazy_ghost_objects: true
report_fields_where_declared: true
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
2 changes: 1 addition & 1 deletion Tests/Functional/app/config/routes.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
controllers:
resource: ../src/Controller/
type: annotation
type: attribute

ac:
resource: "@AtlassianConnectBundle/Resources/config/routing.php"
2 changes: 2 additions & 0 deletions Tests/Functional/app/src/Controller/ProtectedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ final class ProtectedController extends AbstractController
/**
* @Route("/protected/route")
*/
#[Route('/protected/route')]
public function protectedRoute(): Response
{
return new Response('OK');
Expand All @@ -21,6 +22,7 @@ public function protectedRoute(): Response
/**
* @Route("/protected/license-route", defaults={"requires_license": "true"})
*/
#[Route('/protected/license-route', defaults: ['requires_license' => true])]
public function licenseProtectedRoute(): Response
{
return new Response('OK');
Expand Down
9 changes: 2 additions & 7 deletions Tests/Listener/LicenseListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,7 @@ protected function setUp(): void

public function testItSkipsOnASubRequest(): void
{
$attributeParameterBag = $this->createMock(ParameterBagInterface::class);
$attributeParameterBag
->expects($this->never())
->method('get');

$request = new Request();
$request->attributes = $attributeParameterBag;
$request = new Request([], [], []);

$event = $this->getEvent(
$this->kernel,
Expand All @@ -48,6 +42,7 @@ public function testItSkipsOnASubRequest(): void
);

$this->getLicenseListener()->onKernelRequest($event);
$this->assertNull($event->getResponse());
}

public function testItSkipsWhenTheRouteIsNotNullAndRouteRequiresNoLicense(): void
Expand Down
4 changes: 2 additions & 2 deletions Tests/Service/AtlassianRestClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function testGetTenantFromTokenStorage(): void
public function testNoTenantInToken(): void
{
$this->expectException(\RuntimeException::class);
$this->expectDeprecationMessage('Could not get tenant from token');
$this->expectExceptionMessage('Could not get tenant from token');

$this->tokenStorage
->expects($this->once())
Expand All @@ -164,7 +164,7 @@ public function testNoTenantInToken(): void
public function testNotInTenantContext(): void
{
$this->expectException(\RuntimeException::class);
$this->expectDeprecationMessage('Current user is not a Tenant');
$this->expectExceptionMessage('Current user is not a Tenant');

$this->tokenStorage
->expects($this->once())
Expand Down
1 change: 1 addition & 0 deletions src/Entity/Tenant.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity()
*/
#[ORM\Entity, ORM\Table(name: 'tenant'), ORM\HasLifecycleCallbacks]
class Tenant implements TenantInterface
{
use TenantTrait;
Expand Down
19 changes: 19 additions & 0 deletions src/Entity/TenantTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace AtlassianConnectBundle\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

trait TenantTrait
Expand All @@ -15,27 +16,31 @@ trait TenantTrait
* @ORM\Id()
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Column(name: 'id', type: Types::INTEGER), ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')]
private $id;

/**
* @var string
*
* @ORM\Column(name="addon_key", type="string", length=255)
*/
#[ORM\Column(name: 'addon_key', type: Types::STRING, length: 255)]
private $addonKey;

/**
* @var string
*
* @ORM\Column(name="client_key", type="string", length=255, unique=true)
*/
#[ORM\Column(name: 'client_key', type: Types::STRING, length: 255, unique: true)]
private $clientKey;

/**
* @var string|null
*
* @ORM\Column(name="oauth_client_id", type="string", length=255, nullable=true)
*/
#[ORM\Column(name: 'oauth_client_id', type: Types::STRING, length: 255, nullable: true)]
private $oauthClientId;

/**
Expand All @@ -48,88 +53,101 @@ trait TenantTrait
*
* @ORM\Column(name="public_key", type="string", length=255)
*/
#[ORM\Column(name: 'public_key', type: Types::STRING, length: 255)]
private $publicKey;

/**
* @var string
*
* @ORM\Column(name="shared_secret", type="string", length=255)
*/
#[ORM\Column(name: 'shared_secret', type: Types::STRING, length: 255)]
private $sharedSecret;

/**
* @var string
*
* @ORM\Column(name="server_version", type="string", length=255)
*/
#[ORM\Column(name: 'server_version', type: Types::STRING, length: 255)]
private $serverVersion;

/**
* @var string
*
* @ORM\Column(name="plugins_version", type="string", length=255)
*/
#[ORM\Column(name: 'plugins_version', type: Types::STRING, length: 255)]
private $pluginsVersion;

/**
* @var string
*
* @ORM\Column(name="base_url", type="string", length=255)
*/
#[ORM\Column(name: 'base_url', type: Types::STRING, length: 255)]
private $baseUrl;

/**
* @var string
*
* @ORM\Column(name="product_type", type="string", length=255)
*/
#[ORM\Column(name: 'product_type', type: Types::STRING, length: 255)]
private $productType;

/**
* @var string
*
* @ORM\Column(name="description", type="string", length=255)
*/
#[ORM\Column(name: 'description', type: Types::STRING, length: 255)]
private $description;

/**
* @var string
*
* @ORM\Column(name="event_type", type="string", length=255)
*/
#[ORM\Column(name: 'event_type', type: Types::STRING, length: 255)]
private $eventType;

/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
#[ORM\Column(name: 'created_at', type: Types::DATETIME_MUTABLE, nullable: false)]
private $createdAt;

/**
* @var \DateTime
*
* @ORM\Column(name="updated_at", type="datetime", nullable=false)
*/
#[ORM\Column(name: 'updated_at', type: Types::DATETIME_MUTABLE, nullable: false)]
private $updatedAt;

/**
* @var bool
*
* @ORM\Column(name="is_white_listed", type="boolean", options={"default":0})
*/
#[ORM\Column(name: 'is_white_listed', type: Types::BOOLEAN, options: ['default' => 0])]
private $isWhiteListed = false;

/**
* @var \DateTime
*
* @ORM\Column(name="white_listed_until", type="datetime", nullable=true)
*/
#[ORM\Column(name: 'white_listed_until', type: Types::DATETIME_MUTABLE, nullable: true)]
private $whiteListedUntil;

/**
* @ORM\PrePersist()
*/
#[ORM\PrePersist]
public function setCreatedAt(): void
{
$this->createdAt = new \DateTime();
Expand All @@ -144,6 +162,7 @@ public function getCreatedAt(): \DateTime
/**
* @ORM\PreUpdate()
*/
#[ORM\PreUpdate]
public function setUpdatedAt(): void
{
$this->updatedAt = new \DateTime();
Expand Down
2 changes: 1 addition & 1 deletion src/Security/JWTUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function loadUserByUsername(string $username): UserInterface
return $this->loadUserByIdentifier($username);
}

public function refreshUser(UserInterface $user): void
public function refreshUser(UserInterface $user): UserInterface
{
throw new UnsupportedUserException('Refresh prohibited');
}
Expand Down

0 comments on commit 31d61cf

Please sign in to comment.