def setUp(self):
        self.users = {
            'staff': factories.UserFactory(is_staff=True),
            'first': factories.UserFactory(),
            'first_manager': factories.UserFactory(),
            'first_admin': factories.UserFactory(),
            'second': factories.UserFactory(),
            'no_role': factories.UserFactory(),
        }

        self.customers = {
            'first': factories.CustomerFactory(),
            'second': factories.CustomerFactory(),
        }

        customer = self.customers['first']
        project = factories.ProjectFactory(customer=customer)
        project_group = factories.ProjectGroupFactory(customer=customer)
        project_group.projects.add(project)

        for user, customer, role in self.all_roles:
            self.customers[customer].add_user(self.users[user],
                                              self.role_map[role])

        project_group.add_user(self.users['first_manager'],
                               ProjectGroupRole.MANAGER)
        project.add_user(self.users['first_admin'], ProjectRole.ADMINISTRATOR)
예제 #2
0
    def test_owner_can_see_only_customer_events(self):
        structure_factories.CustomerFactory()

        customer = structure_factories.CustomerFactory()
        owner = structure_factories.UserFactory()
        customer.add_user(owner, structure_models.CustomerRole.OWNER)

        self.client.force_authenticate(user=owner)
        self._get_events_by_scope_type(structure_models.Customer)
        self.assertEqual(self.must_terms,
                         {'customer_uuid': [customer.uuid.hex]})
예제 #3
0
    def setUp(self):
        self.staff = factories.UserFactory(is_staff=True)
        self.user1 = factories.UserFactory()
        self.user2 = factories.UserFactory()

        self.customer1 = factories.CustomerFactory()
        self.customer2 = factories.CustomerFactory()

        self.customer1.add_user(self.user1, CustomerRole.OWNER)
        self.customer2.add_user(self.user1, CustomerRole.OWNER)
        self.customer2.add_user(self.user2, CustomerRole.OWNER)
예제 #4
0
    def setUp(self):
        self.users = {
            'staff': factories.UserFactory(is_staff=True),
            'owner': factories.UserFactory(),
            'not_owner': factories.UserFactory(),
            'admin': factories.UserFactory(),
            'admin_other': factories.UserFactory(),
            'manager': factories.UserFactory(),
            'group_manager': factories.UserFactory(),
        }

        self.customers = {
            'owned': factories.CustomerFactory.create_batch(2),
            'inaccessible': factories.CustomerFactory.create_batch(2),
            'admin': factories.CustomerFactory(),
            'manager': factories.CustomerFactory(),
            'group_manager': factories.CustomerFactory(),
        }

        for customer in self.customers['owned']:
            customer.add_user(self.users['owner'], CustomerRole.OWNER)

        self.projects = {
            'admin':
            factories.ProjectFactory(customer=self.customers['admin']),
            'manager':
            factories.ProjectFactory(customer=self.customers['manager']),
            'group_manager':
            factories.ProjectFactory(customer=self.customers['group_manager']),
        }

        self.projects['admin'].add_user(self.users['admin'],
                                        ProjectRole.ADMINISTRATOR)
        self.projects['manager'].add_user(self.users['manager'],
                                          ProjectRole.MANAGER)

        self.project_groups = {
            'admin':
            factories.ProjectGroupFactory(customer=self.customers['admin']),
            'manager':
            factories.ProjectGroupFactory(customer=self.customers['manager']),
            'group_manager':
            factories.ProjectGroupFactory(
                customer=self.customers['group_manager']),
        }

        self.project_groups['admin'].projects.add(self.projects['admin'])
        self.project_groups['manager'].projects.add(self.projects['manager'])
        self.project_groups['group_manager'].projects.add(
            self.projects['group_manager'])
        self.project_groups['group_manager'].add_user(
            self.users['group_manager'], ProjectGroupRole.MANAGER)
