diff options
Diffstat (limited to 'src/Wallabag')
-rw-r--r-- | src/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListener.php (renamed from src/Wallabag/CoreBundle/EventListener/AuthenticationListener.php) | 2 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Resources/config/services.yml | 2 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/login.html.twig | 1 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php | 93 |
4 files changed, 96 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/EventListener/AuthenticationListener.php b/src/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListener.php index 7c2826ec..bcc84923 100644 --- a/src/Wallabag/CoreBundle/EventListener/AuthenticationListener.php +++ b/src/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListener.php | |||
@@ -9,7 +9,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |||
9 | use FOS\UserBundle\Event\FilterUserResponseEvent; | 9 | use FOS\UserBundle\Event\FilterUserResponseEvent; |
10 | use Wallabag\CoreBundle\Entity\Config; | 10 | use Wallabag\CoreBundle\Entity\Config; |
11 | 11 | ||
12 | class AuthenticationListener implements EventSubscriberInterface | 12 | class RegistrationConfirmedListener implements EventSubscriberInterface |
13 | { | 13 | { |
14 | private $em; | 14 | private $em; |
15 | private $container; | 15 | private $container; |
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index 96ea482a..f2247260 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml | |||
@@ -47,7 +47,7 @@ services: | |||
47 | - @wallabag_core.graby | 47 | - @wallabag_core.graby |
48 | 48 | ||
49 | wallabag_core.registration_confirmed: | 49 | wallabag_core.registration_confirmed: |
50 | class: Wallabag\CoreBundle\EventListener\AuthenticationListener | 50 | class: Wallabag\CoreBundle\EventListener\RegistrationConfirmedListener |
51 | arguments: [@service_container, @doctrine.orm.entity_manager] | 51 | arguments: [@service_container, @doctrine.orm.entity_manager] |
52 | tags: | 52 | tags: |
53 | - { name: kernel.event_subscriber } | 53 | - { name: kernel.event_subscriber } |
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/login.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/login.html.twig index 5437d20c..9a59dfc6 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/login.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Security/login.html.twig | |||
@@ -32,6 +32,7 @@ | |||
32 | <div class="row mts txtcenter"> | 32 | <div class="row mts txtcenter"> |
33 | <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" /> | 33 | <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" /> |
34 | <button type="submit">Login</button> | 34 | <button type="submit">Login</button> |
35 | <a href="{{ path('fos_user_registration_register') }}" class="button">{% trans %}Register{% endtrans %}</a> | ||
35 | <a href="{{ path('forgot_password') }}" class="small">Forgot your password?</a> | 36 | <a href="{{ path('forgot_password') }}" class="small">Forgot your password?</a> |
36 | </div> | 37 | </div> |
37 | </fieldset> | 38 | </fieldset> |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php index 759ef01b..78b4952e 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php | |||
@@ -8,6 +8,99 @@ use Wallabag\CoreBundle\Tests\WallabagCoreTestCase; | |||
8 | 8 | ||
9 | class SecurityControllerTest extends WallabagCoreTestCase | 9 | class SecurityControllerTest extends WallabagCoreTestCase |
10 | { | 10 | { |
11 | public function testRegister() | ||
12 | { | ||
13 | $client = $this->getClient(); | ||
14 | |||
15 | $crawler = $client->request('GET', '/register/'); | ||
16 | |||
17 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
18 | $this->assertContains('Register', $client->getResponse()->getContent()); | ||
19 | } | ||
20 | |||
21 | public function dataForCreateAccountFailed() | ||
22 | { | ||
23 | return array( | ||
24 | array( | ||
25 | array( | ||
26 | 'fos_user_registration_form[email]' => '', | ||
27 | 'fos_user_registration_form[username]' => 'newuser', | ||
28 | 'fos_user_registration_form[plainPassword][first]' => 'mypassword', | ||
29 | 'fos_user_registration_form[plainPassword][second]' => 'mypassword', | ||
30 | ), | ||
31 | 'Please enter an email', | ||
32 | ), | ||
33 | array( | ||
34 | array( | ||
35 | 'fos_user_registration_form[email]' => 'newuser@wallabag.org', | ||
36 | 'fos_user_registration_form[username]' => 'admin', | ||
37 | 'fos_user_registration_form[plainPassword][first]' => 'mypassword', | ||
38 | 'fos_user_registration_form[plainPassword][second]' => 'mypassword', | ||
39 | ), | ||
40 | 'The username is already used', | ||
41 | ), | ||
42 | array( | ||
43 | array( | ||
44 | 'fos_user_registration_form[email]' => 'newuser@wallabag.org', | ||
45 | 'fos_user_registration_form[username]' => 'newuser', | ||
46 | 'fos_user_registration_form[plainPassword][first]' => 'mypassword1', | ||
47 | 'fos_user_registration_form[plainPassword][second]' => 'mypassword2', | ||
48 | ), | ||
49 | 'The entered passwords don't match', | ||
50 | ), | ||
51 | ); | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * @dataProvider dataForCreateAccountFailed | ||
56 | */ | ||
57 | public function testCreateAccountFailed($data, $expectedMessage) | ||
58 | { | ||
59 | $client = $this->getClient(); | ||
60 | |||
61 | $crawler = $client->request('GET', '/register/'); | ||
62 | |||
63 | $form = $crawler->filter('input[type=submit]')->form(); | ||
64 | |||
65 | $client->submit($form, $data); | ||
66 | |||
67 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
68 | $this->assertContains($expectedMessage, $client->getResponse()->getContent()); | ||
69 | } | ||
70 | |||
71 | public function dataForCreateAccountSuccess() | ||
72 | { | ||
73 | return array( | ||
74 | array( | ||
75 | array( | ||
76 | 'fos_user_registration_form[email]' => 'newuser@wallabag.org', | ||
77 | 'fos_user_registration_form[username]' => 'newuser', | ||
78 | 'fos_user_registration_form[plainPassword][first]' => 'mypassword', | ||
79 | 'fos_user_registration_form[plainPassword][second]' => 'mypassword', | ||
80 | ), | ||
81 | ) | ||
82 | ); | ||
83 | } | ||
84 | |||
85 | /** | ||
86 | * @dataProvider dataForCreateAccountSuccess | ||
87 | */ | ||
88 | public function testCreateAccountSuccess($data) | ||
89 | { | ||
90 | $client = $this->getClient(); | ||
91 | |||
92 | $crawler = $client->request('GET', '/register/'); | ||
93 | |||
94 | $form = $crawler->filter('input[type=submit]')->form(); | ||
95 | |||
96 | $client->submit($form, $data); | ||
97 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
98 | |||
99 | $crawler = $client->followRedirect(); | ||
100 | |||
101 | $this->assertContains('The user has been created successfully', $client->getResponse()->getContent()); | ||
102 | } | ||
103 | |||
11 | public function testLogin() | 104 | public function testLogin() |
12 | { | 105 | { |
13 | $client = $this->getClient(); | 106 | $client = $this->getClient(); |