Ejemplo n.º 1
0
def main():
  
  # Setup test environment
  testlib.setup_test_environment()
  testlib.setup_test_db()
  
  try:
    # mock out interface calls
    interface.register_user = mock_register_user
    interface.get_logged_in_user = mock_get_logged_in_user
    
    # run tests
    test_post_blank_form()
    test_short_username()
    test_long_username()
    test_invalid_username()
    test_short_password()
    test_nonmatching_password()
    test_matching_username_password()
    test_short_affil()
    test_long_affil()
    test_invalid_email()
    test_key_upload_with_no_file()
    test_key_upload_with_oversized_file()
    test_key_upload_with_bad_format_key()
    test_key_upload_with_valid_key()
    test_normal()
    
    print "All tests passed."
    
  finally:
    testlib.teardown_test_db()
    testlib.teardown_test_environment()
Ejemplo n.º 2
0
def setup_test():
  """
  <Purpose>
    Prepare everything in order to run the tests.

  <Arguments>
    None

  <Exceptions>
    None

  <Side Efects>
    None

  <Return>
    None
  """

  testlib.setup_test_db()

  # Create a user who has the donation key.
  maindb.create_user(mockutil.testusername, "password", "*****@*****.**", "affiliation", 
                    "10 11", "2 2 2", mockutil.donor_key_str)

  # Setup all the mock functions
  mockutil.mock_nodemanager_get_node_info(mockutil.nodeid_key, "10.0test", vessels_dict)
  mockutil.mock_lockserver_calls()
  mockutil.mock_backend_generate_key([mockutil.per_node_key_str])
  mockutil.mock_nodemanager_get_vesselresources()
  mockutil.mock_transitionlib_do_advertise_lookup([mockutil.node_address])
  mockutil.mock_backend_set_vessel_owner_key()
  mockutil.mock_backend_split_vessel()
  mockutil.mock_backend_set_vessel_user_keylist([mockutil._mock_pubkey_to_string(
                                                node_transition_lib.transition_state_keys['canonical'])])
Ejemplo n.º 3
0
def main():

    # Setup test environment
    testlib.setup_test_environment()
    testlib.setup_test_db()

    try:
        # mock out interface calls
        interface.register_user = mock_register_user
        interface.get_logged_in_user = mock_get_logged_in_user

        # run tests
        test_post_blank_form()
        test_short_username()
        test_long_username()
        test_invalid_username()
        test_short_password()
        test_nonmatching_password()
        test_matching_username_password()
        test_short_affil()
        test_long_affil()
        test_invalid_email()
        test_key_upload_with_no_file()
        test_key_upload_with_oversized_file()
        test_key_upload_with_bad_format_key()
        test_key_upload_with_valid_key()
        test_normal()

        print "All tests passed."

    finally:
        testlib.teardown_test_db()
        testlib.teardown_test_environment()
def setup_test():
    """
  <Purpose>
    Prepare everything in order to run the tests.

  <Arguments>
    None

  <Exceptions>
    None

  <Side Efects>
    None

  <Return>
    None
  """

    testlib.setup_test_db()

    # Make sure all the variables are its default values
    mockutil.mockutil_cleanup_variables()

    # Create a user who has the donation key.
    user_object = maindb.create_user(
        mockutil.testusername,
        "password",
        "*****@*****.**",
        "affiliation",
        "10 11",
        "2 2 2",
        mockutil.donor_key_str,
    )

    # Create a database entry for the node
    node_object = maindb.create_node(
        mockutil.nodeid_key_str,
        mockutil.node_ip,
        mockutil.node_port,
        "10.0test",
        False,
        mockutil.per_node_key_str,
        mockutil.extra_vessel_name,
    )

    # Create a donation for user
    maindb.create_donation(node_object, user_object, "Making a donation")

    # Setup all the mock functions
    mockutil.mock_nodemanager_get_node_info(mockutil.nodeid_key, "10.0test", vessels_dict)
    mockutil.mock_lockserver_calls()
    mockutil.mock_backend_generate_key([mockutil.per_node_key_str])
    mockutil.mock_nodemanager_get_vesselresources()
    mockutil.mock_transitionlib_do_advertise_lookup([mockutil.node_address])
    mockutil.mock_backend_set_vessel_owner_key()
    mockutil.mock_backend_split_vessel()
    mockutil.mock_backend_set_vessel_user_keylist(
        [mockutil._mock_pubkey_to_string(node_transition_lib.movingtoonepercentmanyeventspublickey)]
    )
