Exemple #1
0
	public function testLogin () {
		$user = new User;
		$user->setUsername("test");
		$user->setPassword("test");
		
		$this->userManager->createUser($user);
		PartKeepr::getEM()->flush();
		
		$user2 = new User;
		$user2->setRawUsername("2test");
		$user2->setPassword("test");
		
		/* User shouldn't be able to login, even if we cut numbers and special chars from usernames */
		$this->setExpectedException("de\RaumZeitLabor\PartKeepr\Auth\Exceptions\InvalidLoginDataException");
		$this->userManager->authenticate($user2);
		
	}
Exemple #2
0
	public function testBasics () {
		$user = new User;
		
		$user->setUsername("felicitus");
		$this->assertEquals($user->getUsername(), "felicitus");
		
		$user->setUsername("Timo A. Hummel");
		
		$hashedPassword = "******";
		
		$this->assertEquals($user->getUsername(), "timo_a_hummel");
		
		$user->setPassword("foobar");
		$this->assertEquals($user->comparePassword("foobar"), true, "Error comparing passwords: PasswordTest01");
		$this->assertEquals($user->compareHashedPassword($hashedPassword), true, "Error comparing passwords: PasswordTest02");

		$user->setHashedPassword($hashedPassword);
		$this->assertEquals($user->comparePassword("foobar"), true, "Error comparing passwords: PasswordTest03");
		$this->assertEquals($user->compareHashedPassword($hashedPassword), true, "Error comparing passwords: PasswordTest04");
	}