several enhancements (#1808)

* show all fields in timesheet api docs
* fix action dropdown links #1806
* apply same validation rules for passwords and for api-tokens #1753
* added "duplicate team" action #1136
This commit is contained in:
Kevin Papst
2020-07-10 03:57:15 +02:00
committed by GitHub
parent ea39d5c74d
commit 19e4ebf88c
22 changed files with 196 additions and 15 deletions

View File

@@ -243,6 +243,24 @@ class ProfileControllerTest extends ControllerBaseTest
$this->assertTrue($passwordEncoder->getEncoder($user)->isPasswordValid($user->getPassword(), 'test1234', $user->getSalt()));
}
public function testPasswordActionFailsIfPasswordLengthToShort()
{
$this->assertFormHasValidationError(
User::ROLE_USER,
'/profile/' . UserFixtures::USERNAME_USER . '/password',
'form[name=user_password]',
[
'user_password' => [
'plainPassword' => [
'first' => 'abcdef1',
'second' => 'abcdef1',
]
]
],
['#user_password_plainPassword_first']
);
}
public function testApiTokenAction()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
@@ -255,15 +273,15 @@ class ProfileControllerTest extends ControllerBaseTest
$passwordEncoder = static::$kernel->getContainer()->get('test.PasswordEncoder');
$this->assertTrue($passwordEncoder->getEncoder($user)->isPasswordValid($user->getApiToken(), UserFixtures::DEFAULT_API_TOKEN, $user->getSalt()));
$this->assertFalse($passwordEncoder->getEncoder($user)->isPasswordValid($user->getApiToken(), 'test123', $user->getSalt()));
$this->assertFalse($passwordEncoder->getEncoder($user)->isPasswordValid($user->getApiToken(), 'test1234', $user->getSalt()));
$this->assertEquals(UserFixtures::USERNAME_USER, $user->getUsername());
$form = $client->getCrawler()->filter('form[name=user_api_token]')->form();
$client->submit($form, [
'user_api_token' => [
'plainApiToken' => [
'first' => 'test123',
'second' => 'test123',
'first' => 'test1234',
'second' => 'test1234',
]
]
]);
@@ -278,7 +296,25 @@ class ProfileControllerTest extends ControllerBaseTest
$user = $this->getUserByRole(User::ROLE_USER);
$this->assertFalse($passwordEncoder->getEncoder($user)->isPasswordValid($user->getApiToken(), UserFixtures::DEFAULT_API_TOKEN, $user->getSalt()));
$this->assertTrue($passwordEncoder->getEncoder($user)->isPasswordValid($user->getApiToken(), 'test123', $user->getSalt()));
$this->assertTrue($passwordEncoder->getEncoder($user)->isPasswordValid($user->getApiToken(), 'test1234', $user->getSalt()));
}
public function testApiTokenActionFailsIfPasswordLengthToShort()
{
$this->assertFormHasValidationError(
User::ROLE_USER,
'/profile/' . UserFixtures::USERNAME_USER . '/api-token',
'form[name=user_api_token]',
[
'user_api_token' => [
'plainApiToken' => [
'first' => 'abcdef1',
'second' => 'abcdef1',
]
]
],
['#user_api_token_plainApiToken_first']
);
}
public function testRolesActionIsSecured()

View File

@@ -205,4 +205,15 @@ class TeamControllerTest extends ControllerBaseTest
$team = $em->getRepository(Team::class)->find(1);
self::assertEquals(1, \count($team->getProjects()));
}
public function testDuplicateAction()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$this->request($client, '/admin/teams/1/duplicate');
$this->assertIsRedirect($client, $this->createUrl('/admin/teams/2/edit'));
$client->followRedirect();
$node = $client->getCrawler()->filter('#team_edit_form_name');
self::assertEquals(1, $node->count());
self::assertEquals('Test team [COPY]', $node->attr('value'));
}
}