Skip to content

Commit

Permalink
ci: commit oat-sa/environment-management#
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Nov 5, 2024
1 parent 1335871 commit 8f98cdc
Show file tree
Hide file tree
Showing 74 changed files with 3,294 additions and 1,791 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/sonar.yml

This file was deleted.

18 changes: 8 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@
"type": "library",
"license": "GPL-2.0-only",
"minimum-stability": "dev",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/oat-sa/lib-em-php-proto"
}
],
"require": {
"php": ">=7.4.0",
"lcobucci/jwt": "^4.1.5",
"oat-sa/lib-em-php-proto": "*",
"psr/http-message": "^1.0",
"oat-sa/lib-lti1p3-core": "*",
"psr/log": "^1.0 || ^2.0 || ^3.0"
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"psr/http-message": "^1.0",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"symfony/cache-contracts": "^2.0 || ^3.5@dev",
"symfony/http-client-contracts": "^2.4 || ^3.5@dev"
},
"require-dev": {
"nyholm/psr7": "^1.4",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.5",
"zoltanka/bypass-readonly": "dev-master"
},
"autoload": {
"psr-4": {
Expand All @@ -36,3 +33,4 @@
"sort-packages": true
}
}

14 changes: 11 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
colors="true"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
>
<testsuites>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
</testsuites>

<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>

</phpunit>
1 change: 0 additions & 1 deletion sonar-project.properties

This file was deleted.

41 changes: 41 additions & 0 deletions src/Converter/LtiPlatformConverter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2022-2024 (original work) Open Assessment Technologies SA;
*/

declare(strict_types=1);

namespace OAT\Library\EnvironmentManagementClient\Converter;

use OAT\Library\EnvironmentManagementClient\Model\LtiPlatformInterface;
use OAT\Library\Lti1p3Core\Platform\Platform;
use OAT\Library\Lti1p3Core\Platform\PlatformInterface;

class LtiPlatformConverter
{
public function convert(LtiPlatformInterface $platform): PlatformInterface
{
return new Platform(
$platform->getId(),
$platform->getName(),
$platform->getAudience(),
$platform->getOidcAuthenticationUrl(),
$platform->getOauth2AccessTokenUrl()
);
}
}
110 changes: 110 additions & 0 deletions src/Converter/LtiRegistrationConverter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2022-2024 (original work) Open Assessment Technologies SA;
*/

declare(strict_types=1);

namespace OAT\Library\EnvironmentManagementClient\Converter;

use InvalidArgumentException;
use OAT\Library\EnvironmentManagementClient\Model\LtiRegistrationInterface;
use OAT\Library\EnvironmentManagementClient\Model\TenantAwareRegistration;
use OAT\Library\EnvironmentManagementClient\Model\TenantAwareRegistrationInterface;
use OAT\Library\Lti1p3Core\Registration\Registration;
use OAT\Library\Lti1p3Core\Registration\RegistrationInterface;
use OAT\Library\Lti1p3Core\Security\Key\KeyChainFactoryInterface;

class LtiRegistrationConverter
{
private LtiPlatformConverter $platformConverter;
private LtiToolConverter $toolConverter;
private KeyChainFactoryInterface $keyChainFactory;

public function __construct(
LtiPlatformConverter $platformConverter,
LtiToolConverter $toolConverter,
KeyChainFactoryInterface $keyChainFactory,
) {
$this->platformConverter = $platformConverter;
$this->toolConverter = $toolConverter;
$this->keyChainFactory = $keyChainFactory;
}

public function convert(LtiRegistrationInterface $ltiRegistration): RegistrationInterface
{
if (null === $ltiRegistration->getLtiPlatform()) {
throw new InvalidArgumentException(sprintf(
'LTI Platform not returned for Registration %s',
$ltiRegistration->getId(),
));
}

if (null === $ltiRegistration->getLtiTool()) {
throw new InvalidArgumentException(sprintf(
'LTI Tool not returned for Registration %s',
$ltiRegistration->getId(),
));
}

$ltiPlatformKeyChain = $ltiRegistration->getPlatformKeyChain();
$ltiToolKeyChain = $ltiRegistration->getToolKeyChain();

return new Registration(
$ltiRegistration->getId(),
$ltiRegistration->getClientId(),
$this->platformConverter->convert($ltiRegistration->getLtiPlatform()),
$this->toolConverter->convert($ltiRegistration->getLtiTool()),
$ltiRegistration->getDeploymentIds(),
$ltiPlatformKeyChain
&& $ltiPlatformKeyChain->getPublicKey()
&& $ltiPlatformKeyChain->getPrivateKey()
&& $ltiPlatformKeyChain->getKeySetName()
? $this->keyChainFactory->create(
$ltiPlatformKeyChain?->getId(),
$ltiPlatformKeyChain?->getKeySetName(),
$ltiPlatformKeyChain?->getPublicKey(),
$ltiPlatformKeyChain?->getPrivateKey(),
$ltiPlatformKeyChain?->getPrivateKeyPassphrase(),
)
: null,
$ltiToolKeyChain
&& $ltiToolKeyChain->getPublicKey()
&& $ltiToolKeyChain->getPrivateKey()
&& $ltiToolKeyChain->getKeySetName()
? $this->keyChainFactory->create(
$ltiToolKeyChain->getId(),
$ltiToolKeyChain->getKeySetName(),
$ltiToolKeyChain->getPublicKey(),
$ltiToolKeyChain->getPrivateKey(),
$ltiToolKeyChain->getPrivateKeyPassphrase(),
)
: null,
$ltiRegistration->getPlatformJwksUrl(),
$ltiRegistration->getToolJwksUrl(),
);
}

public function convertWithTenantId(LtiRegistrationInterface $ltiRegistration): TenantAwareRegistrationInterface
{
return TenantAwareRegistration::fromBaseRegistration(
$this->convert($ltiRegistration),
$ltiRegistration->getTenantId(),
);
}
}
42 changes: 42 additions & 0 deletions src/Converter/LtiToolConverter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2022-2024 (original work) Open Assessment Technologies SA;
*/

declare(strict_types=1);

namespace OAT\Library\EnvironmentManagementClient\Converter;

use OAT\Library\EnvironmentManagementClient\Model\LtiToolInterface;
use OAT\Library\Lti1p3Core\Tool\Tool;
use OAT\Library\Lti1p3Core\Tool\ToolInterface;

class LtiToolConverter
{
public function convert(LtiToolInterface $tool): ToolInterface
{
return new Tool(
$tool->getId(),
$tool->getName(),
$tool->getAudience(),
$tool->getOidcInitiationUrl(),
$tool->getLaunchUrl(),
$tool->getDeepLinkingUrl()
);
}
}
9 changes: 9 additions & 0 deletions src/Exception/ConfigurationNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace OAT\Library\EnvironmentManagementClient\Exception;

class ConfigurationNotFoundException extends EnvironmentManagementClientException
{
}
9 changes: 9 additions & 0 deletions src/Exception/FeatureFlagNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace OAT\Library\EnvironmentManagementClient\Exception;

class FeatureFlagNotFoundException extends EnvironmentManagementClientException
{
}
51 changes: 0 additions & 51 deletions src/Exception/GrpcCallFailedException.php

This file was deleted.

9 changes: 9 additions & 0 deletions src/Exception/LtiRegistrationNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace OAT\Library\EnvironmentManagementClient\Exception;

class LtiRegistrationNotFoundException extends EnvironmentManagementClientException
{
}
Loading

0 comments on commit 8f98cdc

Please sign in to comment.