namespace OC\Core;
-use OC\Security\IdentityProof\Manager;
use OCP\AppFramework\App;
use OCP\Util;
$container->registerService('defaultMailAddress', function () {
return Util::getDefaultEmailAddress('lostpassword-noreply');
});
- $container->registerService(Manager::class, function () {
- return new Manager(
- \OC::$server->getAppDataDir('identityproof'),
- \OC::$server->getCrypto()
- );
- });
}
}
$this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) {
return new \OC\Security\IdentityProof\Manager(
- $this->getServer()->getAppDataDir('identityproof'),
+ $this->getServer()->query(\OC\Files\AppData\Factory::class),
$this->getServer()->getCrypto()
);
});
namespace OC\Security\IdentityProof;
+use OC\Files\AppData\Factory;
use OCP\Files\IAppData;
use OCP\IUser;
use OCP\Security\ICrypto;
private $crypto;
/**
- * @param IAppData $appData
+ * @param Factory $appDataFactory
* @param ICrypto $crypto
*/
- public function __construct(IAppData $appData,
+ public function __construct(Factory $appDataFactory,
ICrypto $crypto) {
- $this->appData = $appData;
+ $this->appData = $appDataFactory->get('identityproof');
$this->crypto = $crypto;
}
namespace Test\Security\IdentityProof;
+use OC\Files\AppData\Factory;
use OC\Security\IdentityProof\Key;
use OC\Security\IdentityProof\Manager;
use OCP\Files\IAppData;
use Test\TestCase;
class ManagerTest extends TestCase {
+ /** @var Factory|\PHPUnit_Framework_MockObject_MockObject */
+ private $factory;
/** @var IAppData|\PHPUnit_Framework_MockObject_MockObject */
private $appData;
/** @var ICrypto|\PHPUnit_Framework_MockObject_MockObject */
public function setUp() {
parent::setUp();
+
+ /** @var Factory|\PHPUnit_Framework_MockObject_MockObject $factory */
+ $this->factory = $this->createMock(Factory::class);
$this->appData = $this->createMock(IAppData::class);
+ $this->factory->expects($this->any())
+ ->method('get')
+ ->with('identityproof')
+ ->willReturn($this->appData);
+
$this->crypto = $this->createMock(ICrypto::class);
$this->manager = $this->getMockBuilder(Manager::class)
->setConstructorArgs([
- $this->appData,
+ $this->factory,
$this->crypto
])
->setMethods(['generateKeyPair'])
public function testGenerateKeyPair() {
$manager = new Manager(
- $this->appData,
+ $this->factory,
$this->crypto
);
$data = 'MyTestData';
- list($resultPublicKey, $resultPrivateKey) = $this->invokePrivate($manager, 'generateKeyPair');
+ list($resultPublicKey, $resultPrivateKey) = self::invokePrivate($manager, 'generateKeyPair');
openssl_sign($data, $signature, $resultPrivateKey);
$details = openssl_pkey_get_details(openssl_pkey_get_public($resultPublicKey));