예제 #5
0
    def setUp(self):
        self.users = {
            'staff': factories.UserFactory(is_staff=True),
            'owner': factories.UserFactory(),
            'not_owner': factories.UserFactory(),
        }

        self.customers = {
            'owner': factories.CustomerFactory(),
            'inaccessible': factories.CustomerFactory(),
        }

        self.customers['owner'].add_user(self.users['owner'], CustomerRole.OWNER)
예제 #6
0
    def test_new_project_connects_to_available_services_of_customer(self):
        customer = factories.CustomerFactory()
        service = self.create_service(customer, available_for_all=True)

        other_customer = factories.CustomerFactory()
        other_service = self.create_service(other_customer, available_for_all=True)

        # Act
        project = factories.ProjectFactory(customer=customer)

        # Assert
        self.assertTrue(self.link_exists(project, service))
        self.assertFalse(self.link_exists(project, other_service))
예제 #7
0
    def test_if_service_became_available_it_connects_to_all_projects_of_customer(self):
        customer = factories.CustomerFactory()
        service = self.create_service(customer, available_for_all=False)
        project = factories.ProjectFactory(customer=customer)

        other_customer = factories.CustomerFactory()
        other_project = factories.ProjectFactory(customer=other_customer)

        # Act
        service.available_for_all = True
        service.save()

        # Assert
        self.assertTrue(self.link_exists(project, service))
        self.assertFalse(self.link_exists(other_project, service))
예제 #8
0
    def setUp(self):
        self.customers = {
            'owned': structure_factories.CustomerFactory(),
            'has_admined_project': structure_factories.CustomerFactory(),
            'has_managed_project': structure_factories.CustomerFactory(),
            'has_managed_by_group_manager': structure_factories.CustomerFactory(),
        }

        self.users = {
            'customer_owner': structure_factories.UserFactory(),
            'project_admin': structure_factories.UserFactory(),
            'project_manager': structure_factories.UserFactory(),
            'group_manager': structure_factories.UserFactory(),
            'no_role': structure_factories.UserFactory(),
        }

        self.projects = {
            'owned': structure_factories.ProjectFactory(customer=self.customers['owned']),
            'admined': structure_factories.ProjectFactory(customer=self.customers['has_admined_project']),
            'managed': structure_factories.ProjectFactory(customer=self.customers['has_managed_project']),
            'managed_by_group_manager': structure_factories.ProjectFactory(
                customer=self.customers['has_managed_by_group_manager']),
        }

        self.clouds = {
            'owned': factories.CloudFactory(
                state=SynchronizationStates.IN_SYNC, customer=self.customers['owned']),
            'admined': factories.CloudFactory(
                state=SynchronizationStates.IN_SYNC, customer=self.customers['has_admined_project']),
            'managed': factories.CloudFactory(
                state=SynchronizationStates.IN_SYNC, customer=self.customers['has_managed_project']),
            'managed_by_group_manager': factories.CloudFactory(
                state=SynchronizationStates.IN_SYNC, customer=self.customers['has_managed_by_group_manager']),
            'not_in_project': factories.CloudFactory(),
        }

        self.customers['owned'].add_user(self.users['customer_owner'], CustomerRole.OWNER)

        self.projects['admined'].add_user(self.users['project_admin'], ProjectRole.ADMINISTRATOR)
        self.projects['managed'].add_user(self.users['project_manager'], ProjectRole.MANAGER)
        project_group = structure_factories.ProjectGroupFactory()
        project_group.projects.add(self.projects['managed_by_group_manager'])
        project_group.add_user(self.users['group_manager'], ProjectGroupRole.MANAGER)

        factories.CloudProjectMembershipFactory(cloud=self.clouds['admined'], project=self.projects['admined'])
        factories.CloudProjectMembershipFactory(cloud=self.clouds['managed'], project=self.projects['managed'])
        factories.CloudProjectMembershipFactory(
            cloud=self.clouds['managed_by_group_manager'], project=self.projects['managed_by_group_manager'])
    def setUp(self):
        self.users = {
            'owner': structure_factories.UserFactory(),
            'admin': structure_factories.UserFactory(),
            'manager': structure_factories.UserFactory(),
            'group_manager': structure_factories.UserFactory(),
            'no_role': structure_factories.UserFactory(),
            'not_connected': structure_factories.UserFactory(),
        }

        # a single customer
        self.customer = structure_factories.CustomerFactory()
        self.customer.add_user(self.users['owner'], CustomerRole.OWNER)

        # that has 3 users connected: admin, manager, group_manager
        self.connected_project = structure_factories.ProjectFactory(customer=self.customer)
        self.connected_project.add_user(self.users['admin'], ProjectRole.ADMINISTRATOR)
        self.connected_project.add_user(self.users['manager'], ProjectRole.MANAGER)
        project_group = structure_factories.ProjectGroupFactory()
        project_group.projects.add(self.connected_project)
        project_group.add_user(self.users['group_manager'], ProjectGroupRole.MANAGER)

        # has defined a service and connected service to a project
        self.service = factories.OpenStackServiceFactory(customer=self.customer)
        self.service_project_link = factories.OpenStackServiceProjectLinkFactory(
            project=self.connected_project,
            service=self.service,
            state=SynchronizationStates.IN_SYNC)

        # the customer also has another project with users but without a permission link
        self.not_connected_project = structure_factories.ProjectFactory(customer=self.customer)
        self.not_connected_project.add_user(self.users['not_connected'], ProjectRole.ADMINISTRATOR)
        self.not_connected_project.save()

        self.url = factories.OpenStackServiceProjectLinkFactory.get_list_url()
