'Test that a user can add, remove and manage their SSH public keys'

def _check_key(self, pubkey):

    url = u'/v1/keys'
    body = {u'id': u'mykey@box.local', u'public': pubkey}
    response = self.client.post(url, json.dumps(body), content_type=u'application/json', HTTP_AUTHORIZATION=u'token    {}'.format(self.token))
    self.assertEqual(response.status_code, 201)
    key_id = response.data[u'id']
    response = self.client.get(url, HTTP_AUTHORIZATION=u'token    {}'.format(self.token))
    self.assertEqual(response.status_code, 200)
    self.assertEqual(len(response.data[u'results']), 1)
    url = u'/v1/keys/{key_id}'.format(**locals())
    response = self.client.get(url, HTTP_AUTHORIZATION=u'token    {}'.format(self.token))
    self.assertEqual(response.status_code, 200)
    self.assertEqual(body[u'id'], response.data[u'id'])
    self.assertEqual(body[u'public'], response.data[u'public'])
    response = self.client.delete(url, HTTP_AUTHORIZATION=u'token    {}'.format(self.token))
    self.assertEqual(response.status_code, 204)
