diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php index eda9406..05aa22b 100644 --- a/src/SemanticScuttle/Service/User.php +++ b/src/SemanticScuttle/Service/User.php @@ -854,7 +854,11 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService } /** - * Update User Record + * Update user record. + * Updates all values even if they are empty, except passwords. + * An empty password is not set. + * + * No validation is made here. * * @param integer $uId User ID * @param string $password User Password diff --git a/tests/UserTest.php b/tests/UserTest.php index 9f64efe..c24dd5d 100644 --- a/tests/UserTest.php +++ b/tests/UserTest.php @@ -180,6 +180,30 @@ class UserTest extends TestBase ); } + /** + * Passing an empty string / NULL as key and disabling it + * should keep no key + * + * @covers SemanticScuttle_Service_User::updateUser + */ + public function testUpdateUserPrivateKeyExistingKeyEnabled() + { + $pkey = '12345678901234567890123456789012'; + $uid = $this->addUser(); + + $this->assertTrue( + $this->us->updateUser( + $uid, 'password', 'name', 'test@example.org', '', '', + '-' . $pkey, true + ) + ); + $arUser = $this->us->getUser($uid); + $this->assertInternalType('array', $arUser); + $this->assertEquals( + $pkey, $arUser['privateKey'], 'private key was not enabled' + ); + } + //FIXME: verify I cannot re-use private key of different user