예제 #10
0
    def setUp(self):
        self.staff = structure_factories.UserFactory(is_staff=True)
        self.customer_owner = structure_factories.UserFactory()
        self.project_admin = structure_factories.UserFactory()
        self.project_manager = structure_factories.UserFactory()
        self.user = structure_factories.UserFactory()

        self.customer = structure_factories.CustomerFactory()
        self.customer.add_user(self.customer_owner,
                               structure_models.CustomerRole.OWNER)

        self.customer_role = structure_models.CustomerRole.OWNER
        self.customer_invitation = factories.CustomerInvitationFactory(
            customer=self.customer, customer_role=self.customer_role)

        self.project = structure_factories.ProjectFactory(
            customer=self.customer)
        self.project.add_user(self.project_admin,
                              structure_models.ProjectRole.ADMINISTRATOR)
        self.project.add_user(self.project_manager,
                              structure_models.ProjectRole.MANAGER)

        self.project_role = structure_models.ProjectRole.ADMINISTRATOR
        self.project_invitation = factories.ProjectInvitationFactory(
            project=self.project, project_role=self.project_role)
    def setUp(self):
        self.owner = structure_factories.UserFactory(is_staff=True, is_superuser=True)
        self.customer = structure_factories.CustomerFactory()
        self.customer.add_user(self.owner, CustomerRole.OWNER)

        self.project = structure_factories.ProjectFactory(customer=self.customer)
        self.service = factories.OpenStackServiceFactory(customer=self.customer)
예제 #12
0
    def test_user_can_access_all_customers_if_he_is_staff(self, user):
        self.client.force_authenticate(user=getattr(self.fixture, user))

        self._check_user_direct_access_customer(self.fixture.customer, status.HTTP_200_OK)

        customer = factories.CustomerFactory()
        self._check_user_direct_access_customer(customer, status.HTTP_200_OK)
