def test_configure_button_invisible_for_user_without_permission(self):
        user = UserFactory.create()
        response = self.app.get(reverse('server_run:environment_list',
                                        kwargs={'api_id': self.api.id}),
                                user=user)

        self.assertNotIn('Configure test scenarios', response.text)
    def test_view_create_page_without_permission(self):
        user = UserFactory.create()
        response = self.app.get(reverse('server_run:test-scenario_create_item',
                                        kwargs={'api_id': self.api.id}),
                                user=user,
                                status=[403])

        self.assertEqual(response.status_code, 403)
    def test_configure_button_invisible_for_user_with_permission_for_different_api(
            self):
        user = UserFactory.create()
        api2 = APIFactory.create(name='ATP API')
        assign_perm("list_scenario_for_api", user, api2)
        response = self.app.get(reverse('server_run:environment_list',
                                        kwargs={'api_id': self.api.id}),
                                user=user)

        self.assertNotIn('Configure test scenarios', response.text)
    def test_view_create_page_with_permission_for_different_api(self):
        user = UserFactory.create()
        api2 = APIFactory.create(name='ATP API')
        assign_perm("create_scenario_for_api", user, api2)
        response = self.app.get(reverse('server_run:test-scenario_create_item',
                                        kwargs={'api_id': self.api.id}),
                                user=user,
                                status=[403])

        self.assertEqual(response.status_code, 403)
 def setUp(self):
     self.api = APIFactory.create(name="ZGW")
     self.test_scenario = TestScenarioFactory.create(name="API tests",
                                                     description="bla")
     self.test_scenario_url = TestScenarioUrlFactory.create(
         name="token", test_scenario=self.test_scenario)
     self.postman_test = PostmanTestFactory.create(
         test_scenario=self.test_scenario)
     self.user = UserFactory.create()
     assign_perm("delete_scenario_for_api", self.user, self.api)
     assign_perm("list_scenario_for_api", self.user, self.api)
    def test_delete_without_permission_fails(self):
        user = UserFactory.create()
        response = self.app.get(reverse('server_run:testscenario-delete',
                                        kwargs={
                                            'api_id':
                                            self.api.id,
                                            'scenario_uuid':
                                            self.test_scenario.uuid
                                        }),
                                user=user,
                                status=[403])

        self.assertEqual(response.status_code, 403)
    def test_delete_with_permission_for_different_api_fails(self):
        user = UserFactory.create()
        api2 = APIFactory.create(name='ATP API')
        assign_perm("update_scenario_for_api", user, api2)
        response = self.app.get(reverse('server_run:testscenario-delete',
                                        kwargs={
                                            'api_id':
                                            self.api.id,
                                            'scenario_uuid':
                                            self.test_scenario.uuid
                                        }),
                                user=user,
                                status=[403])

        self.assertEqual(response.status_code, 403)
 def setUp(self):
     self.user = UserFactory.create()
 def setUp(self):
     self.api = APIFactory.create(name="ZGW")
     self.user = UserFactory.create()
     assign_perm("create_scenario_for_api", self.user, self.api)
 def setUp(self):
     self.api = APIFactory.create(name="ZGW")
     self.test_scenario = TestScenarioFactory.create(api=self.api)
     self.user = UserFactory.create()
     assign_perm("list_scenario_for_api", self.user, self.api)