static function test_new_no_affiliation_default() { self::init(); self::helper()->setup_new_no_affiliation(); $shib_user = Shibboleth::store()->get_user(); self::assert($config = Shibboleth::config()->default_status == Shibboleth::STUDENT_STATUS); self::assert(!User::store()->shibboleth_id_exists($shib_user->unique_id)); self::assert($shib_user->affiliation == ''); Shibboleth::save($shib_user); $user = User::store()->get_by_shibboleth_id($shib_user->unique_id); self::assert($user->email == $shib_user->email); self::assert($user->firstname == 'John'); self::assert($user->lastname == $shib_user->lastname); self::assert($user->persistent_id == $shib_user->persistent_id); self::assert($user->status == Shibboleth::STUDENT_STATUS); self::assert(!empty($user->password)); self::assert(!empty($user->username)); }
/** * Returns the shibboleth value stored in $_SERVER if it exists or $default if it is not the case. * * @param string $name the generic name. I.e. one of the class const. * @param string $default default value if it is not provided by Shibboleth * @return string */ public function get($name = '', $default = '') { $config = (array) Shibboleth::config(); if ($name) { $name = str_replace('get_', '', $name); $shib_name = isset($config[$name]) ? $config[$name] : ''; if ($shib_name) { $result = isset($_SERVER[$shib_name]) ? $_SERVER[$shib_name] : $default; $result = explode(';', $result); if (empty($result)) { $result = $default; } else { if (count($result) == 1) { $result = reset($result); } else { $result = $result; } } return $result; } } $result = array(); foreach ($config as $key => $val) { $f = array($this, "get_{$key}"); if (is_callable($f)) { $result[$key] = call_user_func($f); } } return $result; }