Beispiel #1
0
 def test_execute(self):
     environment_valid = EnvironmentFactory(application=self.application)
     environment_invalid = EnvironmentFactory(application=self.application)
     self.remove_perm_from_user_group('core.execute_environment',
                                      environment_invalid)
     response = self.client.get('/task/%d/execute/' % self.task.id)
     self.assertContains(response, self.task.name)
     self.assertContains(response, environment_valid.name + "</option>")
     self.assertNotContains(response,
                            environment_invalid.name + "</option>")
     self.assertNotContains(
         response,
         reverse('task_form_page', kwargs={'task_id': self.task.id}))
Beispiel #2
0
 def test_execution_forbidden(self):
     environment = EnvironmentFactory(application=self.application)
     execution = ExecutionFactory(task=self.task,
                                  environment=environment,
                                  user=self.user)
     self.remove_perm_from_user_group('core.view_task', self.task)
     response = self.client.get('/execution/%d/' % execution.id)
     self.assertForbidden(response)
Beispiel #3
0
 def setUp(self):
     self.department = DepartmentFactory()
     self.user = UserFactory()
     self.user.groups.add(self.department.groups.get(system_name='user'))
     self.user.save()
     self.application = ApplicationFactory(department=self.department)
     self.environment = EnvironmentFactory(application=self.application)
     self.task = TaskFactory(application=self.application)
Beispiel #4
0
 def test_execution(self):
     environment = EnvironmentFactory(application=self.application)
     execution = ExecutionFactory(task=self.task,
                                  environment=environment,
                                  user=self.user)
     response = self.client.get('/execution/%d/' % execution.id)
     self.assertContains(
         response,
         reverse('task_form_page', kwargs={'task_id': self.task.id}))
Beispiel #5
0
 def test_edit(self):
     environment = EnvironmentFactory(application=ApplicationFactory(department=self.department))
     obj = self.object_factory(environment=environment)
     server_role = ServerRole.objects.filter(department=self.department).first()
     data = {'name': 'ServerName2',
            'environment': self.environment.id,
            'roles': server_role.id,
            'host': 'host',
            'port': 22,
            'user': '******',
            'method': 1,}
     response, obj_updated = self._test_edit(obj, data)
     self.assertJSONEqual(response.content, {"status": True, "action": "reload"})
     self.assertEqual(obj_updated.name, 'ServerName2')
Beispiel #6
0
 def test_execution_forbidden_change(self):
     self.remove_perm_from_user_group('task.change_task', self.task)
     self.remove_perm_from_user_group('task.execute_task', self.task)
     environment = EnvironmentFactory(application=self.application)
     execution = ExecutionFactory(task=self.task,
                                  environment=environment,
                                  user=self.user)
     response = self.client.get('/execution/%d/' % execution.id)
     self.assertContains(response, self.task.name)
     self.assertContains(response, environment.name)
     self.assertNotContains(
         response,
         reverse('task_execute_page', kwargs={'task_id': self.task.id}))
     self.assertNotContains(
         response,
         reverse('task_form_page', kwargs={'task_id': self.task.id}))
Beispiel #7
0
 def setUpClass(cls):
     super(BaseModalTestCase, cls).setUpClass()
     cls.environment = EnvironmentFactory(application=ApplicationFactory(department=cls.department))
     cls.url_params['parent_id'] = cls.environment.id
     cls.object = cls.object_factory(**cls.getSetUpObjectData())