Révision bc175c27
Ajouté par Assos Assos il y a plus de 5 ans
drupal7/sites/all/modules/ldap/ldap_user/tests/ldap_user.test | ||
---|---|---|
11 | 11 |
* |
12 | 12 |
*/ |
13 | 13 |
|
14 |
|
|
15 | 14 |
module_load_include('php', 'ldap_test', 'LdapTestCase.class'); |
16 | 15 |
|
17 | 16 |
class LdapUserUnitTests extends LdapTestCase { |
... | ... | |
91 | 90 |
$mail = ldap_user_token_replace('[property.mail]', $account, $entity); |
92 | 91 |
$this->assertTrue($mail == $account->mail, t('[property.mail] token worked on ldap_user_token_replace().'), $this->testId('tokens.property')); |
93 | 92 |
$lname = ldap_user_token_replace('[field.lname]', $account, $entity); |
94 |
$this->assertTrue($lname == $entity->lname[LANGUAGE_NONE][0]['value'], t('[field.lname] token worked on ldap_user_token_replace().'), $this->testId('tokens.property.field'));
|
|
93 |
$this->assertTrue($lname == $entity->lname[LANGUAGE_NONE][0]['value'], t('[field.lname] token worked on ldap_user_token_replace().'), $this->testId('tokens.property.field')); |
|
95 | 94 |
$house1 = ldap_user_token_replace('[field.house:1]', $account, $entity); |
96 | 95 |
$this->assertTrue($house1 == $entity->house[LANGUAGE_NONE][1]['value'], t('[field.house:1] token worked on ldap_user_token_replace().'), $this->testId('tokens.property.field.ordinal')); |
97 | 96 |
//@todo need tests for :last and a multivalued attribute. see http://drupal.org/node/1245736 |
... | ... | |
396 | 395 |
$this->prepTestData('hogwarts', $sids, 'provisionToDrupal', 'default'); |
397 | 396 |
$tests = array(); |
398 | 397 |
|
399 |
$tests[] = array(
|
|
398 |
$tests[] = array( |
|
400 | 399 |
'disabled' => 0, |
401 | 400 |
'user' => 'hpotter', |
402 | 401 |
'field_name' => 'field_lname', |
403 | 402 |
'field_values' => array(array('sn' => 'Potter'), array('sn' => 'Pottery-Chard')), |
404 |
'field_results' => array('Potter', 'Pottery-Chard'), // first value is what is desired on synch, second if no sycn
|
|
403 |
'field_results' => array('Potter', 'Pottery-Chard'), // first value is what is desired on synch, second if no sycn |
|
405 | 404 |
'mapping' => array( |
406 | 405 |
'sid' => $sid, |
407 | 406 |
'name' => 'Field: Last Name', |
... | ... | |
418 | 417 |
); |
419 | 418 |
|
420 | 419 |
// test for compound tokens |
421 |
$tests[] = array(
|
|
420 |
$tests[] = array( |
|
422 | 421 |
'disabled' => 0, |
423 | 422 |
'user' => 'hpotter', |
424 | 423 |
'field_name' => 'field_display_name', |
425 |
'field_values' => array(array('givenname' => 'Harry', 'sn' => 'Potter'), array('givenname' => 'Sir Harry', 'sn' => 'Potter')),
|
|
426 |
'field_results' => array('Harry Potter', 'Sir Harry Potter'), // desired results
|
|
424 |
'field_values' => array(array('givenname' => 'Harry', 'sn' => 'Potter'), array('givenname' => 'Sir Harry', 'sn' => 'Potter')), |
|
425 |
'field_results' => array('Harry Potter', 'Sir Harry Potter'), // desired results |
|
427 | 426 |
'mapping' => array( |
428 | 427 |
'sid' => $sid, |
429 | 428 |
'ldap_attr' => '[givenName] [sn]', |
... | ... | |
441 | 440 |
|
442 | 441 |
|
443 | 442 |
// test for constants in use (e.g. "Smith" and "0") instead of tokens e.g. "[sn]" and "[enabled]" |
444 |
$tests[] = array(
|
|
443 |
$tests[] = array( |
|
445 | 444 |
'disabled' => 0, |
446 | 445 |
'user' => 'hpotter', |
447 | 446 |
'field_name' => 'field_lname', |
... | ... | |
464 | 463 |
); |
465 | 464 |
|
466 | 465 |
// test for compound tokens |
467 |
$tests[] = array(
|
|
466 |
$tests[] = array( |
|
468 | 467 |
'disabled' => 0, |
469 | 468 |
'user' => 'hpotter', |
470 | 469 |
'property_name' => 'signature', |
... | ... | |
485 | 484 |
), |
486 | 485 |
); |
487 | 486 |
|
488 |
$tests[] = array(
|
|
487 |
$tests[] = array( |
|
489 | 488 |
'disabled' => 0, |
490 | 489 |
'user' => 'hpotter', |
491 | 490 |
'property_name' => 'mail', |
... | ... | |
506 | 505 |
), |
507 | 506 |
); |
508 | 507 |
|
509 |
$tests[] = array(
|
|
508 |
$tests[] = array( |
|
510 | 509 |
'disabled' => 0, |
511 | 510 |
'user' => 'hpotter', |
512 | 511 |
'property_name' => 'status', |
... | ... | |
515 | 514 |
'mapping' => array( |
516 | 515 |
'sid' => $sid, |
517 | 516 |
'ldap_attr' => '0', |
518 |
'user_attr' => '[property.status]', // testing of a constant mapped to property
|
|
517 |
'user_attr' => '[property.status]', // testing of a constant mapped to property |
|
519 | 518 |
'convert' => 0, |
520 | 519 |
'direction' => LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER, |
521 | 520 |
'prov_events' => array(LDAP_USER_EVENT_CREATE_DRUPAL_USER), |
... | ... | |
562 | 561 |
$ldap_user_conf = ldap_user_conf('admin', TRUE); |
563 | 562 |
if ($property_name) { |
564 | 563 |
$token_attributes = array(); |
565 |
ldap_servers_token_extract_attributes($token_attributes, $test['mapping']['ldap_attr']);
|
|
564 |
ldap_servers_token_extract_attributes($token_attributes, $test['mapping']['ldap_attr']); |
|
566 | 565 |
foreach ($token_attributes as $attr_name => $attr_parts) { |
567 | 566 |
$this->testFunctions->setFakeServerUserAttribute( |
568 | 567 |
'activedirectory1', |
... | ... | |
576 | 575 |
} |
577 | 576 |
if ($field_name) { |
578 | 577 |
$token_attributes = array(); |
579 |
ldap_servers_token_extract_attributes($token_attributes, $test['mapping']['ldap_attr']);
|
|
578 |
ldap_servers_token_extract_attributes($token_attributes, $test['mapping']['ldap_attr']); |
|
580 | 579 |
foreach ($token_attributes as $attr_name => $attr_parts ) { |
581 | 580 |
$this->testFunctions->setFakeServerUserAttribute( |
582 | 581 |
'activedirectory1', |
... | ... | |
621 | 620 |
if (in_array($prov_event, $ldap_user_conf->ldapUserSynchMappings[$direction][$field_token]['prov_events'])) { // if intended to synch |
622 | 621 |
$field_success = isset($user_entity->{$field_name}[LANGUAGE_NONE][0]['value']) && |
623 | 622 |
$user_entity->{$field_name}[LANGUAGE_NONE][0]['value'] == $test['field_results'][0]; |
624 |
$this->assertTrue($field_success, t("provisionDrupalAccount worked for field $field_name"), $this->testId(":provisionDrupalAccount.i=$j.prov_event=$prov_event"));
|
|
623 |
$this->assertTrue($field_success, t("provisionDrupalAccount worked for field $field_name"), $this->testId(":provisionDrupalAccount.i=$j.prov_event=$prov_event")); |
|
625 | 624 |
if (!$field_success) { |
626 | 625 |
debug('field fail,' . $field_name); debug($user_entity->{$field_name}); debug($test['field_results'][0]); //debug($user_entity); |
627 | 626 |
} |
... | ... | |
1033 | 1032 |
module_exists('ldap_servers') && |
1034 | 1033 |
(variable_get('ldap_simpletest', 2) > 0) |
1035 | 1034 |
); |
1036 |
$this->assertTrue($setup_success, ' ldap_user setup successful', $this->testId('orphaned entries tests'));
|
|
1035 |
$this->assertTrue($setup_success, ' ldap_user setup successful', $this->testId('orphaned entries tests')); |
|
1037 | 1036 |
|
1038 | 1037 |
$sids = array('activedirectory1'); |
1039 | 1038 |
$this->prepTestData('hogwarts', $sids, 'provisionToDrupal', 'default'); |
... | ... | |
1055 | 1054 |
|
1056 | 1055 |
// create 70 drupal accounts (clone0 to clone69) based on corresponding ldap entries |
1057 | 1056 |
$first_clone_username = 'clone0'; |
1058 |
$last_clone_username= 'clone' . (LDAP_TEST_USER_ORPHAN_CLONE_COUNT - 1); |
|
1057 |
$last_clone_username = 'clone' . (LDAP_TEST_USER_ORPHAN_CLONE_COUNT - 1);
|
|
1059 | 1058 |
for ($i = 0; $i < LDAP_TEST_USER_ORPHAN_CLONE_COUNT; $i++) { // 70 |
1060 | 1059 |
$name = "clone" . $i; |
1061 | 1060 |
$account = $this->createLdapIdentifiedDrupalAccount( |
... | ... | |
1166 | 1165 |
break; |
1167 | 1166 |
} |
1168 | 1167 |
|
1169 |
$this->assertTrue($success, $test_id, $test_text);
|
|
1168 |
$this->assertTrue($success, $test_id, $test_text); |
|
1170 | 1169 |
|
1171 | 1170 |
// remove all drupal users except 1 for next test |
1172 | 1171 |
foreach ($cn_to_account as $cn => $account) { |
... | ... | |
1232 | 1231 |
module_exists('ldap_servers') && |
1233 | 1232 |
(variable_get('ldap_simpletest', 2) > 0) |
1234 | 1233 |
); |
1235 |
$this->assertTrue($setup_success, ' ldap_user setup successful', $this->testId('user interface tests'));
|
|
1234 |
$this->assertTrue($setup_success, ' ldap_user setup successful', $this->testId('user interface tests')); |
|
1236 | 1235 |
|
1237 | 1236 |
$sids = array('activedirectory1'); |
1238 | 1237 |
$this->prepTestData('hogwarts', $sids, 'provisionToDrupal', 'default'); |
Formats disponibles : Unified diff
Weekly update of contrib modules