Révision e9f59589
Ajouté par Assos Assos il y a presque 10 ans
drupal7/sites/all/modules/cas/cas.test | ||
---|---|---|
35 | 35 |
$this->admin_user = $this->drupalCreateUser(array('administer users', 'administer cas')); |
36 | 36 |
|
37 | 37 |
// Download and extract in PHPCAS. |
38 |
$this->downloadExtractPhpCas('1.3.1');
|
|
38 |
$this->downloadExtractPhpCas('1.3.2');
|
|
39 | 39 |
} |
40 | 40 |
|
41 | 41 |
/** |
... | ... | |
332 | 332 |
function testCasUserAdd() { |
333 | 333 |
$this->drupalLogin($this->admin_user); |
334 | 334 |
|
335 |
// Add a CAS user. |
|
336 |
$edit = array( |
|
337 |
'cas_name' => $this->randomName(), |
|
338 |
); |
|
339 |
$this->drupalPost('admin/people/cas/create', $edit, t('Create new account')); |
|
340 |
$this->assertText(t('Created a new user account for @name. No e-mail has been sent.', array('@name' => $edit['cas_name'])), 'User created'); |
|
335 |
// Add 3 CAS users. |
|
336 |
$edit = array(); |
|
337 |
for ($i = 0; $i < 3; $i++) { |
|
338 |
$cas_names[] = $this->randomName(); |
|
339 |
} |
|
340 |
$edit['cas_name'] = implode("\n", $cas_names); |
|
341 |
$this->drupalPost('admin/people/cas/create', $edit, t('Create new account(s)')); |
|
342 |
$this->assertText(t('The following 3 CAS usernames were created: @cas_names', array('@cas_names' => implode(', ', $cas_names))), 'Users created'); |
|
341 | 343 |
|
342 |
// Verify the user shows up in the list of all users.
|
|
344 |
// Verify the users show up in the list of all users.
|
|
343 | 345 |
$this->drupalGet('admin/people'); |
344 |
$this->assertNoUniqueText($edit['cas_name'], 'User and CAS username found in list of users'); |
|
346 |
foreach ($cas_names as $cas_name) { |
|
347 |
$this->assertNoUniqueText($cas_name, 'User and CAS username found in list of users'); |
|
348 |
} |
|
345 | 349 |
|
346 |
// Attempt to add the user again and see that it fails. |
|
347 |
$this->drupalPost('admin/people/cas/create', $edit, t('Create new account')); |
|
350 |
// Attempt to add one of the users again and see that it fails. |
|
351 |
$edit['cas_name'] = $cas_names[0]; |
|
352 |
$this->drupalPost('admin/people/cas/create', $edit, t('Create new account(s)')); |
|
348 | 353 |
$this->assertText(t('The CAS username is already in use on this site.'), 'CAS username already in use.'); |
349 | 354 |
} |
350 | 355 |
} |
... | ... | |
374 | 379 |
$this->drupalGet('cas'); |
375 | 380 |
$this->assertRaw(t('No account found for %cas_name.', array('%cas_name' => $cas_name))); |
376 | 381 |
|
382 |
// Ensure that the login result is not cached. |
|
383 |
$cas_name = $this->randomName(); |
|
384 |
$this->setCasUser($cas_name); |
|
385 |
$this->drupalGet('cas'); |
|
386 |
$this->assertRaw(t('No account found for %cas_name.', array('%cas_name' => $cas_name))); |
|
387 |
|
|
377 | 388 |
// Test that the user is automatically registered. |
378 | 389 |
variable_set('cas_user_register', TRUE); |
379 | 390 |
$this->drupalGet('cas'); |
... | ... | |
593 | 604 |
variable_set('cas_first_login_destination', "node/$node->nid"); |
594 | 605 |
$cas_name = $this->randomName(); |
595 | 606 |
$account = $this->casLogin($cas_name); |
596 |
$this->assertUrl("node/$node->nid", array('query' => array('destination' => '')));
|
|
607 |
$this->assertUrl("node/$node->nid"); |
|
597 | 608 |
$this->drupalLogout(); |
598 | 609 |
|
599 | 610 |
// The second login should not be redirected. |
... | ... | |
605 | 616 |
// destination. |
606 | 617 |
$account = $this->casCreateUser(); |
607 | 618 |
$this->casLogin($account); |
608 |
$this->assertUrl("node/$node->nid", array('query' => array('destination' => '')));
|
|
619 |
$this->assertUrl("node/$node->nid"); |
|
609 | 620 |
$this->drupalLogout(); |
610 | 621 |
|
611 | 622 |
// The second login should not be redirected. |
... | ... | |
670 | 681 |
|
671 | 682 |
function setUp() { |
672 | 683 |
parent::setUp(); |
673 |
variable_set('cas_check_first', TRUE); |
|
674 | 684 |
} |
675 | 685 |
|
676 | 686 |
/** |
677 | 687 |
* Test the CAS Gateway functionality of the user is not logged in. |
678 | 688 |
*/ |
679 | 689 |
function testCasGatewayLoggedOut() { |
690 |
$node1 = $this->drupalCreateNode(); |
|
691 |
|
|
692 |
variable_set('cas_check_frequency', CAS_CHECK_ONCE); |
|
680 | 693 |
$this->drupalGet(''); |
681 |
$this->assertTrue($this->redirect_count > 1, 'Polled CAS server on first request.');
|
|
694 |
$this->assertTrue($this->redirect_count == 2, 'Polled CAS server on first request.');
|
|
682 | 695 |
$this->drupalGet(''); |
683 | 696 |
$this->assertEqual($this->redirect_count, 0, 'Did not poll CAS server on second request.'); |
684 |
$this->drupalGet('node');
|
|
697 |
$this->drupalGet('node/' . $node1->nid);
|
|
685 | 698 |
$this->assertEqual($this->redirect_count, 0, 'Did not poll CAS server on third request.'); |
699 |
$this->assertFalse($this->loggedInUser); |
|
700 |
|
|
701 |
variable_set('cas_check_frequency', CAS_CHECK_ALWAYS); |
|
702 |
$this->drupalGet(''); |
|
703 |
$this->assertTrue($this->redirect_count == 2, 'Polled CAS server on first request'); |
|
704 |
$this->drupalGet(''); |
|
705 |
$this->assertTrue($this->redirect_count == 2, 'Polled CAS server on second request'); |
|
706 |
$this->drupalGet('node/' . $node1->nid); |
|
707 |
$this->assertEqual($this->redirect_count == 2, 'Polled CAS server on third request'); |
|
708 |
$this->assertFalse($this->loggedInUser); |
|
686 | 709 |
} |
687 | 710 |
|
688 | 711 |
/** |
... | ... | |
694 | 717 |
$account = $this->casCreateUser($cas_name); |
695 | 718 |
$this->setCasUser($cas_name); |
696 | 719 |
|
697 |
$this->drupalGet('node'); |
|
720 |
variable_set('cas_check_frequency', CAS_CHECK_ONCE); |
|
721 |
$this->drupalGet(''); |
|
722 |
$this->assertLoggedIn($account); |
|
723 |
// Logging out should immediately log a user back in |
|
724 |
$this->drupalGet('user/logout'); |
|
725 |
$this->assertLoggedIn($account); |
|
726 |
|
|
727 |
variable_set('cas_check_frequency', CAS_CHECK_ALWAYS); |
|
728 |
$this->drupalGet(''); |
|
729 |
$this->assertLoggedIn($account); |
|
730 |
// Logging out should immediately log a user back in |
|
731 |
$this->drupalGet('user/logout'); |
|
698 | 732 |
$this->assertLoggedIn($account); |
699 | 733 |
} |
700 | 734 |
} |
... | ... | |
754 | 788 |
$account = $this->casCreateUser(); |
755 | 789 |
$this->setCasUser($account); |
756 | 790 |
|
757 |
variable_set('cas_check_first', TRUE);
|
|
791 |
variable_set('cas_check_frequency', CAS_CHECK_ONCE);
|
|
758 | 792 |
variable_set('cas_exclude', "node/$node->nid"); |
759 | 793 |
|
760 | 794 |
// Visit an excluded page and ensure we did not try to log in. |
Formats disponibles : Unified diff
Weekly update of contrib modules