Merge lp:~canonical-isd-hackers/drupal-launchpad/6.x-sso into lp:drupal-launchpad/6.x

Proposed by Szilveszter Farkas
Status: Merged
Merged at revision: not available
Proposed branch: lp:~canonical-isd-hackers/drupal-launchpad/6.x-sso
Merge into: lp:drupal-launchpad/6.x
Diff against target: 146 lines (+85/-4)
3 files modified
TESTING.txt (+22/-0)
openid_launchpad.module (+12/-4)
tests/module.test (+51/-0)
To merge this branch: bzr merge lp:~canonical-isd-hackers/drupal-launchpad/6.x-sso
Reviewer Review Type Date Requested Status
Anthony Lenton (community) Approve
Review via email: mp+24495@code.launchpad.net

Description of the change

This branch contains several updates:

1) Ubuntu SSO endpoints added.

2) Test coverage increased from 21.16% to 39.73%

3) Added notes about testing and code coverage measurement.

To post a comment you must log in.
32. By Szilveszter Farkas

Fix define which can break the whole site.

Revision history for this message
Anthony Lenton (elachuni) wrote :

Looks good in general. Approved, pending a fix in the tests to put back persistent variables the way they were before running the tests.

review: Approve
Revision history for this message
Szilveszter Farkas (phanatic) wrote :

