/**
  * @depends icingaDatabaseAccessibleTest::testInsert
  * @group Database
  */
 public function testRoleAdd()
 {
     try {
         info("Testing actions for group modification\n");
         info("\tTesting icinga-web action: Creating groups\n");
         $context = AgaviContext::getInstance();
         $arguments = new AgaviRequestDataHolder();
         $role = $this->roleParams;
         foreach ($role as $name => $value) {
             $arguments->setParameter($name, $value);
         }
         // insert user
         $container = $context->getController()->createExecutionContainer("AppKit", "Admin.Groups.Edit", $arguments, "simple", "write");
         IcingaWebTestTool::assertInstanceOf("AgaviExecutionContainer", $container, "Couldn't create add-group action");
         $result = $container->execute();
         $this->assertNotEquals($result->getHttpStatusCode(), "404", "Action for adding groups not found");
         // Check if user is really added
         $result = Doctrine_Core::getTable("NsmRole")->findBy("role_name", $role["role_name"])->getFirst();
         IcingaWebTestTool::assertInstanceOf("NsmRole", $result, "No group found, something seemed to go wrong");
         success("\tCreating roles suceeded!\n");
         self::$idFixture = $result["role_id"];
         return true;
     } catch (Exception $e) {
         $this->fail("Adding a role failed!" . $e->getMessage());
     }
 }
Ejemplo n.º 2
0
 /**
  * @depends testLibs
  * @group Bootstrap
  **/
 public function testBootstrap()
 {
     $ctx = AgaviContext::getInstance('testing');
     IcingaWebTestTool::assertInstanceOf('AppKitAgaviContext', $ctx, "AgaviContext has wrong instance");
     IcingaWebTestTool::assertInstanceOf('AgaviDoctrineDatabase', $ctx->getDatabaseManager()->getDatabase());
     IcingaWebTestTool::assertInstanceOf('Doctrine_Manager', $ctx->getDatabaseManager()->getDatabase()->getDoctrineManager());
     try {
         $ctx->getDatabaseManager()->getDatabase()->connect();
     } catch (Doctrine_Connection_Exception $e) {
         $this->fail('No database connection');
     }
 }
Ejemplo n.º 3
0
 public function testUpdateCredentialPermission()
 {
     $model = new TestDataStoreModel();
     $e = null;
     try {
         $model->doUpdate("no data");
     } catch (DataStorePermissionException $p) {
         $e = $p;
     }
     IcingaWebTestTool::assertInstanceOf("DataStorePermissionException", $e, "Wrong or no exception thrown on disallowed write");
     $this->checkCalls($model, array(false, false, false, false), "disallowed update");
     $context = AgaviContext::getInstance();
     $context->getUser()->addCredential("testCredential");
     $model->doUpdate("no data");
     $this->checkCalls($model, array(false, false, true, false), "allowed update");
 }
 /**
  * @depends testUserPreferenceAdd
  * @group Database
  */
 public function testUserPreferenceRemove()
 {
     try {
         $userid = self::$idFixture;
         info("\tTesting icinga-web action: Remove user preference\n");
         $context = AgaviContext::getInstance();
         $preferenceData = new AgaviRequestDataHolder();
         $preferenceData->setParameters(array("remove" => "true", "isLong" => "false", "upref_key" => "TEST", "upref_val" => "TESTCASE"));
         $modifyAction = $context->getController()->createExecutionContainer("AppKit", "User.Preferences", $preferenceData, "simple", "write");
         IcingaWebTestTool::assertInstanceOf("AgaviExecutionContainer", $modifyAction, "Couldn't create add-preference action");
         $result = $modifyAction->execute();
         $this->assertNotEquals($result->getHttpStatusCode(), "404", "Action for eediting user preferences not found");
         success("\tDeleting preferences suceeded!\n");
         return true;
     } catch (Exception $e) {
         $this->fail("Removing an user preference failed!" . $e->getMessage());
     }
 }