Skip to content

Commit

Permalink
Merge branch 'release/2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
MKodde committed Feb 25, 2019
2 parents 7bcc6b3 + f5f080d commit 4793970
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Next release

## 2.0.7
**Bugfix**
* Fix Manage query workflow state #242

## 2.0.6

**Bugfixes**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Surfnet\ServiceProviderDashboard\Application\Exception\InvalidArgumentException;
use Surfnet\ServiceProviderDashboard\Application\Provider\EntityQueryRepositoryProvider;
use Surfnet\ServiceProviderDashboard\Application\ViewObject;
use Surfnet\ServiceProviderDashboard\Application\ViewObject\Manage\Config;
use Surfnet\ServiceProviderDashboard\Domain\Entity\Entity;
use Surfnet\ServiceProviderDashboard\Domain\Entity\Service;
use Surfnet\ServiceProviderDashboard\Infrastructure\Manage\Dto\ManageEntity;
Expand Down Expand Up @@ -65,9 +66,21 @@ class EntityService implements EntityServiceInterface
*/
private $oidcPlaygroundUriProd;

/**
* @var Config
*/
private $testManageConfig;

/**
* @var Config
*/
private $prodManageConfig;

public function __construct(
EntityQueryRepositoryProvider $entityQueryRepositoryProvider,
TicketServiceInterface $ticketService,
Config $testConfig,
Config $productionConfig,
RouterInterface $router,
LoggerInterface $logger,
$oidcPlaygroundUriTest,
Expand All @@ -82,6 +95,8 @@ public function __construct(
$this->logger = $logger;
$this->oidcPlaygroundUriTest = $oidcPlaygroundUriTest;
$this->oidcPlaygroundUriProd = $oidcPlaygroundUriProd;
$this->testManageConfig = $testConfig;
$this->prodManageConfig = $productionConfig;
}

public function createEntityUuid()
Expand Down Expand Up @@ -144,12 +159,18 @@ public function getEntityListForService(Service $service)
$entities[] = ViewObject\Entity::fromEntity($entity, $this->router);
}

$testEntities = $this->findPublishedTestEntitiesByTeamName($service->getTeamName());
$testEntities = $this->findPublishedTestEntitiesByTeamName(
$service->getTeamName(),
$this->testManageConfig->getPublicationStatus()->getCreateStatus()
);
foreach ($testEntities as $result) {
$entities[] = ViewObject\Entity::fromManageTestResult($result, $this->router, $service->getId());
}

$productionEntities = $this->findPublishedProductionEntitiesByTeamName($service->getTeamName());
$productionEntities = $this->findPublishedProductionEntitiesByTeamName(
$service->getTeamName(),
$this->prodManageConfig->getPublicationStatus()->getCreateStatus()
);
foreach ($productionEntities as $result) {
$entities[] = ViewObject\Entity::fromManageProductionResult($result, $this->router, $service->getId());
}
Expand Down Expand Up @@ -215,7 +236,7 @@ private function findPublishedTestEntitiesByTeamName($teamName)
{
return $this->queryRepositoryProvider
->getManageTestQueryClient()
->findByTeamName($teamName);
->findByTeamName($teamName, $this->testManageConfig->getPublicationStatus()->getCreateStatus());
}

/**
Expand All @@ -232,7 +253,7 @@ private function findPublishedProductionEntitiesByTeamName($teamName)
{
$entities = $this->queryRepositoryProvider
->getManageProductionQueryClient()
->findByTeamName($teamName);
->findByTeamName($teamName, $this->prodManageConfig->getPublicationStatus()->getCreateStatus());

// Try to find the tickets in Jira that match the manageIds. If Jira is down or otherwise unavailable, the
// entities are returned without updating their status. This might result in a 're request for delete'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ public function findByManageId($manageId);
public function getMetadataXmlByManageId($manageId);

/**
* @param string $teamname
* @param string $teamName
* @param string $state
*
* @return array|null
*/
public function findByTeamName($teamName);
public function findByTeamName($teamName, $state);
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ services:
arguments:
- '@Surfnet\ServiceProviderDashboard\Application\Provider\EntityQueryRepositoryProvider'
- '@Surfnet\ServiceProviderDashboard\Application\Service\TicketService'
- '@surfnet.manage.configuration.test'
- '@surfnet.manage.configuration.production'
- '@router'
- '@logger'
- '%playground_uri_test%'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,19 @@ public function findByManageId($manageId)
* Query manage for all test entities by given team name.
*
* @param string $teamName
* @param string $state
*
* @return ManageEntity[]|null
*
* @throws QueryServiceProviderException
*/
public function findByTeamName($teamName)
public function findByTeamName($teamName, $state)
{
try {
// Query manage to get the internal id of every SP entity with given team ID.
$searchResults = $this->doSearchQuery([
'metaDataFields.coin:service_team_id' => $teamName,
'state' => 'testaccepted'
'state' => $state
]);

// For each search result, query manage to get the full SP entity data.
Expand Down
26 changes: 23 additions & 3 deletions tests/unit/Application/Service/EntityServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Surfnet\ServiceProviderDashboard\Application\Provider\EntityQueryRepositoryProvider;
use Surfnet\ServiceProviderDashboard\Application\Service\EntityService;
use Surfnet\ServiceProviderDashboard\Application\Service\TicketServiceInterface;
use Surfnet\ServiceProviderDashboard\Application\ViewObject\Manage\Config;
use Surfnet\ServiceProviderDashboard\Domain\Entity\Service;
use Surfnet\ServiceProviderDashboard\Domain\Repository\EntityRepository;
use Surfnet\ServiceProviderDashboard\Infrastructure\Manage\Client\QueryClient as ManageQueryClient;
Expand Down Expand Up @@ -71,11 +72,30 @@ public function setUp()

$provider = new EntityQueryRepositoryProvider($this->repository, $this->manageTest, $this->manageProd);

$manageConfigTest = m::mock(Config::class);
$manageConfigTest
->shouldReceive('getPublicationStatus->getCreateStatus')
->andReturn('testaccepted');

$manageConfigProd = m::mock(Config::class);
$manageConfigProd
->shouldReceive('getPublicationStatus->getCreateStatus')
->andReturn('prodaccepted');

$this->router = m::mock(RouterInterface::class);
$this->router = m::mock(RouterInterface::class);
$logger = m::mock(LoggerInterface::class);
$this->ticketService = m::mock(TicketServiceInterface::class);
$this->service = new EntityService($provider, $this->ticketService, $this->router, $logger, 'playgroundUriTest', 'playgroundUriProd');
$this->service = new EntityService(
$provider,
$this->ticketService,
$manageConfigTest,
$manageConfigProd,
$this->router,
$logger,
'playgroundUriTest',
'playgroundUriProd'
);
}

public function test_it_can_search_manage_test_by_manage_id()
Expand Down Expand Up @@ -133,12 +153,12 @@ public function test_get_entity_list_for_service()

$this->manageTest
->shouldReceive('findByTeamName')
->with($teamName)
->with($teamName, 'testaccepted')
->andReturn([]);

$this->manageProd
->shouldReceive('findByTeamName')
->with($teamName)
->with($teamName, 'prodaccepted')
->andReturn([]);

$this->ticketService
Expand Down

0 comments on commit 4793970

Please sign in to comment.