private function assertKuser() { // check copied values $this->assertEquals($this->systemUser->getFirstName(), $this->kuser->getFirstName(), 'first_name for ' . $this->getParams()); $this->assertEquals($this->systemUser->getLastName(), $this->kuser->getLastName(), 'last_name for ' . $this->getParams()); $this->assertEquals($this->systemUser->getEmail(), $this->kuser->getPuserId(), 'puserid for ' . $this->getParams()); $this->assertEquals($this->adminConsolePartnerId, $this->kuser->getPartnerId(), 'partner_id for ' . $this->getParams()); $this->assertEquals($this->systemUser->getEmail(), $this->kuser->getEmail(), 'email for ' . $this->getParams()); $this->assertEquals($this->systemUser->getName(), $this->kuser->getScreenName(), 'screen_name for ' . $this->getParams()); $this->assertEquals($this->systemUser->getName(), $this->kuser->getFullName(), 'full_name for ' . $this->getParams()); if ($this->systemUser->getStatus == systemUser::SYSTEM_USER_ACTIVE) { $this->assertEquals(KuserStatus::ACTIVE, $this->kuser->getStatus(), 'status ' . $this->getParams()); } else { $this->assertEquals(KuserStatus::BLOCKED, $this->kuser->getStatus(), 'status ' . $this->getParams()); } $this->assertEquals($this->systemUser->getDeletedAt(), $this->kuser->getDeletedAt(), 'deleted_at ' . $this->getParams()); $partnerData = unserialize($this->kuser->getPartnerData()); var_dump($partnerData); $this->assertTrue(get_class($partnerData) === 'Kaltura_AdminConsoleUserPartnerData', 'PartnerData is not of type Kaltura_AdminConsoleUserPartnerData'); $this->assertEquals($this->systemUser->getIsPrimary(), $partnerData->isPrimary, 'is_primary ' . $this->getParams()); $this->assertEquals($this->systemUser->getRole(), $partnerData->role, 'role ' . $this->getParams()); // check new values $this->assertEquals(true, $this->kuser->getIsAdmin(), 'is_admin for ' . $this->getParams()); $this->assertEquals($this->kuser->getLoginDataId(), $this->loginData->getId()); }
private function assertKuser() { // check copied values $this->assertEquals($this->adminKuser->getFullName(), $this->kuser->getFullName(), 'full_name for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getIcon(), $this->kuser->getIcon(), 'icon for ' . $this->getParams()); $this->assertEquals('__ADMIN__' . $this->adminKuser->getId(), $this->kuser->getPuserId(), 'puserid for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getPartnerId(), $this->kuser->getPartnerId(), 'partner_id for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getPicture(), $this->kuser->getPicture(), 'picture for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getEmail(), $this->kuser->getEmail(), 'email for ' . $this->getParams()); $this->assertEquals($this->adminKuser->getScreenName(), $this->kuser->getScreenName(), 'screen_name for ' . $this->getParams()); // check new values $this->assertEquals(true, $this->kuser->getIsAdmin(), 'is_admin for ' . $this->getParams()); $this->assertEquals($this->kuser->getLoginDataId(), $this->loginData->getId()); }
/** * @dataProvider providerTestMigration */ public function testMigration($kuserId) { $this->assertNull($this->kuser); $this->kuser = kuserPeer::retrieveByPK($kuserId); $this->assertNotNull($this->kuser); $this->assertEquals($this->kuser->getFullName(), trim($this->kuser->getFirstName() . ' ' . $this->kuser->getLastName())); if ($this->kuser->getSalt() && $this->kuser->getSha1Password() && in_array($this->kuser->getPartnerId(), $this->loginPartnerIds)) { $this->assertTrue($this->kuser->getLoginDataId()); $loginData1 = UserLoginDataPeer::retrieveByPK($this->kuser->getLoginDataId()); $this->assertNotNull($loginData1); $loginData2 = UserLoginDataPeer::getByEmail($this->kuser->getEmail()); $this->assertNotNull($loginData2); $this->assertEquals($loginData1->getId(), $loginData2->getId()); $this->assertEquals($this->kuser->getSalt(), $loginData2->getSalt()); $this->assertEquals($this->kuser->getSha1Password(), $loginData2->getSha1Password()); $this->assertEquals($this->kuser->getEmail(), $loginData2->getLoginEmail()); $c = new Criteria(); $c->addAnd(UserLoginDataPeer::LOGIN_EMAIL, $this->kuser->getEmail()); $loginDatas = UserLoginDataPeer::doSelect($c); $this->assertEquals(count($loginDatas), 1); $this->assertEquals($loginDatas[0]->getId(), $loginData1->getId()); $allKusers = kuserPeer::getByLoginDataAndPartner($this->kuser->getLoginDataId(), $this->kuser->getPartnerId()); $this->assertEquals(count($allKusers), 1); } else { if ($this->kuser->getPartnerId() != $this->adminConsolePartnerId && substr($this->kuser->getPuserId(), 0, 9) != '__ADMIN__') { $this->assertNull($this->kuser->getLoginDataId()); } } if ($this->kuser->getPartnerId() == $this->adminConsolePartnerId || substr($this->kuser->getPuserId(), 0, 9) == '__ADMIN__') { $this->assertTrue($this->kuser->getIsAdmin()); } else { $this->assertFalse($this->kuser->getIsAdmin()); } if ($this->kuser->getIsAdmin()) { $this->assertTrue($this->kuser->getIsAdmin()); } }
/** * Adds a new kuser and user_login_data records as needed * @param kuser $user * @param string $password * @param bool $checkPasswordStructure * @throws kUserException::USER_NOT_FOUND * @throws kUserException::USER_ALREADY_EXISTS * @throws kUserException::INVALID_EMAIL * @throws kUserException::INVALID_PARTNER * @throws kUserException::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED * @throws kUserException::LOGIN_ID_ALREADY_USED * @throws kUserException::PASSWORD_STRUCTURE_INVALID * @throws kPermissionException::ROLE_ID_MISSING * @throws kPermissionException::ONLY_ONE_ROLE_PER_USER_ALLOWED */ public static function addUser(kuser $user, $password = null, $checkPasswordStructure = true, $sendEmail = null) { if (!$user->getPuserId()) { throw new kUserException('', kUserException::USER_ID_MISSING); } // check if user with the same partner and puserId already exists $existingUser = kuserPeer::getKuserByPartnerAndUid($user->getPartnerId(), $user->getPuserId()); if ($existingUser) { throw new kUserException('', kUserException::USER_ALREADY_EXISTS); } // check if roles are valid - may throw exceptions if (!$user->getRoleIds() && $user->getIsAdmin()) { // assign default role according to user type admin / normal $userRoleId = $user->getPartner()->getAdminSessionRoleId(); $user->setRoleIds($userRoleId); } UserRolePeer::testValidRolesForUser($user->getRoleIds(), $user->getPartnerId()); if ($user->getScreenName() === null) { $user->setScreenName($user->getPuserId()); } if ($user->getFullName() === null) { $user->setFirstName($user->getPuserId()); } if (is_null($user->getStatus())) { $user->setStatus(KuserStatus::ACTIVE); } // if password is set, user should be able to login to the system - add a user_login_data record if ($password || $user->getIsAdmin()) { // throws an action on error $user->enableLogin($user->getEmail(), $password, $checkPasswordStructure, $sendEmail); } $user->save(); return $user; }