Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"webmozart/assert": "^1.12.1"
},
"require-dev": {
"ext-pdo": "*",
"behat/behat": "^3.27",
"behat/mink": "^1.13",
"behat/mink-browserkit-driver": "^2.3",
Expand Down
6 changes: 4 additions & 2 deletions composer.lock

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

3 changes: 0 additions & 3 deletions config/openconext/parameters.yaml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ parameters:
database_gateway_user: gateway_user
database_gateway_password: gateway_secret

database_deploy_user: gw_deploy_user
database_deploy_password: gw_deploy_secret

mailer_transport: smtp
mailer_host: mailcatcher
mailer_user: ~
Expand Down
17 changes: 0 additions & 17 deletions config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ doctrine:
password: "%database_gateway_password%"
server_version: "%database_server_version%"
charset: UTF8
deploy:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_gateway_name%"
user: "%database_deploy_user%"
password: "%database_deploy_password%"
server_version: "%database_server_version%"
charset: UTF8
orm:
default_entity_manager: gateway
auto_generate_proxy_classes: "%kernel.debug%"
Expand All @@ -36,11 +27,6 @@ doctrine:
mapping: true
type: attribute
is_bundle: true
deploy:
report_fields_where_declared: true
connection: deploy
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
mappings: []

when@smoketest:
doctrine:
Expand All @@ -49,9 +35,6 @@ when@smoketest:
connections:
gateway:
dbname: gateway_test
host: mariadb
password: gw_deploy_secret
user: gw_deploy_user

when@test:
doctrine:
Expand Down
34 changes: 20 additions & 14 deletions config/services_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,33 @@ services:
gateway.service.gateway_api_sms:
class: Surfnet\StepupGateway\ApiBundle\Tests\TestDouble\Service\SmsService

Surfnet\StepupGateway\Behat\ValueObject\SmoketestPdoFactory:
class: Surfnet\StepupGateway\Behat\ValueObject\SmoketestPdoFactory
arguments:
- '%database_host%'
- 'gw_deploy_user'
- 'gw_deploy_secret'
- 'gateway_test'

Surfnet\StepupGateway\Behat\Repository\SecondFactorRepository:
class: Surfnet\StepupGateway\Behat\Repository\SecondFactorRepository
arguments:
- '@Surfnet\StepupGateway\Behat\Repository\Connection'
- '@Surfnet\StepupGateway\Behat\ValueObject\SmoketestPdoFactory'

Surfnet\StepupGateway\Behat\Repository\SamlEntityRepository:
class: Surfnet\StepupGateway\Behat\Repository\SamlEntityRepository
arguments:
- '@Surfnet\StepupGateway\Behat\Repository\Connection'
- '@Surfnet\StepupGateway\Behat\ValueObject\SmoketestPdoFactory'

Surfnet\StepupGateway\Behat\Repository\WhitelistRepository:
class: Surfnet\StepupGateway\Behat\Repository\WhitelistRepository
arguments:
- '@Surfnet\StepupGateway\Behat\Repository\Connection'
- '@Surfnet\StepupGateway\Behat\ValueObject\SmoketestPdoFactory'

Surfnet\StepupGateway\Behat\Repository\InstitutionConfigurationRepository:
class: Surfnet\StepupGateway\Behat\Repository\InstitutionConfigurationRepository
arguments:
- '@Surfnet\StepupGateway\Behat\Repository\Connection'

Surfnet\StepupGateway\Behat\Repository\Connection:
class: Surfnet\StepupGateway\Behat\Repository\Connection
arguments:
- '%env(APP_ENV)%'
- '%database_deploy_user%'
- '%database_deploy_password%'
- 'gateway_test'
- '%database_host%'

- '@Surfnet\StepupGateway\Behat\ValueObject\SmoketestPdoFactory'

Surfnet\StepupGateway\Behat\Controller\ServiceProviderController:
class: Surfnet\StepupGateway\Behat\Controller\ServiceProviderController
Expand Down Expand Up @@ -69,6 +67,13 @@ services:
- "@logger"
public: false

Surfnet\StepupGateway\Behat\Service\DatabaseSchemaService:
class: Surfnet\StepupGateway\Behat\Service\DatabaseSchemaService
public: true
arguments:
- '@doctrine.orm.gateway_entity_manager'
- '@Surfnet\StepupGateway\Behat\ValueObject\SmoketestPdoFactory'

Surfnet\StepupGateway\Behat\Service\FixtureService:
class: Surfnet\StepupGateway\Behat\Service\FixtureService
public: true
Expand All @@ -82,6 +87,7 @@ services:
public: true
arguments:
$fixtureService: '@Surfnet\StepupGateway\Behat\Service\FixtureService'
$databaseSchemaService: '@Surfnet\StepupGateway\Behat\Service\DatabaseSchemaService'
$logger: '@logger'

Surfnet\StepupGateway\Behat\ServiceProviderContext:
Expand Down
19 changes: 13 additions & 6 deletions tests/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use RuntimeException;
use SAML2\Compat\ContainerSingleton;
use Surfnet\SamlBundle\Tests\TestSaml2Container;
use Surfnet\StepupGateway\Behat\Service\DatabaseSchemaService;
use Surfnet\StepupGateway\Behat\Service\FixtureService;

class FeatureContext implements Context
Expand All @@ -37,6 +38,11 @@ class FeatureContext implements Context
*/
private $fixtureService;

/**
* @var DatabaseSchemaService
*/
private static $databaseSchemaService;

private $whitelistedInstitutions = [];

/**
Expand Down Expand Up @@ -66,9 +72,13 @@ class FeatureContext implements Context
*/
private $cookieDomain;

public function __construct(FixtureService $fixtureService, LoggerInterface $logger)
{
public function __construct(
FixtureService $fixtureService,
DatabaseSchemaService $databaseSchemaService,
LoggerInterface $logger
) {
$this->fixtureService = $fixtureService;
self::$databaseSchemaService = $databaseSchemaService;
$this->sso2faCookieName = 'stepup-gateway_sso-on-second-factor-authentication';
$this->sessCookieName = 'MOCKSESSID';
$this->cookieDomain = '.gateway.dev.openconext.local';
Expand All @@ -80,10 +90,7 @@ public function __construct(FixtureService $fixtureService, LoggerInterface $log
#[\Behat\Hook\BeforeFeature]
public static function setupDatabase(BeforeFeatureScope $scope): void
{
// Generate test databases
echo "Preparing test schemas\n";
shell_exec("/var/www/html/bin/console doctrine:schema:drop --env=smoketest --force");
shell_exec("/var/www/html/bin/console doctrine:schema:create --env=smoketest");
self::$databaseSchemaService->resetSchema();
}

#[\Behat\Hook\BeforeScenario]
Expand Down
49 changes: 0 additions & 49 deletions tests/src/Repository/Connection.php

This file was deleted.

12 changes: 5 additions & 7 deletions tests/src/Repository/InstitutionConfigurationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,20 @@
namespace Surfnet\StepupGateway\Behat\Repository;

use Exception;
use PDO;
use Surfnet\StepupGateway\Behat\ValueObject\SmoketestPdoFactory;
use function error_get_last;

/**
* A poor-mans repository, a pdo connection to the test database is established in the constructor
*/
class InstitutionConfigurationRepository
{
private readonly PDO $connection;

/**
* @var Connection
*/
private $connection;

public function __construct(Connection $connection)
public function __construct(SmoketestPdoFactory $factory)
{
$this->connection = $connection;
$this->connection = $factory->createConnection();
}

public function configure(string $institution, string $option, bool $value)
Expand Down
10 changes: 4 additions & 6 deletions tests/src/Repository/SamlEntityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Exception;
use PDO;
use Ramsey\Uuid\Uuid;
use Surfnet\StepupGateway\Behat\ValueObject\SmoketestPdoFactory;

/**
* A poor mans repository, a pdo connection to the test database is established in the constructor
Expand All @@ -31,14 +32,11 @@ class SamlEntityRepository

const SP_ADFS_SSO_LOCATION = 'https://gateway.dev.openconext.local/test/authentication/adfs/sso';

/**
* @var Connection
*/
private $connection;
private readonly PDO $connection;

public function __construct(Connection $connection)
public function __construct(SmoketestPdoFactory $factory)
{
$this->connection = $connection;
$this->connection = $factory->createConnection();
}

public function createSpIfNotExists($entityId, $certificate, $sfoEnabled = false)
Expand Down
10 changes: 4 additions & 6 deletions tests/src/Repository/SecondFactorRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,18 @@
use PDO;
use Ramsey\Uuid\Uuid;
use Surfnet\StepupBundle\Value\VettingType;
use Surfnet\StepupGateway\Behat\ValueObject\SmoketestPdoFactory;

/**
* A poor mans repository, a pdo connection to the test database is established in the constructor
*/
class SecondFactorRepository
{
/**
* @var Connection
*/
private $connection;
private readonly PDO $connection;

public function __construct(Connection $connection)
public function __construct(SmoketestPdoFactory $factory)
{
$this->connection = $connection;
$this->connection = $factory->createConnection();
}

public function create($nameId, $tokenType, $institution, bool $selfAsserted = false, $identifier = null)
Expand Down
10 changes: 4 additions & 6 deletions tests/src/Repository/WhitelistRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@

use Exception;
use PDO;
use Surfnet\StepupGateway\Behat\ValueObject\SmoketestPdoFactory;

/**
* A poor mans repository, a pdo connection to the test database is established in the constructor
*/
class WhitelistRepository
{
/**
* @var Connection
*/
private $connection;
private readonly PDO $connection;

public function __construct(Connection $connection)
public function __construct(SmoketestPdoFactory $factory)
{
$this->connection = $connection;
$this->connection = $factory->createConnection();
}

/**
Expand Down
Loading
Loading