def setup_test():
    """
  <Purpose>
    Prepare everything in order to run the tests.

  <Arguments>
    None

  <Exceptions>
    None

  <Side Efects>
    None

  <Return>
    None
  """

    testlib.setup_test_db()

    # Create a user who has the donation key.
    user_object = maindb.create_user(
        mockutil.testusername,
        "password",
        "*****@*****.**",
        "affiliation",
        "10 11",
        "2 2 2",
        mockutil.donor_key_str,
    )

    # Create a database entry for the node
    node_object = maindb.create_node(
        mockutil.nodeid_key_str,
        mockutil.node_ip,
        mockutil.node_port,
        "10.0test",
        True,
        mockutil.per_node_key_str,
        mockutil.extra_vessel_name,
    )

    # Create a donation for user
    maindb.create_donation(node_object, user_object, "Making a donation")
    # Setup all the mock functions
    mockutil.mock_nodemanager_get_node_info(mockutil.nodeid_key, "10.0test", vessels_dict)
    mockutil.mock_lockserver_calls()
    mockutil.mock_backend_generate_key([mockutil.per_node_key_str])
    mockutil.mock_nodemanager_get_vesselresources()
    mockutil.mock_transitionlib_do_advertise_lookup([mockutil.node_address])
    mockutil.mock_backend_set_vessel_owner_key()
    mockutil.mock_backend_split_vessel()
    # set_vessel_user_keylist_call_count won't be called because the
    # node_transition_lib will see that it's a state change to the same state.
    mockutil.mock_backend_set_vessel_user_keylist(None)
Ejemplo n.º 6
0
def main():
    # The tests don't use the database, so we just make a single database
    # so that it exists to prevent unrelated errors when we use the models.
    testlib.setup_test_environment()
    testlib.setup_test_db()

    try:
        unittest.main()

    finally:
        testlib.teardown_test_db()
        testlib.teardown_test_environment()
Ejemplo n.º 7
0
def main():
  # The tests don't use the database, so we just make a single database
  # so that it exists to prevent unrelated errors when we use the models.
  testlib.setup_test_environment()
  testlib.setup_test_db()
  
  try:
    unittest.main()
  
  finally:
    testlib.teardown_test_db()
    testlib.teardown_test_environment()
Ejemplo n.º 8
0
def setup_test():
    """
  <Purpose>
    Prepare everything in order to run the tests.

  <Arguments>
    None

  <Exceptions>
    None

  <Side Efects>
    None

  <Return>
    None
  """

    testlib.setup_test_db()

    # Make sure all the variables are its default values
    mockutil.mockutil_cleanup_variables()

    # Create a user who has the donation key.
    user_object = maindb.create_user(mockutil.testusername, "password",
                                     "*****@*****.**", "affiliation",
                                     "10 11", "2 2 2", mockutil.donor_key_str)

    # Create a database entry for the node
    node_object = maindb.create_node(mockutil.nodeid_key_str, mockutil.node_ip,
                                     mockutil.node_port, "10.0test", False,
                                     mockutil.per_node_key_str,
                                     mockutil.extra_vessel_name)

    # Create a donation for user
    maindb.create_donation(node_object, user_object, "Making a donation")

    # Setup all the mock functions
    mockutil.mock_nodemanager_get_node_info(mockutil.nodeid_key, "10.0test",
                                            vessels_dict)
    mockutil.mock_lockserver_calls()
    mockutil.mock_backend_generate_key([mockutil.per_node_key_str])
    mockutil.mock_nodemanager_get_vesselresources()
    mockutil.mock_transitionlib_do_advertise_lookup([mockutil.node_address])
    mockutil.mock_backend_set_vessel_owner_key()
    mockutil.mock_backend_split_vessel()
    mockutil.mock_backend_set_vessel_user_keylist([
        mockutil._mock_pubkey_to_string(
            node_transition_lib.
            transition_state_keys['movingto_onepercentmanyevents'])
    ])
Ejemplo n.º 9
0
def main():
  
  # Setup test environment
  testlib.setup_test_environment()
  testlib.setup_test_db()
  
  try:
    login_test_user()
    test_regenerate_api_key()
    print "All tests passed."
    
  finally:
    testlib.teardown_test_db()
    testlib.teardown_test_environment()
def main():

    # Setup test environment
    testlib.setup_test_environment()
    testlib.setup_test_db()

    try:
        login_test_user()
        test_regenerate_api_key()
        print "All tests passed."

    finally:
        testlib.teardown_test_db()
        testlib.teardown_test_environment()
Ejemplo n.º 11
0
def main():

    # Setup test environment
    testlib.setup_test_environment()
    testlib.setup_test_db()

    try:
        # Run tests
        get_pages_without_user_logged_in()
        get_pages_with_user_logged_in()

        print "All tests passed."

    finally:
        testlib.teardown_test_db()
        testlib.teardown_test_environment()
