Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
82beee57
Commit
82beee57
authored
Jun 16, 2016
by
Vincent Petry
Committed by
GitHub
Jun 16, 2016
Browse files
Merge pull request #25132 from owncloud/2fa-load-apps-before-query
load 2FA provider apps before querying classes
parents
39179697
3521f974
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/private/Authentication/TwoFactorAuth/Manager.php
View file @
82beee57
...
...
@@ -24,6 +24,7 @@ namespace OC\Authentication\TwoFactorAuth;
use
Exception
;
use
OC
;
use
OC\App\AppManager
;
use
OC_App
;
use
OCP\AppFramework\QueryException
;
use
OCP\Authentication\TwoFactorAuth\IProvider
;
use
OCP\IConfig
;
...
...
@@ -110,6 +111,7 @@ class Manager {
$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
)
{
...
...
@@ -125,6 +127,17 @@ class Manager {
});
}
/**
* 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
*
...
...
tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
View file @
82beee57
...
...
@@ -55,7 +55,10 @@ class ManagerTest extends TestCase {
$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
())
...
...
@@ -83,6 +86,10 @@ class ManagerTest extends TestCase {
'\OCA\MyCustom2faApp\FakeProvider'
,
],
]));
$this
->
manager
->
expects
(
$this
->
once
())
->
method
(
'loadTwoFactorApp'
)
->
with
(
'mycustom2faapp'
);
}
/**
...
...
@@ -94,6 +101,9 @@ class ManagerTest extends TestCase {
->
method
(
'getEnabledAppsForUser'
)
->
with
(
$this
->
user
)
->
will
(
$this
->
returnValue
([
'faulty2faapp'
]));
$this
->
manager
->
expects
(
$this
->
once
())
->
method
(
'loadTwoFactorApp'
)
->
with
(
'faulty2faapp'
);
$this
->
appManager
->
expects
(
$this
->
once
())
->
method
(
'getAppInfo'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment