<commit_before><?php

$base_dir = dirname(__FILE__);
require_once $base_dir.'/../lib/GangliaAcl.php';

/**
 * Test class for GangliaAcl.
 * Generated by PHPUnit on 2011-04-20 at 20:35:07.
 */
class GangliaAclTest extends PHPUnit_Framework_TestCase {
  
    protected function setUp() {
        $this->object = new GangliaAcl;
    }
    
    // This is the normal way to access the ACL.
    public function testGetInstance() {
      $obj1 = GangliaAcl::getInstance();
      $obj2 = GangliaAcl::getInstance();
      
      $this->assertEquals( $obj1, $obj2 );
    }
    
    public function testGuestCanViewNormalClusters() {
      $this->assertTrue( $this->object->isAllowed( GangliaAcl::GUEST, GangliaAcl::ALL, 'view' ) );
    }
    
    public function testAdminCanViewNormalClusters() {
      $this->assertTrue( $this->object->isAllowed( GangliaAcl::ADMIN, GangliaAcl::ALL, 'view' ) );
    }
    
    public function testGuestCannotEdit() {
      $this->assertFalse( $this->object->isAllowed( GangliaAcl::GUEST, GangliaAcl::ALL, 'edit' ) );
    }
    
    public function testAdminCanEdit() {
      $this->assertTrue( $this->object->isAllowed( GangliaAcl::ADMIN, GangliaAcl::ALL, 'edit' ) );
    }
    
    public function testAdminCanAccessPrivateCluster() {
      $this->object->addPrivateCluster( 'clustername' );
      $this->assertTrue( $this->object->isAllowed( GangliaAcl::ADMIN, 'clustername', 'view' ) );
      $this->assertTrue( $this->object->isAllowed( GangliaAcl::ADMIN, 'clustername', 'edit' ) );
    }
    
    public function testGuestCannotAccessPrivateCluster() {
      $this->object->addPrivateCluster( 'clustername' );
      $this->assertFalse( $this->object->isAllowed( GangliaAcl::GUEST, 'clustername', 'view' ) );
      $this->assertFalse( $this->object->isAllowed( GangliaAcl::GUEST, 'clustername', 'edit' ) );
    }
    
    public function testUserMayBeGrantedViewAccessToPrivateCluster() {
      $this->object->addPrivateCluster( 'clustername' );<commit_msg>verify that a cluster which has explicitly set 'edit' operation is still view-able by a guest.<commit_after><?php

$base_dir = dirname(__FILE__);
require_once $base_dir.'/../lib/GangliaAcl.php';

/**
 * Test class for GangliaAcl.
 * Generated by PHPUnit on 2011-04-20 at 20:35:07.
 */
class GangliaAclTest extends PHPUnit_Framework_TestCase {
  
    protected function setUp() {
        $this->object = new GangliaAcl;
    }
    
    // This is the normal way to access the ACL.
    public function testGetInstance() {
      $obj1 = GangliaAcl::getInstance();
      $obj2 = GangliaAcl::getInstance();
      
      $this->assertEquals( $obj1, $obj2 );
    }
    
    public function testGuestCanViewNormalClusters() {
      $this->assertTrue( $this->object->isAllowed( GangliaAcl::GUEST, GangliaAcl::ALL, 'view' ) );
    }
    
    public function testAdminCanViewNormalClusters() {
      $this->assertTrue( $this->object->isAllowed( GangliaAcl::ADMIN, GangliaAcl::ALL, 'view' ) );
    }
    
    public function testGuestCannotEdit() {
      $this->assertFalse( $this->object->isAllowed( GangliaAcl::GUEST, GangliaAcl::ALL, 'edit' ) );
    }
    
    public function testAdminCanEdit() {
      $this->assertTrue( $this->object->isAllowed( GangliaAcl::ADMIN, GangliaAcl::ALL, 'edit' ) );
    }
    
    public function testAdminCanAccessPrivateCluster() {
      $this->object->addPrivateCluster( 'clustername' );
      $this->assertTrue( $this->object->isAllowed( GangliaAcl::ADMIN, 'clustername', 'view' ) );
      $this->assertTrue( $this->object->isAllowed( GangliaAcl::ADMIN, 'clustername', 'edit' ) );
    }
    
    public function testGuestCannotAccessPrivateCluster() {
      $this->object->addPrivateCluster( 'clustername' );
      $this->assertFalse( $this->object->isAllowed( GangliaAcl::GUEST, 'clustername', 'view' ) );
      $this->assertFalse( $this->object->isAllowed( GangliaAcl::GUEST, 'clustername', 'edit' ) );
    }
    
    public function testGuestCanViewNormalCluster() {
      $this->object->add( new Zend_Acl_Resource('clustername'), GangliaAcl::ALL );
      $this->object->addRole( 'username', GangliaAcl::GUEST );
      $this->object->allow( 'username', 'clustername', array('edit', 'view') );
      
      $this->assertTrue( $this->object->isAllowed( GangliaAcl::GUEST, 'clustername', 'view' ) );
    }
    
    public function testUserMayBeGrantedViewAccessToPrivateCluster() {
      $this->object->addPrivateCluster( 'clustername' );
{'fraction_non_alphanumeric': 0.15191011235955057, 'fraction_numerical': 0.008089887640449439, 'mean_word_length': 3.6951476793248945, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 76, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6165950', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1434, 'n_words': 259}