예제 #13
0
    def test_licenses_stats_filtering_by_customer_with_instances(self):
        self.client.force_authenticate(self.staff)
        # other customer is connected with another template and has one instance connected to it
        other_customer = structure_factories.CustomerFactory()
        other_project = structure_factories.ProjectFactory(
            customer=other_customer)
        other_cloud = factories.CloudFactory(customer=other_customer)
        other_template = factories.TemplateFactory()
        factories.ImageFactory(cloud=other_cloud, template=self.template)
        other_template_license = factories.TemplateLicenseFactory()
        other_template.template_licenses.add(other_template_license)

        factories.InstanceFactory(
            template=other_template,
            cloud_project_membership__project=other_project,
        )
        # when
        response = self.client.get(self.url, {
            'customer': other_customer.uuid,
            'aggregate': 'project'
        })
        # then: response should return data for other_instance, but not first_instance and second_instance
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 1,
                         "Response should contain data only for one project")
        self.assertEqual(response.data[0]['project_uuid'],
                         other_project.uuid.hex)
        self.assertEqual(
            response.data[0]['count'], 1,
            "Customer should have only one instance with one license")
예제 #14
0
    def setUp(self):
        self.users = {
            'owner': structure_factories.UserFactory(),
            'admin': structure_factories.UserFactory(),
            'manager': structure_factories.UserFactory(),
            'group_manager': structure_factories.UserFactory(),
            'no_role': structure_factories.UserFactory(),
            'not_connected': structure_factories.UserFactory(),
        }

        # a single customer
        self.customer = structure_factories.CustomerFactory()
        self.customer.add_user(self.users['owner'], CustomerRole.OWNER)

        # that has 3 users connected: admin, manager, group_manager
        self.connected_project = structure_factories.ProjectFactory(customer=self.customer)
        self.connected_project.add_user(self.users['admin'], ProjectRole.ADMINISTRATOR)
        self.connected_project.add_user(self.users['manager'], ProjectRole.MANAGER)
        project_group = structure_factories.ProjectGroupFactory()
        project_group.projects.add(self.connected_project)
        project_group.add_user(self.users['group_manager'], ProjectGroupRole.MANAGER)

        # has defined a cloud and connected cloud to a project
        self.cloud = factories.CloudFactory(customer=self.customer)
        factories.CloudProjectMembershipFactory(project=self.connected_project, cloud=self.cloud)

        # the customer also has another project with users but without a permission link
        self.not_connected_project = structure_factories.ProjectFactory(customer=self.customer)
        self.not_connected_project.add_user(self.users['not_connected'], ProjectRole.ADMINISTRATOR)
        self.not_connected_project.save()
예제 #15
0
 def setUp(self):
     # project, customer and project_group
     self.customer = structure_factories.CustomerFactory()
     self.project = structure_factories.ProjectFactory(
         customer=self.customer)
     self.project_group = structure_factories.ProjectGroupFactory()
     self.project_group.projects.add(self.project)
     # cloud and template
     self.cloud = factories.CloudFactory()
     factories.CloudProjectMembershipFactory(cloud=self.cloud,
                                             project=self.project)
     template = factories.TemplateFactory()
     factories.ImageFactory(cloud=self.cloud, template=template)
     # license
     self.license = factories.TemplateLicenseFactory()
     self.license.templates.add(template)
     # users
     self.staff = structure_factories.UserFactory(username='******',
                                                  is_superuser=True,
                                                  is_staff=True)
     self.manager = structure_factories.UserFactory(username='******')
     self.project.add_user(self.manager,
                           structure_models.ProjectRole.MANAGER)
     self.administrator = structure_factories.UserFactory(
         username='******')
     self.project.add_user(self.administrator,
                           structure_models.ProjectRole.ADMINISTRATOR)
     self.owner = structure_factories.UserFactory(username='******')
     self.customer.add_user(self.owner, structure_models.CustomerRole.OWNER)
     self.group_manager = structure_factories.UserFactory()
     self.project_group = structure_factories.ProjectGroupFactory()
     self.project_group.projects.add(self.project)
     self.project_group.add_user(self.group_manager,
                                 structure_models.ProjectGroupRole.MANAGER)
예제 #16
0
 def setUp(self):
     self.customer = structure_factories.CustomerFactory()
     self.customer_owner = structure_factories.UserFactory()
     self.staff_user = structure_factories.UserFactory(is_staff=True)
     self.user = structure_factories.UserFactory()
     self.customer.add_user(self.customer_owner,
                            structure_models.CustomerRole.OWNER)
