You are here

public function SimplesamlphpDrupalAuthTest::roleMatchingDataProvider in simpleSAMLphp Authentication 8.3

Provides test parameters for testRoleMatching.

Return value

array Parameters

See also

\Drupal\Tests\simplesamlphp_auth\Unit\Service\SimplesamlphpDrupalAuthTest::testRoleMatching

File

tests/src/Unit/Service/SimplesamlphpDrupalAuthTest.php, line 459

Class

SimplesamlphpDrupalAuthTest
SimplesamlphpDrupalAuth unit tests.

Namespace

Drupal\Tests\simplesamlphp_auth\Unit\Service

Code

public function roleMatchingDataProvider() {
  return [
    // Test matching of exact attribute value.
    [
      'admin:userName,=,externalAdmin|test:something,=,something',
      [
        'userName' => [
          'externalAdmin',
        ],
      ],
      [
        'admin' => 'admin',
      ],
    ],
    // Test matching of attribute portion.
    [
      'employee:mail,@=,company.com',
      [
        'mail' => [
          'joe@company.com',
        ],
      ],
      [
        'employee' => 'employee',
      ],
    ],
    // Test non-matching of attribute portion.
    [
      'employee:mail,@=,company.com',
      [
        'mail' => [
          'joe@anothercompany.com',
        ],
      ],
      [],
    ],
    // Test matching of any attribute portion.
    [
      'employee:affiliate,~=,xyz',
      [
        'affiliate' => [
          'abcd',
          'wxyz',
        ],
      ],
      [
        'employee' => 'employee',
      ],
    ],
    // Test multiple roles.
    [
      'admin:userName,=,externalAdmin|employee:mail,@=,company.com',
      [
        'userName' => [
          'externalAdmin',
        ],
        'mail' => [
          'externalAdmin@company.com',
        ],
      ],
      [
        'admin' => 'admin',
        'employee' => 'employee',
      ],
    ],
    // Test special characters (colon) in attribute.
    [
      'admin:domain,=,http://admindomain.com',
      [
        'domain' => [
          'http://admindomain.com',
          'http://drupal.org',
        ],
      ],
      [
        'admin' => 'admin',
      ],
    ],
  ];
}