'Create sample data for password expiry tests.
The test environment will consist of a single domain, containing
a single project. It will create three users and one group.
Each user is going to be given a role assignment on the project
and the domain. Two of the three users are going to be placed into
the group, which won\'t have any role assignments to either the
project or the domain.'

def load_sample_data(self):

    self._populate_default_domain()
    self.domain = unit.new_domain_ref()
    self.resource_api.create_domain(self.domain['id'], self.domain)
    self.domain_id = self.domain['id']
    self.project = unit.new_project_ref(domain_id=self.domain_id)
    self.project_id = self.project['id']
    self.project = self.resource_api.create_project(self.project_id, self.project)
    self.group = unit.new_group_ref(domain_id=self.domain_id)
    self.group = self.identity_api.create_group(self.group)
    self.group_id = self.group['id']
    self.starttime = datetime.datetime.utcnow()
    with freezegun.freeze_time(self.starttime):
        self.config_fixture.config(group='security_compliance', password_expires_days=1)
        self.user = unit.create_user(self.identity_api, domain_id=self.domain_id)
        self.config_fixture.config(group='security_compliance', password_expires_days=2)
        self.user2 = unit.create_user(self.identity_api, domain_id=self.domain_id)
        self.config_fixture.config(group='security_compliance', password_expires_days=3)
        self.user3 = unit.create_user(self.identity_api, domain_id=self.domain_id)
    self.role = unit.new_role_ref(name='admin')
    self.role_api.create_role(self.role['id'], self.role)
    self.role_id = self.role['id']
    self.assignment_api.create_grant(self.role_id, user_id=self.user['id'], domain_id=self.domain_id)
    self.assignment_api.create_grant(self.role_id, user_id=self.user2['id'], domain_id=self.domain_id)
    self.assignment_api.create_grant(self.role_id, user_id=self.user3['id'], domain_id=self.domain_id)
    self.assignment_api.create_grant(self.role_id, user_id=self.user['id'], project_id=self.project_id)
    self.assignment_api.create_grant(self.role_id, user_id=self.user2['id'], project_id=self.project_id)
    self.assignment_api.create_grant(self.role_id, user_id=self.user3['id'], project_id=self.project_id)
    self.identity_api.add_user_to_group(self.user2['id'], self.group_id)
    self.identity_api.add_user_to_group(self.user3['id'], self.group_id)
