Exemple #1
0
 /**
  * @expectedException \OC\User\NoUserException
  */
 public function testGetHomeDeletedUser()
 {
     $access = $this->getAccessMock();
     $backend = new UserLDAP($access, $this->getMock('\\OCP\\IConfig'));
     $this->prepareMockForUserExists($access);
     $access->connection->expects($this->any())->method('__get')->will($this->returnCallback(function ($name) {
         if ($name === 'homeFolderNamingRule') {
             return 'attr:testAttribute';
         }
         return null;
     }));
     $access->expects($this->any())->method('readAttribute')->will($this->returnValue([]));
     $userMapper = $this->getMockBuilder('\\OCA\\User_LDAP\\Mapping\\UserMapping')->disableOriginalConstructor()->getMock();
     $access->expects($this->any())->method('getUserMapper')->will($this->returnValue($userMapper));
     $this->configMock->expects($this->any())->method('getUserValue')->will($this->returnValue(true));
     //no path at all – triggers OC default behaviour
     $result = $backend->getHome('newyorker');
     $this->assertFalse($result);
 }
Exemple #2
0
 /**
  * @expectedException \Exception
  */
 public function testGetHomeNoPath()
 {
     $access = $this->getAccessMock();
     $backend = new UserLDAP($access, $this->getMock('\\OCP\\IConfig'));
     $this->prepareMockForUserExists($access);
     $access->connection->expects($this->any())->method('__get')->will($this->returnCallback(function ($name) {
         if ($name === 'homeFolderNamingRule') {
             return 'attr:testAttribute';
         }
         return null;
     }));
     $access->expects($this->any())->method('readAttribute')->will($this->returnCallback(function ($dn, $attr) {
         switch ($dn) {
             default:
                 return false;
         }
     }));
     //no path at all – triggers OC default behaviour
     $result = $backend->getHome('newyorker');
     $this->assertFalse($result);
 }
 public function testGetHome()
 {
     $access = $this->getAccessMock();
     $backend = new UserLDAP($access);
     $this->prepareMockForUserExists($access);
     $access->connection->expects($this->any())->method('__get')->will($this->returnCallback(function ($name) {
         if ($name === 'homeFolderNamingRule') {
             return 'attr:testAttribute';
         }
         return null;
     }));
     $access->expects($this->any())->method('readAttribute')->will($this->returnCallback(function ($dn, $attr) {
         switch ($dn) {
             case 'dnOfRoland':
                 if ($attr === 'testAttribute') {
                     return array('/tmp/rolandshome/');
                 }
                 return array();
                 break;
             case 'dnOfLadyOfShadows':
                 if ($attr === 'testAttribute') {
                     return array('susannah/');
                 }
                 return array();
                 break;
             default:
                 return false;
         }
     }));
     //absolut path
     $result = $backend->getHome('gunslinger');
     $this->assertEquals('/tmp/rolandshome/', $result);
     //datadir-relativ path
     $result = $backend->getHome('ladyofshadows');
     $datadir = \OCP\Config::getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
     $this->assertEquals($datadir . '/susannah/', $result);
     //no path at all – triggers OC default behaviour
     $result = $backend->getHome('newyorker');
     $this->assertFalse($result);
 }