You are here

function cas_test_cas_phpcas_alter in CAS 6.3

Same name and namespace in other branches
  1. 7 tests/cas_test.module \cas_test_cas_phpcas_alter()

File

tests/cas_test.module, line 11
Dummy module implementing a CAS Server.

Code

function cas_test_cas_phpcas_alter() {

  // Set the User-Agent field which is used by SimpleTest to identify testing
  // requests.
  if (preg_match('/simpletest\\d+/', $GLOBALS['db_prefix'], $matches)) {
    phpCAS::setExtraCurlOption(CURLOPT_USERAGENT, drupal_generate_test_ua($matches[0]));
  }

  // Set all CAS server URLs manually, as this is the only way to specify an
  // HTTP (i.e., not HTTPS) connection.
  $service_url = phpCAS::getServiceURL();
  phpCAS::setServerLoginURL(url('cas_test/login', array(
    'query' => array(
      'service' => $service_url,
    ),
    'absolute' => TRUE,
  )));
  switch (variable_get('cas_version', '2.0')) {
    case CAS_VERSION_1_0:
      phpCAS::setServerServiceValidateURL(url('cas_test/validate', array(
        'absolute' => TRUE,
      )));
      break;
    case CAS_VERSION_2_0:
      phpCAS::setServerServiceValidateURL(url('cas_test/serviceValidate', array(
        'absolute' => TRUE,
      )));
      phpCAS::setServerProxyValidateURL(url('cas_test/proxyValidate', array(
        'absolute' => TRUE,
      )));
      break;
    default:
      throw new Exception('Unknown CAS server version.');
      break;
  }
  phpCAS::setServerLogoutURL(url('cas_test/logout', array(
    'absolute' => TRUE,
  )));

  // SAML not currently implemented.
  // phpCAS::setServerSamlValidateURL(url('cas_test/samlValidate', array('absolute' => TRUE)));
}