We figured out that the tests use separate database tables, so setting the variables in the tests shouldn't affect production settings.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'TESTING.txt'
2--- TESTING.txt 1970-01-01 00:00:00 +0000
3+++ TESTING.txt 2010-04-30 16:08:58 +0000
4@@ -0,0 +1,22 @@
5+How to run drupal-launchpad unit tests?
6+=======================================
7+
8+You'll need the SimpleTest plugin for Drupal 6, available from here:
9+
10+http://drupal.org/project/simpletest
11+
12+After applying the appropriate patches to Drupal core, and enabling the
13+SimpleTest module, you'll be able to find the tests in the Administration
14+interface under Site building / Testing.
15+
16+
17+How to measure code coverage?
18+=============================
19+
20+Grab the Drupal 6 compatible code_coverage module this branch:
21+
22+https://code.edge.launchpad.net/~canonical-isd-hackers/drupal-launchpad/6.x-code_coverage
23+
24+After applying the two patches to Drupal core and SimpleTest, and finally
25+enabling the Code coverage module, you'll find the reports after each test run
26+under the Code coverage main menu item.
27
28=== modified file 'openid_launchpad.module'
29--- openid_launchpad.module 2009-03-27 11:13:33 +0000
30+++ openid_launchpad.module 2010-04-30 16:08:58 +0000
31@@ -26,6 +26,10 @@
32 define('LAUNCHPAD_TESTING_OP', LAUNCHPAD_TESTING_URL.'+openid');
33 define('LAUNCHPAD_STAGING_URL', 'https://login.staging.launchpad.net/');
34 define('LAUNCHPAD_STAGING_OP', LAUNCHPAD_STAGING_URL.'+openid');
35+define('UBUNTU_SSO_PRODUCTION_URL', 'https://login.ubuntu.com/');
36+define('UBUNTU_SSO_PRODUCTION_OP', UBUNTU_SSO_PRODUCTION_URL.'+openid');
37+define('UBUNTU_SSO_STAGING_URL', 'https://login.staging.ubuntu.com/');
38+define('UBUNTU_SSO_STAGING_OP', UBUNTU_SSO_STAGING_URL.'+openid');
39
40 /**
41 * Implementation of hook_menu.
42@@ -335,7 +339,9 @@
43 function get_expected_endpoint() {
44 $endpoints = array (LAUNCHPAD_PRODUCTION_URL => LAUNCHPAD_PRODUCTION_OP,
45 LAUNCHPAD_TESTING_URL => LAUNCHPAD_TESTING_OP,
46- LAUNCHPAD_STAGING_URL => LAUNCHPAD_STAGING_OP);
47+ LAUNCHPAD_STAGING_URL => LAUNCHPAD_STAGING_OP,
48+ UBUNTU_SSO_PRODUCTION_URL => UBUNTU_SSO_PRODUCTION_OP,
49+ UBUNTU_SSO_STAGING_URL => UBUNTU_SSO_STAGING_OP);
50 $current_server = variable_get('openid_launchpad_server', LAUNCHPAD_PRODUCTION_URL);
51 return $endpoints[$current_server];
52 }
53@@ -414,9 +420,11 @@
54 '#type' => 'radios',
55 '#title' => t('Select server'),
56 '#options' => array(
57- LAUNCHPAD_PRODUCTION_URL => t('Production') . " (" . LAUNCHPAD_PRODUCTION_URL . ")",
58- LAUNCHPAD_STAGING_URL => t('Staging') . " (" . LAUNCHPAD_STAGING_URL . ")",
59- LAUNCHPAD_TESTING_URL => t('Testing') . " (" . LAUNCHPAD_TESTING_URL . ")",
60+ LAUNCHPAD_PRODUCTION_URL => t('Production') . " (" . LAUNCHPAD_PRODUCTION_URL . ")",
61+ LAUNCHPAD_STAGING_URL => t('Staging') . " (" . LAUNCHPAD_STAGING_URL . ")",
62+ LAUNCHPAD_TESTING_URL => t('Testing') . " (" . LAUNCHPAD_TESTING_URL . ")",
63+ UBUNTU_SSO_PRODUCTION_URL => t('Ubuntu SSO production') . " (" . UBUNTU_SSO_PRODUCTION_URL . ")",
64+ UBUNTU_SSO_STAGING_URL => t('Ubuntu SSO staging') . " (" . UBUNTU_SSO_STAGING_URL . ")",
65 ),
66 '#default_value' => variable_get('openid_launchpad_server', LAUNCHPAD_PRODUCTION_URL),
67 );
68
69=== modified file 'tests/module.test'
70--- tests/module.test 2009-03-03 01:20:23 +0000
71+++ tests/module.test 2010-04-30 16:08:58 +0000
72@@ -43,6 +43,11 @@
73 $this->assertFalse($result);
74 }
75
76+ function testDrupalLaunchpadNotAllowPasswordPageAccess() {
77+ $result = allow_password_page_access();
78+ $this->assertFalse($result);
79+ }
80+
81 function testDrupalLaunchpadHideUserAccountPagesWhenOptionNotSet() {
82 variable_del('openid_launchpad_hide_account');
83 $result = hide_user_account_pages();
84@@ -67,6 +72,16 @@
85 $this->assertFalse($result);
86 }
87
88+ function testDrupalLaunchpadAllowLoginPageAccess() {
89+ $result = allow_login_page_access();
90+ $this->assertTrue($result);
91+ }
92+
93+ function testDrupalLaunchpadAllowRegisterPageAccess() {
94+ $result = allow_register_page_access();
95+ $this->assertFalse($result);
96+ }
97+
98 function testDrupalLaunchpadDetectNonOpenIDResponse() {
99 unset($_SESSION['openid']);
100 $result = allow_non_login_page_access();
101@@ -135,9 +150,45 @@
102 $result = get_expected_endpoint();
103 $this->assertEqual($result, LAUNCHPAD_STAGING_OP);
104
105+ variable_set('openid_launchpad_server', UBUNTU_SSO_PRODUCTION_URL);
106+ $result = get_expected_endpoint();
107+ $this->assertEqual($result, UBUNTU_SSO_PRODUCTION_OP);
108+
109+ variable_set('openid_launchpad_server', UBUNTU_SSO_STAGING_URL);
110+ $result = get_expected_endpoint();
111+ $this->assertEqual($result, UBUNTU_SSO_STAGING_OP);
112+
113 variable_del('openid_launchpad_server');
114 }
115
116+ function testDrupalLaunchpadAdminOverviewForm() {
117+ variable_set('openid_launchpad_hide_account', true);
118+ variable_set('openid_launchpad_sync_user', true);
119+ variable_set('openid_launchpad_prevent_register', true);
120+
121+ $form = launchpad_admin_overview();
122+ $this->assertEqual($form['#submit'], array('launchpad_admin_overview_submit'));
123+ $this->assertEqual($form['trust_root']['#type'], 'markup');
124+ $this->assertTrue(strpos($form['trust_root']['#value'], 'This site\'s trust root/realm is:'));
125+ $this->assertEqual($form['openid_launchpad_server']['#type'], 'radios');
126+ $this->assertEqual($form['openid_launchpad_server']['#options'][LAUNCHPAD_PRODUCTION_URL], 'Production (https://login.launchpad.net/)');
127+ $this->assertEqual($form['openid_launchpad_server']['#options'][LAUNCHPAD_STAGING_URL], 'Staging (https://login.staging.launchpad.net/)');
128+ $this->assertEqual($form['openid_launchpad_server']['#options'][LAUNCHPAD_TESTING_URL], 'Testing (https://login.demo.launchpad.net/)');
129+ $this->assertEqual($form['openid_launchpad_server']['#options'][UBUNTU_SSO_PRODUCTION_URL], 'Ubuntu SSO production (https://login.ubuntu.com/)');
130+ $this->assertEqual($form['openid_launchpad_server']['#options'][UBUNTU_SSO_STAGING_URL], 'Ubuntu SSO staging (https://login.staging.ubuntu.com/)');
131+ $this->assertEqual($form['openid_launchpad_server']['#default_value'], 'https://login.launchpad.net/');
132+ $this->assertEqual($form['sso']['openid_launchpad_hide_account']['#title'], 'Prevent users from accessing \'My Account\' functionality');
133+ $this->assertEqual($form['sso']['openid_launchpad_hide_account']['#default_value'], true);
134+ $this->assertEqual($form['sso']['openid_launchpad_sync_user']['#title'], 'Keep users\' name and email in sync with launchpad');
135+ $this->assertEqual($form['sso']['openid_launchpad_sync_user']['#default_value'], true);
136+ $this->assertEqual($form['sso']['openid_launchpad_prevent_register']['#title'], 'Prevent users from using the registration form');
137+ $this->assertEqual($form['sso']['openid_launchpad_prevent_register']['#default_value'], true);
138+
139+ variable_del('openid_launchpad_hide_account');
140+ variable_del('openid_launchpad_sync_user');
141+ variable_del('openid_launchpad_prevent_register');
142+ }
143+
144 function testDrupalLaunchpadSavesCorrectOpenIDServerFromAdminForm() {
145 $form = array();
146 $form_state = array('values' => array('openid_launchpad_server' => ''));

Subscribers

People subscribed via source and target branches