[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/_test/tests/inc/ -> auth_admincheck.test.php (source)

   1  <?php
   2  
   3  use dokuwiki\test\mock\AuthPlugin;
   4  use dokuwiki\test\mock\AuthCaseInsensitivePlugin;
   5  
   6  class auth_admin_test extends DokuWikiTest {
   7  
   8      private $oldauth;
   9  
  10      function setUp() {
  11          parent::setUp();
  12          global $auth;
  13          $this->oldauth = $auth;
  14      }
  15  
  16      function setSensitive() {
  17          global $auth;
  18          $auth = new AuthPlugin();
  19      }
  20  
  21      function setInSensitive() {
  22          global $auth;
  23          $auth = new AuthCaseInsensitivePlugin();
  24      }
  25  
  26      function teardown() {
  27          global $auth;
  28          global $AUTH_ACL;
  29          unset($AUTH_ACL);
  30          $auth = $this->oldauth;
  31      }
  32  
  33      function test_ismanager_insensitive(){
  34          $this->setInSensitive();
  35          global $conf;
  36          $conf['superuser'] = 'john,@admin,@Mötly Görls, Dörte';
  37          $conf['manager'] = 'john,@managers,doe, @Mötly Böys, Dänny';
  38  
  39          // anonymous user
  40          $this->assertEquals(auth_ismanager('jill', null,false), false);
  41  
  42          // admin or manager users
  43          $this->assertEquals(auth_ismanager('john', null,false), true);
  44          $this->assertEquals(auth_ismanager('doe',  null,false), true);
  45  
  46          $this->assertEquals(auth_ismanager('dörte', null,false), true);
  47          $this->assertEquals(auth_ismanager('dänny', null,false), true);
  48  
  49          // admin or manager groups
  50          $this->assertEquals(auth_ismanager('jill', array('admin'),false), true);
  51          $this->assertEquals(auth_ismanager('jill', array('managers'),false), true);
  52  
  53          $this->assertEquals(auth_ismanager('jill', array('mötly görls'),false), true);
  54          $this->assertEquals(auth_ismanager('jill', array('mötly böys'),false), true);
  55      }
  56  
  57      function test_isadmin_insensitive(){
  58          $this->setInSensitive();
  59          global $conf;
  60          $conf['superuser'] = 'john,@admin,doe,@roots';
  61  
  62          // anonymous user
  63          $this->assertEquals(auth_ismanager('jill', null,true), false);
  64  
  65          // admin user
  66          $this->assertEquals(auth_ismanager('john', null,true), true);
  67          $this->assertEquals(auth_ismanager('doe',  null,true), true);
  68  
  69          // admin groups
  70          $this->assertEquals(auth_ismanager('jill', array('admin'),true), true);
  71          $this->assertEquals(auth_ismanager('jill', array('roots'),true), true);
  72          $this->assertEquals(auth_ismanager('john', array('admin'),true), true);
  73          $this->assertEquals(auth_ismanager('doe',  array('admin'),true), true);
  74      }
  75  
  76      function test_ismanager_sensitive(){
  77          $this->setSensitive();
  78          global $conf;
  79          $conf['superuser'] = 'john,@admin,@Mötly Görls, Dörte';
  80          $conf['manager'] = 'john,@managers,doe, @Mötly Böys, Dänny';
  81  
  82          // anonymous user
  83          $this->assertEquals(auth_ismanager('jill', null,false), false);
  84  
  85          // admin or manager users
  86          $this->assertEquals(auth_ismanager('john', null,false), true);
  87          $this->assertEquals(auth_ismanager('doe',  null,false), true);
  88  
  89          $this->assertEquals(auth_ismanager('dörte', null,false), false);
  90          $this->assertEquals(auth_ismanager('dänny', null,false), false);
  91  
  92          // admin or manager groups
  93          $this->assertEquals(auth_ismanager('jill', array('admin'),false), true);
  94          $this->assertEquals(auth_ismanager('jill', array('managers'),false), true);
  95  
  96          $this->assertEquals(auth_ismanager('jill', array('mötly görls'),false), false);
  97          $this->assertEquals(auth_ismanager('jill', array('mötly böys'),false), false);
  98      }
  99  
 100      function test_isadmin_sensitive(){
 101          $this->setSensitive();
 102          global $conf;
 103          $conf['superuser'] = 'john,@admin,doe,@roots';
 104  
 105          // anonymous user
 106          $this->assertEquals(auth_ismanager('jill', null,true), false);
 107  
 108          // admin user
 109          $this->assertEquals(auth_ismanager('john', null,true), true);
 110          $this->assertEquals(auth_ismanager('Doe',  null,true), false);
 111  
 112          // admin groups
 113          $this->assertEquals(auth_ismanager('jill', array('admin'),true), true);
 114          $this->assertEquals(auth_ismanager('jill', array('roots'),true), true);
 115          $this->assertEquals(auth_ismanager('john', array('admin'),true), true);
 116          $this->assertEquals(auth_ismanager('doe',  array('admin'),true), true);
 117          $this->assertEquals(auth_ismanager('Doe',  array('admin'),true), true);
 118      }
 119  
 120  }
 121  
 122  //Setup VIM: ex: et ts=4 :