Beispiel #1
0
    def testUserToDict(self):
        """Whether the necessary fields match in a dictionary representation."""
        user = models.User()
        user.is_key_revoked = False
        user_dict = user.to_dict()

        self.assertEqual(user_dict['id'], user.id)
        self.assertEqual(user_dict['email'], user.email)
        self.assertEqual(user_dict['name'], user.name)
        self.assertEqual(user_dict['private_key'], user.private_key)
        self.assertEqual(user_dict['public_key'], user.public_key)
        self.assertEqual(user_dict['access'], models.NOT_REVOKED_TEXT)
        self.assertEqual(user_dict['accessChange'], models.DISABLE_TEXT)

        user.is_key_revoked = True
        user_dict = user.to_dict()
        self.assertEqual(user_dict['access'], models.REVOKED_TEXT)
        self.assertEqual(user_dict['accessChange'], models.ENABLE_TEXT)
Beispiel #2
0
  def testUserToDict(self):
    """Whether the necessary fields match in a dictionary representation."""
    user = models.User()
    user.is_key_revoked = False
    user_dict = user.to_dict()

    self.assertEqual(user_dict['id'], user.id)
    self.assertEqual(user_dict['email'], user.email)
    self.assertEqual(user_dict['name'], user.name)
    self.assertEqual(user_dict['private_key'], user.private_key)
    self.assertEqual(user_dict['public_key'], user.public_key)
    self.assertEqual(user_dict['access'], models.NOT_REVOKED_TEXT)
    self.assertEqual(user_dict['accessChange'], models.DISABLE_TEXT)

    user.is_key_revoked = True
    user_dict = user.to_dict()
    self.assertEqual(user_dict['access'], models.REVOKED_TEXT)
    self.assertEqual(user_dict['accessChange'], models.ENABLE_TEXT)
Beispiel #3
0
  def testListUsersHandler(self):
    """Test the list user handler gets users from the database."""
    users = []
    for fake_email_and_name in base_test.FAKE_EMAILS_AND_NAMES:
      user = models.User(email=fake_email_and_name['email'],
                         name=fake_email_and_name['name'],
                         private_key=fake_email_and_name['pri'],
                         public_key=fake_email_and_name['pub'])
      user.save()
      users.append(user)

    resp = self.client.get(flask.url_for('user_list'))
    user_list_output = json.loads(resp.data[len(ufo.XSSI_PREFIX):])['items']

    self.assertEquals(len(user_list_output),
                      len(base_test.FAKE_EMAILS_AND_NAMES))

    for user in users:
      self.assertIn(user.to_dict(), user_list_output)