def _create_user_expect_validation_error(self, username, password=good_password, email=good_email, 
                                 affiliation=good_affiliation, pubkey=good_pubkey):
   
   # An empty list because the ValidationError should occur before any backend
   # generate_key() calls are performed.
   mocklib.mock_backend_generate_key([])
   
   func = interface.register_user
   args = (username, password, email, affiliation, pubkey)
   self.assertRaises(ValidationError, func, *args)
 def _create_user_expect_validation_error(self, username, password=good_password, email=good_email, 
                                 affiliation=good_affiliation, pubkey=good_pubkey):
   
   # An empty list because the ValidationError should occur before any backend
   # generate_key() calls are performed.
   mocklib.mock_backend_generate_key([])
   
   func = interface.register_user
   args = (username, password, email, affiliation, pubkey)
   self.assertRaises(ValidationError, func, *args)
 def _create_user_expect_success(self, username, password=good_password, email=good_email, 
                                 affiliation=good_affiliation, pubkey=good_pubkey):
   
   # We expect a single key to be generated through the backed (the donor key)
   mocklib.mock_backend_generate_key(["1 2"])
   
   created_user = interface.register_user(username, password, email, affiliation, pubkey)
 
   user_from_db = maindb.get_user(username)
   assert(user_from_db.username == created_user.username)
   assert(user_from_db.email == created_user.email)
   assert(user_from_db.affiliation == created_user.affiliation)
   assert(user_from_db.user_pubkey == created_user.user_pubkey)
   assert(user_from_db.user_privkey == created_user.user_privkey)
   assert(user_from_db.donor_pubkey == created_user.donor_pubkey)
 def _create_user_expect_success(self, username, password=good_password, email=good_email, 
                                 affiliation=good_affiliation, pubkey=good_pubkey):
   
   # We expect a single key to be generated through the backed (the donor key)
   mocklib.mock_backend_generate_key(["1 2"])
   
   created_user = interface.register_user(username, password, email, affiliation, pubkey)
 
   user_from_db = maindb.get_user(username)
   assert(user_from_db.username == created_user.username)
   assert(user_from_db.email == created_user.email)
   assert(user_from_db.affiliation == created_user.affiliation)
   assert(user_from_db.user_pubkey == created_user.user_pubkey)
   assert(user_from_db.user_privkey == created_user.user_privkey)
   assert(user_from_db.donor_pubkey == created_user.donor_pubkey)
    def test_seattlegeni_generates_user_keypair(self):

        # We expect a single keypair to be generated directly through the keygen
        # api (specifically, the user keys).
        user_pubkey = "3 4"
        user_privkey = "2 3 3"
        mocklib.mock_keygen_generate_keypair([(user_pubkey, user_privkey)])

        # We expect a single key to be generated directly through the backed api
        # (specifically, the donor key).
        donor_pubkey = "1 2"
        mocklib.mock_backend_generate_key([donor_pubkey])

        provided_pubkey = None
        interface.register_user(good_username, good_password, good_email,
                                good_affiliation, provided_pubkey)

        user_from_db = maindb.get_user(good_username)

        assert (user_from_db.user_pubkey == user_pubkey)
        assert (user_from_db.user_privkey == user_privkey)
        assert (user_from_db.donor_pubkey == donor_pubkey)
  def test_seattlegeni_generates_user_keypair(self):
    
    # We expect a single keypair to be generated directly through the keygen
    # api (specifically, the user keys).
    user_pubkey = "3 4"
    user_privkey = "2 3 3"
    mocklib.mock_keygen_generate_keypair([(user_pubkey, user_privkey)])
    
    # We expect a single key to be generated directly through the backed api
    # (specifically, the donor key).
    donor_pubkey = "1 2"
    mocklib.mock_backend_generate_key([donor_pubkey])
    
    provided_pubkey=None
    interface.register_user(good_username, good_password, good_email, 
                                           good_affiliation, provided_pubkey)

    user_from_db = maindb.get_user(good_username)

    assert(user_from_db.user_pubkey == user_pubkey)
    assert(user_from_db.user_privkey == user_privkey)
    assert(user_from_db.donor_pubkey == donor_pubkey)