'Test creating ec2 credentials for domain user, fallback path.'

def test_create_stack_domain_user_keypair_legacy_fallback(self):

    self._clear_domain_override()
    self._stubs_auth()
    ctx = utils.dummy_context()
    ctx.trust_id = None
    ex_data = {'access': 'dummy_access2', 'secret': 'dummy_secret2'}
    ex_data_json = json.dumps(ex_data)
    self._stub_uuid(['dummy_access2', 'dummy_secret2'])
    self.mock_ks_v3_client.credentials = self.m.CreateMockAnything()
    mock_credential = self.m.CreateMockAnything()
    mock_credential.id = '1234567'
    mock_credential.user_id = 'atestuser2'
    mock_credential.blob = ex_data_json
    mock_credential.type = 'ec2'
    self.mock_ks_v3_client.credentials.create(user='atestuser2', type='ec2', blob=ex_data_json, project=ctx.tenant_id).AndReturn(mock_credential)
    self.m.ReplayAll()
    heat_ks_client = heat_keystoneclient.KeystoneClient(ctx)
    ec2_cred = heat_ks_client.create_stack_domain_user_keypair(user_id='atestuser2', project_id='aproject')
    self.assertEqual('1234567', ec2_cred.id)
    self.assertEqual('dummy_access2', ec2_cred.access)
    self.assertEqual('dummy_secret2', ec2_cred.secret)
