use Exception;
use OC;
use OC\App\AppManager;
+use OC_App;
use OCP\AppFramework\QueryException;
use OCP\Authentication\TwoFactorAuth\IProvider;
use OCP\IConfig;
$providerClasses = $info['two-factor-providers'];
foreach ($providerClasses as $class) {
try {
+ $this->loadTwoFactorApp($appId);
$provider = OC::$server->query($class);
$providers[$provider->getId()] = $provider;
} catch (QueryException $exc) {
});
}
+ /**
+ * Load an app by ID if it has not been loaded yet
+ *
+ * @param string $appId
+ */
+ protected function loadTwoFactorApp($appId) {
+ if (!OC_App::isAppLoaded($appId)) {
+ OC_App::loadApp($appId);
+ }
+ }
+
/**
* Verify the given challenge
*
$this->session = $this->getMock('\OCP\ISession');
$this->config = $this->getMock('\OCP\IConfig');
- $this->manager = new Manager($this->appManager, $this->session, $this->config);
+ $this->manager = $this->getMockBuilder('\OC\Authentication\TwoFactorAuth\Manager')
+ ->setConstructorArgs([$this->appManager, $this->session, $this->config])
+ ->setMethods(['loadTwoFactorApp']) // Do not actually load the apps
+ ->getMock();
$this->fakeProvider = $this->getMock('\OCP\Authentication\TwoFactorAuth\IProvider');
$this->fakeProvider->expects($this->any())