-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write contractual base to production entities
The new service will ensure the business rules are followed for this feature. The tests have been updated to cover the new Coin entry on the Manage entity. See: https://www.pivotaltracker.com/story/show/187977233
- Loading branch information
Showing
11 changed files
with
264 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/Surfnet/ServiceProviderDashboard/Domain/Service/ContractualBaseService.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
/** | ||
* Copyright 2024 SURFnet B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace Surfnet\ServiceProviderDashboard\Domain\Service; | ||
|
||
use Surfnet\ServiceProviderDashboard\Domain\Entity\Constants; | ||
use Surfnet\ServiceProviderDashboard\Domain\Entity\ManageEntity; | ||
|
||
class ContractualBaseService | ||
{ | ||
public function writeContractualBase(ManageEntity $entity): void | ||
{ | ||
// 1. The entity must be targeted at the production env | ||
if ($entity->getEnvironment() !== Constants::ENVIRONMENT_PRODUCTION) { | ||
return; | ||
} | ||
|
||
// 2. It must be a SAML or OIDC entity | ||
$protocol = $entity->getProtocol()->getProtocol(); | ||
if (!in_array($protocol, [Constants::TYPE_SAML, Constants::TYPE_OPENID_CONNECT_TNG], true)) { | ||
return; | ||
} | ||
|
||
// 3. Determine the contractual base, based on the service type | ||
$serviceType = $entity->getService()->getServiceType(); | ||
$contractualBase = match ($serviceType) { | ||
Constants::SERVICE_TYPE_INSTITUTE => Constants::CONTRACTUAL_BASE_IX, | ||
Constants::SERVICE_TYPE_NON_INSTITUTE => Constants::CONTRACTUAL_BASE_AO, | ||
default => null, | ||
}; | ||
|
||
if ($contractualBase === null) { | ||
return; | ||
} | ||
|
||
// 4. Set the coin value on the entity | ||
$entity->getMetaData()?->getCoin()->setContractualBase($contractualBase); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.