예제 #17
0
    def setUp(self):
        self.users = {
            'owner': factories.UserFactory(),
            'admin': factories.UserFactory(),
            'manager': factories.UserFactory(),
            'group_manager': factories.UserFactory(),
            'no_role': factories.UserFactory(),
        }

        self.customer = factories.CustomerFactory()
        self.customer.add_user(self.users['owner'], CustomerRole.OWNER)

        project_groups = factories.ProjectGroupFactory.create_batch(
            3, customer=self.customer)
        project_groups.append(factories.ProjectGroupFactory())

        self.project_groups = {
            'owner': project_groups[:-1],
            'admin': project_groups[0:2],
            'manager': project_groups[1:3],
            'group_manager': project_groups[2:3],
            'inaccessible': project_groups[-1:],
        }
        project_groups[2].add_user(self.users['group_manager'],
                                   ProjectGroupRole.MANAGER)

        admined_project = factories.ProjectFactory(customer=self.customer)
        admined_project.add_user(self.users['admin'], ProjectGroupRole.MANAGER)
        admined_project.project_groups.add(*self.project_groups['admin'])

        managed_project = factories.ProjectFactory(customer=self.customer)
        managed_project.add_user(self.users['manager'], ProjectRole.MANAGER)
        managed_project.project_groups.add(*self.project_groups['manager'])
예제 #18
0
 def setUp(self):
     # project, customer and project_group
     self.customer = structure_factories.CustomerFactory()
     self.project = structure_factories.ProjectFactory(
         customer=self.customer)
     self.project_group = structure_factories.ProjectGroupFactory()
     self.project_group.projects.add(self.project)
     # cloud and template
     self.cloud = factories.CloudFactory(customer=self.customer)
     factories.CloudProjectMembershipFactory(cloud=self.cloud,
                                             project=self.project)
     self.template = factories.TemplateFactory(os='OS')
     factories.ImageFactory(cloud=self.cloud, template=self.template)
     # license
     self.license = factories.TemplateLicenseFactory()
     self.license.templates.add(self.template)
     # users
     self.staff = structure_factories.UserFactory(is_superuser=True,
                                                  is_staff=True)
     self.manager = structure_factories.UserFactory()
     self.project.add_user(self.manager,
                           structure_models.ProjectRole.MANAGER)
     self.group_manager = structure_factories.UserFactory()
     self.project_group.add_user(self.group_manager,
                                 structure_models.ProjectGroupRole.MANAGER)
예제 #19
0
    def setUp(self):
        self.customer = structure_factories.CustomerFactory()
        self.owner = structure_factories.UserFactory()
        self.customer.add_user(self.owner, structure_models.CustomerRole.OWNER)

        self.admin = structure_factories.UserFactory()
        self.manager = structure_factories.UserFactory()
        self.group_manager = structure_factories.UserFactory()
        self.project = structure_factories.ProjectFactory(
            customer=self.customer)
        self.project.add_user(self.admin,
                              structure_models.ProjectRole.ADMINISTRATOR)
        self.project.add_user(self.manager,
                              structure_models.ProjectRole.MANAGER)
        project_group = structure_factories.ProjectGroupFactory(
            customer=self.customer)
        project_group.projects.add(self.project)
        project_group.add_user(self.group_manager,
                               structure_models.ProjectGroupRole.MANAGER)
        self.cloud = factories.CloudFactory(customer=self.customer)
        factories.CloudProjectMembershipFactory(cloud=self.cloud,
                                                project=self.project)

        self.expected_public_fields = ('auth_url', 'uuid', 'url', 'name',
                                       'customer', 'customer_name',
                                       'customer_native_name', 'flavors',
                                       'projects', 'dummy', 'resources_count',
                                       'service_type')
    def test_target_model_instance_deletion_decreases_scope_counter_quota(
            self):
        customer = structure_factories.CustomerFactory()
        project = structure_factories.ProjectFactory(customer=customer)
        project.delete()

        self.assertEqual(customer.quotas.get(name='nc_project_count').usage, 0)
