function setUp()
 {
     self::$fixture_file = MODULE_SECUREFILES_PATH . '/tests/SecureFileControllerTest.yml';
     parent::setUp();
     $this->priorAuthenticators = Authenticator::get_authenticators();
     $this->priorDefaultAuthenticator = Authenticator::get_default_authenticator();
     Authenticator::register('MemberAuthenticator');
     Authenticator::set_default_authenticator('MemberAuthenticator');
     if (!file_exists(ASSETS_PATH)) {
         mkdir(ASSETS_PATH);
     }
     /* Create a test folders for each of the fixture references */
     $fileIDs = $this->allFixtureIDs('Folder');
     foreach ($fileIDs as $fileID) {
         $file = DataObject::get_by_id('Folder', $fileID);
         if (!file_exists(BASE_PATH . "/{$file->Filename}")) {
             mkdir(BASE_PATH . "/{$file->Filename}");
         }
     }
     /* Create a test files for each of the fixture references */
     $fileIDs = $this->allFixtureIDs('File');
     foreach ($fileIDs as $fileID) {
         $file = DataObject::get_by_id('File', $fileID);
         $fh = fopen(BASE_PATH . "/{$file->Filename}", "w");
         fwrite($fh, str_repeat('x', 1000));
         fclose($fh);
     }
     // USERS:
     // 1 x ADMIN user
     // 1 x Member with SECUREFILEACCESS
     // 1 x Member with SECURE_FILE_SETTINGS
     // 1 x Member
 }
Beispiel #2
0
 function setUp()
 {
     // This test assumes that MemberAuthenticator is present and the default
     $this->priorAuthenticators = Authenticator::get_authenticators();
     $this->priorDefaultAuthenticator = Authenticator::get_default_authenticator();
     Authenticator::register('MemberAuthenticator');
     Authenticator::set_default_authenticator('MemberAuthenticator');
     parent::setUp();
 }
 function setUp()
 {
     // This test assumes that MemberAuthenticator is present and the default
     $this->priorAuthenticators = Authenticator::get_authenticators();
     $this->priorDefaultAuthenticator = Authenticator::get_default_authenticator();
     Authenticator::register('MemberAuthenticator');
     Authenticator::set_default_authenticator('MemberAuthenticator');
     // And that the unique identified field is 'Email'
     $this->priorUniqueIdentifierField = Member::get_unique_identifier_field();
     Member::set_unique_identifier_field('Email');
     parent::setUp();
 }
Beispiel #4
0
 public function setUp()
 {
     // This test assumes that MemberAuthenticator is present and the default
     $this->priorAuthenticators = Authenticator::get_authenticators();
     $this->priorDefaultAuthenticator = Authenticator::get_default_authenticator();
     foreach ($this->priorAuthenticators as $authenticator) {
         Authenticator::unregister($authenticator);
     }
     Authenticator::register('MemberAuthenticator');
     Authenticator::set_default_authenticator('MemberAuthenticator');
     // And that the unique identified field is 'Email'
     $this->priorUniqueIdentifierField = Member::config()->unique_identifier_field;
     $this->priorRememberUsername = Security::config()->remember_username;
     Member::config()->unique_identifier_field = 'Email';
     parent::setUp();
 }
 function setUp()
 {
     // This test assumes that MemberAuthenticator is present and the default
     $this->priorAuthenticators = Authenticator::get_authenticators();
     $this->priorDefaultAuthenticator = Authenticator::get_default_authenticator();
     //Authenticator::register('MemberAuthenticator');
     Authenticator::register_authenticator('ExternalAuthenticator');
     Authenticator::set_default_authenticator('ExternalAuthenticator');
     //Create the sources in this order. Switching them around would mean that
     //all tests use the fake driver because this always succeeds and auto create
     //is on
     ExternalAuthenticator::createSource('sstripe_unittest', 'SSTRIPE', 'SilverStripe');
     ExternalAuthenticator::createSource('fake_unittest', 'FAKE', 'Fake Source');
     ExternalAuthenticator::setAuthSequential(true);
     ExternalAuthenticator::setAuthSSLock('sstripe_unittest', true);
     ExternalAuthenticator::setAuthSSLock('fake_unittest', false);
     ExternalAuthenticator::setAutoAdd('fake_unittest', 'mygroup');
     ExternalAuthenticator::setDefaultDomain('fake_unittest', 'silverstripe.com');
     ExternalAuthenticator::setAuthDebug(false);
     ExternalAuthenticator::setAuditLogFile(false);
     ExternalAuthenticator::setAuditLogSStripe(true);
     parent::setUp();
 }
Beispiel #6
0
 /**
  * Get the login forms for all available authentication methods
  *
  * @return array Returns an array of available login forms (array of Form
  *               objects).
  *
  * @todo Check how to activate/deactivate authentication methods
  */
 protected function GetLoginForms()
 {
     $forms = array();
     $authenticators = Authenticator::get_authenticators();
     foreach ($authenticators as $authenticator) {
         array_push($forms, call_user_func(array($authenticator, 'get_login_form'), $this));
     }
     return $forms;
 }
Beispiel #7
0
 /**
  * Get the login forms for all available authentication methods
  *
  * @return array Returns an array of available login forms (array of Form
  *               objects).
  *
  * @todo Check how to activate/deactivate authentication methods
  */
 public function GetLoginForms()
 {
     $forms = array();
     $authenticators = Authenticator::get_authenticators();
     foreach ($authenticators as $authenticator) {
         $forms[] = $authenticator::get_login_form($this);
     }
     return $forms;
 }
Beispiel #8
0
 /**
  * Determine if CMSSecurity is enabled
  *
  * @return bool
  */
 public static function enabled()
 {
     // Disable shortcut
     if (!static::config()->reauth_enabled) {
         return false;
     }
     // Count all cms-supported methods
     $authenticators = Authenticator::get_authenticators();
     foreach ($authenticators as $authenticator) {
         // Supported if at least one authenticator is supported
         if ($authenticator::supports_cms()) {
             return true;
         }
     }
     return false;
 }