'Test getting and deleting ec2 credentials through the ec2 API.'

def test_get_and_delete_ec2_credentials(self):

    another_user = unit.create_user(self.identity_api, domain_id=self.domainA['id'])
    just_user_auth = self.build_authentication_request(user_id=self.just_a_user['id'], password=self.just_a_user['password'], project_id=self.project['id'])
    url = ('/users/%s/credentials/OS-EC2' % self.just_a_user['id'])
    r = self.post(url, body={'tenant_id': self.project['id']}, auth=just_user_auth)
    another_user_auth = self.build_authentication_request(user_id=another_user['id'], password=another_user['password'])
    another_user_url = ('/users/%s/credentials/OS-EC2/%s' % (another_user['id'], r.result['credential']['access']))
    self.get(another_user_url, auth=another_user_auth, expected_status=exception.ForbiddenAction.code)
    just_user_url = ('/users/%s/credentials/OS-EC2/%s' % (self.just_a_user['id'], r.result['credential']['access']))
    self.get(just_user_url, auth=just_user_auth)
    self.delete(another_user_url, auth=another_user_auth, expected_status=exception.ForbiddenAction.code)
    self.delete(just_user_url, auth=just_user_auth)