예제 #21
0
    def setUp(self):
        self.staff = structure_factories.UserFactory(is_staff=True)
        self.owner = structure_factories.UserFactory()
        self.admin = structure_factories.UserFactory()

        self.customer = structure_factories.CustomerFactory()
        self.customer.add_user(self.owner, structure_models.CustomerRole.OWNER)
        self.cloud = factories.CloudFactory(customer=self.customer)
        self.project = structure_factories.ProjectFactory(customer=self.customer)
        self.project.add_user(self.admin, structure_models.ProjectRole.ADMINISTRATOR)
        self.cloud_project_membership = factories.CloudProjectMembershipFactory(cloud=self.cloud, project=self.project)

        self.valid_data = {
            'name': 'test_security_group',
            'description': 'test security_group description',
            'cloud_project_membership': {
                'url': factories.CloudProjectMembershipFactory.get_url(self.cloud_project_membership),
            },
            'rules': [
                {
                    'protocol': 'tcp',
                    'from_port': 1,
                    'to_port': 10,
                    'cidr': '10.7.50.1/24',
                }
            ]
        }
        self.url = factories.SecurityGroupFactory.get_list_url()
예제 #22
0
    def setUp(self):
        self.customer = structure_factories.CustomerFactory()
        self.project_group = structure_factories.ProjectGroupFactory(
            customer=self.customer)
        self.project1 = structure_factories.ProjectFactory(
            customer=self.customer)
        self.project2 = structure_factories.ProjectFactory(
            customer=self.customer)
        self.membership1 = factories.CloudProjectMembershipFactory(
            project=self.project1)
        self.membership2 = factories.CloudProjectMembershipFactory(
            project=self.project2)

        self.project_group.projects.add(self.project1)
        # users
        self.staff = structure_factories.UserFactory(is_staff=True)
        self.customer_owner = structure_factories.UserFactory()
        self.customer.add_user(self.customer_owner,
                               structure_models.CustomerRole.OWNER)
        self.project_group_manager = structure_factories.UserFactory()
        self.project_group.add_user(self.project_group_manager,
                                    structure_models.ProjectGroupRole.MANAGER)
        self.project1_admin = structure_factories.UserFactory()
        self.project1.add_user(self.project1_admin,
                               structure_models.ProjectRole.ADMINISTRATOR)

        quota_names = ['vcpu', 'ram', 'storage', 'max_instances']

        self.expected_quotas_for_project1 = models.CloudProjectMembership.get_sum_of_quotas_as_dict(
            [self.membership1], quota_names)

        self.expected_quotas_for_both_projects = models.CloudProjectMembership.get_sum_of_quotas_as_dict(
            [self.membership1, self.membership2], quota_names)
 def setUp(self):
     super(BackupSchedulePermissionsTest, self).setUp()
     # objects
     self.customer = structure_factories.CustomerFactory()
     self.project = structure_factories.ProjectFactory(
         customer=self.customer)
     self.project_group = structure_factories.ProjectGroupFactory(
         customer=self.customer)
     self.project_group.projects.add(self.project)
     self.service = factories.OpenStackServiceFactory(
         customer=self.customer)
     self.spl = factories.OpenStackServiceProjectLinkFactory(
         service=self.service, project=self.project)
     self.instance = factories.InstanceFactory(
         service_project_link=self.spl)
     self.schedule = factories.BackupScheduleFactory(instance=self.instance)
     # users
     self.staff = structure_factories.UserFactory(username='******',
                                                  is_staff=True)
     self.regular_user = structure_factories.UserFactory(
         username='******')
     self.project_admin = structure_factories.UserFactory(username='******')
     self.project.add_user(self.project_admin,
                           structure_models.ProjectRole.ADMINISTRATOR)
     self.customer_owner = structure_factories.UserFactory(username='******')
     self.customer.add_user(self.customer_owner,
                            structure_models.CustomerRole.OWNER)
     self.project_group_manager = structure_factories.UserFactory(
         username='******')
     self.project_group.add_user(self.project_group_manager,
                                 structure_models.ProjectGroupRole.MANAGER)