Ejemplo n.º 12
0
def main():
  
  # Setup test environment
  testlib.setup_test_environment()
  testlib.setup_test_db()
  
  try:
    # Run tests
    get_pages_without_user_logged_in()
    get_pages_with_user_logged_in()
    
    print "All tests passed."
    
  finally:
    testlib.teardown_test_db()
    testlib.teardown_test_environment()
Ejemplo n.º 13
0
def setup_test():
    """
  <Purpose>
    Prepare everything in order to run the tests.

  <Arguments>
    None

  <Exceptions>
    None

  <Side Efects>
    None

  <Return>
    None
  """

    testlib.setup_test_db()

    # Create a user who has the donation key.
    user_object = maindb.create_user(mockutil.testusername, "password",
                                     "*****@*****.**", "affiliation",
                                     "10 11", "2 2 2", mockutil.donor_key_str)

    # Create a database entry for the node
    node_object = maindb.create_node(mockutil.nodeid_key_str, mockutil.node_ip,
                                     mockutil.node_port, "10.0test", True,
                                     mockutil.per_node_key_str,
                                     mockutil.extra_vessel_name)

    # Create a donation for user
    maindb.create_donation(node_object, user_object, "Making a donation")
    # Setup all the mock functions
    mockutil.mock_nodemanager_get_node_info(mockutil.nodeid_key, "10.0test",
                                            vessels_dict)
    mockutil.mock_lockserver_calls()
    mockutil.mock_backend_generate_key([mockutil.per_node_key_str])
    mockutil.mock_nodemanager_get_vesselresources()
    mockutil.mock_transitionlib_do_advertise_lookup([mockutil.node_address])
    mockutil.mock_backend_set_vessel_owner_key()
    mockutil.mock_backend_split_vessel()
    # set_vessel_user_keylist_call_count won't be called because the
    # node_transition_lib will see that it's a state change to the same state.
    mockutil.mock_backend_set_vessel_user_keylist(None)
def main():
  
  # Setup test environment
  testlib.setup_test_environment()
  testlib.setup_test_db()
  
  try:
    login_test_user()
    
    test_normal()
    test_get_vessel_list_throws_DoesNotExistError()
    test_get_vessel_list_throws_InvalidRequestError()
    test_renew_vessels_throws_InvalidRequestError()
    
    print "All tests passed."
    
  finally:
    testlib.teardown_test_db()
    testlib.teardown_test_environment()
def main():

    # Setup test environment
    testlib.setup_test_environment()
    testlib.setup_test_db()

    try:
        login_test_user()

        test_normal()
        test_get_vessel_list_throws_DoesNotExistError()
        test_get_vessel_list_throws_InvalidRequestError()
        test_renew_vessels_throws_InvalidRequestError()

        print "All tests passed."

    finally:
        testlib.teardown_test_db()
        testlib.teardown_test_environment()
Ejemplo n.º 16
0
def main():
  
  # Setup test environment
  testlib.setup_test_environment()
  testlib.setup_test_db()
  
  try:
    login_test_user()
    
    test_regenerate_key()
    test_upload_key_no_file()
    test_upload_key_file()
    test_upload_key_file_empty_file()
    test_upload_key_file_invalid_key()
    
    print "All tests passed."
    
  finally:
    testlib.teardown_test_db()
    testlib.teardown_test_environment()
Ejemplo n.º 17
0
def main():

    # Setup test environment
    testlib.setup_test_environment()
    testlib.setup_test_db()

    try:
        login_test_user()

        test_regenerate_key()
        test_upload_key_no_file()
        test_upload_key_file()
        test_upload_key_file_empty_file()
        test_upload_key_file_invalid_key()

        print "All tests passed."

    finally:
        testlib.teardown_test_db()
        testlib.teardown_test_environment()
Ejemplo n.º 18
0
def main():

    # Setup test environment
    testlib.setup_test_environment()
    testlib.setup_test_db()

    try:
        login_test_user()

        test_normal()
        test_interface_throws_UnableToAcquireResourcesError()
        test_interface_throws_InsufficientUserResourcesError()
        test_blank_POST_data()
        test_invalid_POST_data_invalid_num()
        test_invalid_POST_data_invalid_env()

        print "All tests passed."

    finally:
        testlib.teardown_test_db()
        testlib.teardown_test_environment()
Ejemplo n.º 19
0
def main():

    # Setup test environment
    testlib.setup_test_environment()
    testlib.setup_test_db()

    try:
        login_test_user()

        test_normal()
        test_interface_throws_UnableToAcquireResourcesError()
        test_interface_throws_InsufficientUserResourcesError()
        test_blank_POST_data()
        test_invalid_POST_data_invalid_num()
        test_invalid_POST_data_invalid_env()

        print "All tests passed."

    finally:
        testlib.teardown_test_db()
        testlib.teardown_test_environment()
 def setUp(self):
   # Setup a fresh database for each test.
   testlib.setup_test_db()
