Exemplo n.º 1
0
 /**
  * test the user authentication to TAO and to the API
  */
 public function testAuth()
 {
     //is the user in the db
     $this->assertFalse($this->userService->loginAvailable($this->testUserData[PROPERTY_USER_LOGIN]));
     if (tao_models_classes_UserService::singleton()->isASessionOpened()) {
         tao_models_classes_UserService::singleton()->logout();
     }
     //no other user session
     $this->assertFalse(tao_models_classes_UserService::singleton()->isASessionOpened());
     //check user login
     $this->assertTrue($this->userService->loginUser($this->testUserData[PROPERTY_USER_LOGIN], $this->clearPassword));
     //check session
     $this->assertTrue(tao_models_classes_UserService::singleton()->isASessionOpened());
     $currentUser = $this->userService->getCurrentUser();
     $this->assertIsA($currentUser, 'core_kernel_classes_Resource');
     foreach ($this->testUserData as $prop => $value) {
         try {
             $property = new core_kernel_classes_Property($prop);
             $v = $currentUser->getUniquePropertyValue(new core_kernel_classes_Property($prop));
             $v = $v instanceof core_kernel_classes_Resource ? $v->getUri() : $v->literal;
             $this->assertEquals($value, $v);
         } catch (common_Exception $ce) {
             $this->fail($ce);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * action used to check if a login can be used
  * @return void
  */
 public function checkLogin()
 {
     if (!tao_helpers_Request::isAjax()) {
         throw new Exception("wrong request mode");
     }
     $data = array('available' => false);
     if ($this->hasRequestParameter('login')) {
         $data['available'] = $this->userService->loginAvailable($this->getRequestParameter('login'));
     }
     $this->returnJson($data);
 }
Exemplo n.º 3
0
 /**
  * Test user removing
  * @see tao_models_classes_UserService::removeUser
  */
 public function testDelete()
 {
     $this->testUser = $this->getUserByLogin($this->testUserData[PROPERTY_USER_LOGIN]);
     $this->assertInstanceOf('core_kernel_classes_Resource', $this->testUser);
     $this->assertTrue($this->userService->removeUser($this->testUser));
     $this->assertTrue($this->userService->loginAvailable($this->testUserData[PROPERTY_USER_LOGIN]));
     $this->testUserUtf8 = $this->getUserByLogin($this->testUserUtf8Data[PROPERTY_USER_LOGIN]);
     $this->assertInstanceOf('core_kernel_classes_Resource', $this->testUserUtf8);
     $this->assertTrue($this->userService->removeUser($this->testUserUtf8));
     $this->assertTrue($this->userService->loginAvailable($this->testUserUtf8Data[PROPERTY_USER_LOGIN]));
 }