예제 #24
0
    def setUp(self):
        self.users = {
            'owner': factories.UserFactory(),
            'no_role': factories.UserFactory(),
        }

        self.project_groups = {}
        self.projects = {}
        self.memberships = {}
        self.customers = {}

        for i in ('owner', 'inaccessible'):
            customer = factories.CustomerFactory()

            self.customers[i] = customer
            self.projects[i] = factories.ProjectFactory.create_batch(
                2, customer=customer)
            self.project_groups[
                i] = factories.ProjectGroupFactory.create_batch(
                    2, customer=customer)

            project = self.projects[i][0]
            project_group = self.project_groups[i][0]

            project_group.projects.add(project)

            membership = ProjectGroupMembership.objects.get(
                project=project, projectgroup=project_group)
            self.memberships[i] = membership

        self.customers['owner'].add_user(self.users['owner'],
                                         CustomerRole.OWNER)
예제 #25
0
    def setUp(self):
        self.staff = structure_factories.UserFactory(is_staff=True)
        self.customer = structure_factories.CustomerFactory()
        self.owner = structure_factories.UserFactory()
        self.customer.add_user(self.owner, structure_models.CustomerRole.OWNER)

        self.manager = structure_factories.UserFactory(username='******')
        self.admin = structure_factories.UserFactory(username='******')
        self.project = structure_factories.ProjectFactory(
            customer=self.customer)
        self.project.add_user(self.manager,
                              structure_models.ProjectRole.MANAGER)
        self.project.add_user(self.admin,
                              structure_models.ProjectRole.ADMINISTRATOR)
        project_group = structure_factories.ProjectGroupFactory()
        self.project.project_groups.add(project_group)

        self.group_manager = structure_factories.UserFactory(
            username='******')
        project_group.add_user(self.group_manager,
                               structure_models.ProjectGroupRole.MANAGER)

        models.Instance.objects.all().delete()
        self.instance = factories.InstanceFactory(
            cloud_project_membership__project=self.project)
        factories.InstanceSlaHistoryFactory(instance=self.instance,
                                            period='2015')
        self.other_instance = factories.InstanceFactory()
        factories.InstanceSlaHistoryFactory(instance=self.other_instance,
                                            period='2015')
    def setUp(self):
        self.users = {
            'staff':
            structure_factories.UserFactory(username='******', is_staff=True),
            'owner':
            structure_factories.UserFactory(username='******'),
            'administrator':
            structure_factories.UserFactory(username='******'),
            'manager':
            structure_factories.UserFactory(username='******'),
            'regular_user':
            structure_factories.UserFactory(username='******'),
        }

        self.customer = structure_factories.CustomerFactory()
        self.customer.add_user(self.users['owner'],
                               structure_models.CustomerRole.OWNER)
        self.project = structure_factories.ProjectFactory(
            customer=self.customer)
        self.project.add_user(self.users['administrator'],
                              structure_models.ProjectRole.ADMINISTRATOR)
        self.project_group = structure_factories.ProjectGroupFactory(
            customer=self.customer)
        self.project_group.add_user(self.users['manager'],
                                    structure_models.ProjectGroupRole.MANAGER)
        self.project_group.projects.add(self.project)

        self.default_price_list_item = factories.DefaultPriceListItemFactory()
