'Test getting ec2 credential by id.'

def test_get_ec2_keypair_id(self):

    user_id = 'atestuser'
    self._stubs_auth(user_id=user_id)
    ctx = utils.dummy_context()
    ctx.trust_id = None
    ex_data = {'access': 'access123', 'secret': 'secret456'}
    ex_data_json = json.dumps(ex_data)
    credential_id = 'acredential123'
    mock_credential = self.m.CreateMockAnything()
    mock_credential.id = credential_id
    mock_credential.user_id = user_id
    mock_credential.blob = ex_data_json
    mock_credential.type = 'ec2'
    self.mock_ks_v3_client.credentials = self.m.CreateMockAnything()
    self.mock_ks_v3_client.credentials.get(credential_id).AndReturn(mock_credential)
    self.m.ReplayAll()
    heat_ks_client = heat_keystoneclient.KeystoneClient(ctx)
    ec2_cred = heat_ks_client.get_ec2_keypair(credential_id=credential_id)
    self.assertEqual(credential_id, ec2_cred.id)
    self.assertEqual('access123', ec2_cred.access)
    self.assertEqual('secret456', ec2_cred.secret)
