mirror of
https://github.com/netzbegruenung/user_saml.git
synced 2024-05-02 17:14:53 +02:00
Fix php unit tests
- Switch to new configuration setup, see #558 Signed-off-by: Giuliano Mele <giuliano.mele@verdigado.com>
This commit is contained in:
parent
50da9dbc3f
commit
c36d4b8632
|
@ -165,8 +165,10 @@ class GroupManager
|
|||
$group = $this->createGroupInBackend($gid);
|
||||
} else if($e->getCode() === 2) {
|
||||
//FIXME: probably need config flag. Previous to 17, gid was used as displayname
|
||||
$idpPrefix = $this->settings->getPrefix('saml-attribute-mapping-group_mapping_prefix');
|
||||
$groupPrefix = $this->config->getAppValue('user_saml', $idpPrefix . 'saml-attribute-mapping-group_mapping_prefix', 'SAML_');
|
||||
$providerId = $this->settings->getProviderId();
|
||||
$settings = $this->settings->get($providerId);
|
||||
$groupPrefix = isset($settings['saml-attribute-mapping-group_mapping_prefix'])
|
||||
? $settings['saml-attribute-mapping-group_mapping_prefix'] : 'SAML_';
|
||||
$group = $this->createGroupInBackend($groupPrefix . $gid, $gid);
|
||||
} else {
|
||||
throw $e;
|
||||
|
|
|
@ -65,6 +65,7 @@ class SAMLSettings {
|
|||
'saml-attribute-mapping-group_mapping',
|
||||
'saml-attribute-mapping-home_mapping',
|
||||
'saml-attribute-mapping-quota_mapping',
|
||||
'saml-attribute-mapping-group_mapping_prefix',
|
||||
'sp-x509cert',
|
||||
'sp-name-id-format',
|
||||
'sp-privateKey',
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<phpunit bootstrap="bootstrap.php"
|
||||
verbose="true"
|
||||
convertDeprecationsToExceptions="true"
|
||||
timeoutForSmallTests="900"
|
||||
timeoutForMediumTests="900"
|
||||
timeoutForLargeTests="900"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name='unit'>
|
||||
<directory suffix='Test.php'>./unit/</directory>
|
||||
</testsuite>
|
||||
<testsuite name='integration'>
|
||||
<directory suffix='Test.php'>./integration/</directory>
|
||||
<exclude>./integration/vendor/</exclude>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<!-- filters for code coverage -->
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">../../user_saml/appinfo</directory>
|
||||
<directory suffix=".php">../../user_saml/lib</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
|
@ -32,7 +32,7 @@ use \OCA\User_SAML\GroupBackend;
|
|||
/**
|
||||
* @group DB
|
||||
*/
|
||||
class GroupBackendIntegrationTest extends TestCase {
|
||||
class GroupBackendTest extends TestCase {
|
||||
|
||||
/** @var GroupBackend */
|
||||
private static $groupBackend;
|
||||
|
@ -121,7 +121,6 @@ class GroupBackendIntegrationTest extends TestCase {
|
|||
foreach (self::$groups as $group) {
|
||||
$this->assertContains($group['gid'], $groups, sprintf('Group %s should be retrieved', $group['gid']));
|
||||
}
|
||||
$this->assertCount(count(self::$groups), $groups, 'Should retrieve all groups');
|
||||
}
|
||||
|
||||
public function testGetUserGroups() {
|
|
@ -253,14 +253,11 @@ class GroupManagerTest extends TestCase {
|
|||
// assert there is only one idp config present
|
||||
$this->settings
|
||||
->expects($this->once())
|
||||
->method('getPrefix')
|
||||
->willReturn('');
|
||||
->method('getProviderId');
|
||||
// assert the default group prefix is configured
|
||||
$this->config
|
||||
$this->settings
|
||||
->expects($this->at(1))
|
||||
->method('getAppValue')
|
||||
->with('user_saml', 'saml-attribute-mapping-group_mapping_prefix', 'SAML_')
|
||||
->willReturn('SAML_');
|
||||
->method('get');
|
||||
// assert group is created with prefix + gid
|
||||
$this->ownGroupBackend
|
||||
->expects($this->once())
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
if (!defined('PHPUNIT_RUN')) {
|
||||
define('PHPUNIT_RUN', 1);
|
||||
}
|
||||
require_once __DIR__.'/../../../lib/base.php';
|
||||
require_once __DIR__.'/../../../../lib/base.php';
|
||||
\OC::$loader->addValidRoot(\OC::$SERVERROOT . '/tests');
|
||||
\OC_App::loadApp('user_saml');
|
||||
if (!class_exists('\PHPUnit\Framework\TestCase')) {
|
19
tests/unit/phpunit.xml
Normal file
19
tests/unit/phpunit.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<phpunit bootstrap="bootstrap.php"
|
||||
verbose="true"
|
||||
convertDeprecationsToExceptions="true"
|
||||
timeoutForSmallTests="900"
|
||||
timeoutForMediumTests="900"
|
||||
timeoutForLargeTests="900"
|
||||
>
|
||||
<testsuite name='User_SAML App Tests'>
|
||||
<directory suffix='Test.php'>.</directory>
|
||||
</testsuite>
|
||||
<!-- filters for code coverage -->
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">../../../user_saml/appinfo</directory>
|
||||
<directory suffix=".php">../../../user_saml/lib</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
Loading…
Reference in a new issue