'Test creating a stack domain user.'

def test_create_stack_domain_user(self):

    ctx = utils.dummy_context()
    self.patchobject(ctx, '_create_auth_plugin')
    ctx.trust_id = None
    self._stub_domain_admin_client()
    self.mock_admin_client.users = self.m.CreateMockAnything()
    mock_user = self.m.CreateMockAnything()
    mock_user.id = 'duser123'
    self.mock_admin_client.users.create(name='duser', password=None, default_project='aproject', domain='adomain123').AndReturn(mock_user)
    self.mock_admin_client.roles = self.m.CreateMockAnything()
    self.mock_admin_client.roles.list(name='heat_stack_user').AndReturn(self._mock_roles_list())
    self.mock_admin_client.roles.grant(project='aproject', role='4546', user='duser123').AndReturn(None)
    self.m.ReplayAll()
    heat_ks_client = heat_keystoneclient.KeystoneClient(ctx)
    heat_ks_client.create_stack_domain_user(username='duser', project_id='aproject')
