1 |
f76f30e1
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Contains ReCaptcha.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Test cases for ReCaptcha module UI.
|
10 |
|
|
*/
|
11 |
|
|
class ReCaptchaAdminUITestCase extends ReCaptchaBaseTestCase {
|
12 |
|
|
|
13 |
|
|
/**
|
14 |
4f315dab
|
Assos Assos
|
* Drupal path of the (general) CAPTCHA admin page.
|
15 |
f76f30e1
|
Assos Assos
|
*/
|
16 |
|
|
const RECAPTCHA_ADMIN_PATH = 'admin/config/people/captcha/recaptcha';
|
17 |
|
|
|
18 |
4f315dab
|
Assos Assos
|
/**
|
19 |
|
|
*
|
20 |
|
|
*/
|
21 |
f76f30e1
|
Assos Assos
|
public static function getInfo() {
|
22 |
|
|
return array(
|
23 |
|
|
'name' => 'ReCaptcha admin UI test',
|
24 |
|
|
'group' => 'reCAPTCHA',
|
25 |
4f315dab
|
Assos Assos
|
'description' => 'Tests reCaptcha admin UI',
|
26 |
f76f30e1
|
Assos Assos
|
);
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
/**
|
30 |
|
|
* Test access to the admin pages.
|
31 |
|
|
*/
|
32 |
4f315dab
|
Assos Assos
|
public function testAdminAccess() {
|
33 |
f76f30e1
|
Assos Assos
|
$this->drupalLogin($this->normal_user);
|
34 |
|
|
$this->drupalGet(self::RECAPTCHA_ADMIN_PATH);
|
35 |
|
|
file_put_contents('tmp.simpletest.html', $this->drupalGetContent());
|
36 |
|
|
$this->assertText(t('Access denied'), 'Normal users should not be able to access the CAPTCHA admin pages', 'CAPTCHA');
|
37 |
|
|
$this->assertResponse(403);
|
38 |
|
|
|
39 |
|
|
$this->drupalLogin($this->admin_user);
|
40 |
|
|
$this->drupalGet(self::RECAPTCHA_ADMIN_PATH);
|
41 |
|
|
$this->assertResponse(200);
|
42 |
|
|
$this->assertField('recaptcha_server_status_check_interval');
|
43 |
|
|
|
44 |
|
|
// Update the interval and make sure it get saved properly.
|
45 |
|
|
$edit = array(
|
46 |
|
|
'recaptcha_server_status_check_interval' => 20,
|
47 |
|
|
'recaptcha_public_key' => '6LekT84SAAAAAE0AqDpG5IrtKoyr7OOiE82MtXgJ',
|
48 |
|
|
'recaptcha_private_key' => '6LekT84SAAAAAE0AqDpG5IrtKoyr7OOiE81MtXgJ',
|
49 |
|
|
);
|
50 |
|
|
$this->drupalPost(NULL, $edit, t('Save configuration'));
|
51 |
|
|
$this->assertText(t('The configuration options have been saved.'));
|
52 |
|
|
$this->assertFieldByName('recaptcha_server_status_check_interval', 20);
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
} |