def setup_general():
    """
  <Purpose>
    Prepare all the general stuff in order to run the tests.

  <Arguments>
    None

  <Exceptions>
    None

  <Side Efects>
    None

  <Return>
    None
  """

    testlib.setup_test_db()

    # Make sure all the variables are its default values
    mockutil.mockutil_cleanup_variables()

    # Create a user who has the donation key.
    user_object = maindb.create_user(mockutil.testusername, "password",
                                     "*****@*****.**", "affiliation",
                                     "10 11", "2 2 2", mockutil.donor_key_str)

    # Create a database entry for the node
    node_object = maindb.create_node(mockutil.nodeid_key_str, mockutil.node_ip,
                                     mockutil.node_port, "10.0test", True,
                                     mockutil.per_node_key_str,
                                     mockutil.extra_vessel_name)

    # Create a donation for user
    maindb.create_donation(node_object, user_object, "Making a donation")

    testuser = maindb.get_user(mockutil.testusername)

    # Retrieve the info about the donation we just made.
    all_donations = maindb.get_donations_by_user(
        testuser, include_inactive_and_broken=True)
    node = all_donations[0].node

    global vessels_dict
    vessels_dict = vessels_dict_basic.copy()
    # Create 9 different vessels, assuming that the original vessel got split into 9.
    for i in range(9):
        vessels_dict["vessel" + str(i)] = {}
        vessels_dict["vessel" + str(i)]["userkeys"] = []
        vessels_dict["vessel" + str(i)]["ownerkey"] = rsa_string_to_publickey(
            node.owner_pubkey)
        vessels_dict["vessel" + str(i)]["ownerinfo"] = ""
        vessels_dict["vessel" + str(i)]["status"] = ""
        vessels_dict["vessel" + str(i)]["advertise"] = True

        maindb.create_vessel(node, "vessel" + str(i))

    # Setup all the mock functions
    mockutil.mock_nodemanager_get_node_info(mockutil.nodeid_key, "10.0test",
                                            vessels_dict)
    mockutil.mock_lockserver_calls()
    mockutil.mock_backend_generate_key([mockutil.per_node_key_str])
    mockutil.mock_nodemanager_get_vesselresources()
    mockutil.mock_transitionlib_do_advertise_lookup([mockutil.node_address])
    mockutil.mock_backend_set_vessel_owner_key()
def setup_general():
  """
  <Purpose>
    Prepare all the general stuff in order to run the tests.

  <Arguments>
    None

  <Exceptions>
    None

  <Side Efects>
    None

  <Return>
    None
  """

  testlib.setup_test_db()

  # Make sure all the variables are its default values
  mockutil.mockutil_cleanup_variables()

  # Create a user who has the donation key.
  user_object = maindb.create_user(mockutil.testusername, "password", "*****@*****.**", "affiliation",
                    "10 11", "2 2 2", mockutil.donor_key_str)

  # Create a database entry for the node
  node_object = maindb.create_node(mockutil.nodeid_key_str, mockutil.node_ip, mockutil.node_port, "10.0test",
                                  True, mockutil.per_node_key_str, mockutil.extra_vessel_name)


  # Create a donation for user
  maindb.create_donation(node_object, user_object, "Making a donation")

  testuser = maindb.get_user(mockutil.testusername)

  # Retrieve the info about the donation we just made.
  all_donations = maindb.get_donations_by_user(testuser, include_inactive_and_broken=True)
  node = all_donations[0].node

  global vessels_dict
  vessels_dict = vessels_dict_basic.copy()
  # Create 9 different vessels, assuming that the original vessel got split into 9.
  for i in range(9):
    vessels_dict["vessel"+str(i)]={}
    vessels_dict["vessel"+str(i)]["userkeys"] = []
    vessels_dict["vessel"+str(i)]["ownerkey"] = rsa_string_to_publickey(node.owner_pubkey)
    vessels_dict["vessel"+str(i)]["ownerinfo"] = ""
    vessels_dict["vessel"+str(i)]["status"] = ""
    vessels_dict["vessel"+str(i)]["advertise"] = True

    maindb.create_vessel(node, "vessel"+str(i))


  # Setup all the mock functions
  mockutil.mock_nodemanager_get_node_info(mockutil.nodeid_key, "10.0test", vessels_dict)
  mockutil.mock_lockserver_calls()
  mockutil.mock_backend_generate_key([mockutil.per_node_key_str])
  mockutil.mock_nodemanager_get_vesselresources()
  mockutil.mock_transitionlib_do_advertise_lookup([mockutil.node_address])
  mockutil.mock_backend_set_vessel_owner_key()