예제 #27
0
    def setUp(self):
        self.owner = structure_factories.UserFactory()
        self.customer = structure_factories.CustomerFactory()
        self.customer.add_user(self.owner, structure_models.CustomerRole.OWNER)
        self.other_user = structure_factories.UserFactory()

        self.event_type = 'customer_update_succeeded'
        self.other_event = 'customer_deletion_succeeded'
        self.message = 'Customer {customer_name} has been updated.'
        self.event = {
            'message':
            self.message,
            'type':
            self.event_type,
            'context':
            event_logger.customer.compile_context(customer=self.customer),
            'timestamp':
            time.time()
        }

        # Create email hook for another user
        self.other_hook = logging_models.EmailHook.objects.create(
            user=self.other_user,
            email=self.owner.email,
            event_types=[self.event_type])
    def setUp(self):
        self.staff = structure_factories.UserFactory(is_staff=True)
        self.owner = structure_factories.UserFactory()
        self.admin = structure_factories.UserFactory()

        self.customer = structure_factories.CustomerFactory()
        self.customer.add_user(self.owner, structure_models.CustomerRole.OWNER)
        self.service = factories.OpenStackServiceFactory(customer=self.customer)
        self.project = structure_factories.ProjectFactory(customer=self.customer)
        self.project.add_user(self.admin, structure_models.ProjectRole.ADMINISTRATOR)
        self.service_project_link = factories.OpenStackServiceProjectLinkFactory(
            service=self.service, project=self.project)

        self.valid_data = {
            'name': 'test_security_group',
            'description': 'test security_group description',
            'service_project_link': {
                'url': factories.OpenStackServiceProjectLinkFactory.get_url(self.service_project_link),
            },
            'rules': [
                {
                    'protocol': 'tcp',
                    'from_port': 1,
                    'to_port': 10,
                    'cidr': '11.11.1.2/24',
                }
            ]
        }
        self.url = factories.SecurityGroupFactory.get_list_url()
예제 #29
0
 def setUp(self):
     super(BackupSchedulePermissionsTest, self).setUp()
     # objects
     self.customer = structure_factories.CustomerFactory()
     self.project = structure_factories.ProjectFactory(
         customer=self.customer)
     self.project_group = structure_factories.ProjectGroupFactory(
         customer=self.customer)
     self.project_group.projects.add(self.project)
     self.cloud = iaas_factories.CloudFactory(customer=self.customer)
     self.cpm = iaas_factories.CloudProjectMembershipFactory(
         cloud=self.cloud, project=self.project)
     self.instance = iaas_factories.InstanceFactory(
         cloud_project_membership=self.cpm)
     self.schedule = factories.BackupScheduleFactory(
         backup_source=self.instance)
     # users
     self.staff = structure_factories.UserFactory(username='******',
                                                  is_staff=True)
     self.regular_user = structure_factories.UserFactory(
         username='******')
     self.project_admin = structure_factories.UserFactory(username='******')
     self.project.add_user(self.project_admin,
                           structure_models.ProjectRole.ADMINISTRATOR)
     self.customer_owner = structure_factories.UserFactory(username='******')
     self.customer.add_user(self.customer_owner,
                            structure_models.CustomerRole.OWNER)
     self.project_group_manager = structure_factories.UserFactory(
         username='******')
     self.project_group.add_user(self.project_group_manager,
                                 structure_models.ProjectGroupRole.MANAGER)
예제 #30
0
    def setUp(self):
        self.user = structure_factories.UserFactory()

        self.customer = structure_factories.CustomerFactory()
        self.owner = structure_factories.UserFactory()
        self.customer.add_user(self.owner, structure_models.CustomerRole.OWNER)

        self.project_group = structure_factories.ProjectGroupFactory(
            customer=self.customer)
        self.group_manager = structure_factories.UserFactory()
        self.project_group.add_user(self.group_manager,
                                    structure_models.ProjectGroupRole.MANAGER)

        self.project = structure_factories.ProjectFactory(
            customer=self.customer)
        self.admin = structure_factories.UserFactory()
        self.project.add_user(self.admin,
                              structure_models.ProjectRole.ADMINISTRATOR)

        self.events = {
            'customer_event':
            factories.EventFactory(customer_uuid=self.customer.uuid.hex),
            'project_group_event':
            factories.EventFactory(
                project_group_uuid=self.project_group.uuid.hex),
            'project_event':
            factories.EventFactory(project_uuid=self.project.uuid.hex),
        }