Ejemplo n.º 1
0
 /**
  * @runInSeparateProcess
  * @preserveGlobalState disabled
  */
 public function testInvalidLdapResourceIsNotValid()
 {
     $this->setUpResourceFactoryMock(Mockery::mock()->shouldReceive('bind')->andThrow('\\Exception')->getMock());
     // Passing array(null) is required to make Mockery call the constructor...
     $form = Mockery::mock('Icinga\\Forms\\Config\\Resource\\LdapResourceForm[getView]', array(null));
     $form->shouldReceive('getView->escape')->with(Mockery::type('string'))->andReturnUsing(function ($s) {
         return $s;
     });
     $form->setTokenDisabled();
     $this->assertFalse(LdapResourceForm::isValidResource($form->create()), 'ResourceForm claims that an invalid ldap resource is valid');
 }
Ejemplo n.º 2
0
 /**
  * Validate the given form data and check whether a BIND-request is successful
  *
  * @param   array   $data   The data to validate
  *
  * @return  bool
  */
 public function isValid($data)
 {
     if (false === parent::isValid($data)) {
         return false;
     }
     if (false === isset($data['skip_validation']) || $data['skip_validation'] == 0) {
         if (false === LdapResourceForm::isValidResource($this)) {
             $this->addSkipValidationCheckbox();
             return false;
         }
     }
     return true;
 }