Esempio n. 1
0
    def test_create_user_request_team_size_validation(self):
        """
        Tests the team size restriction

        Covers:
            team.create_team
            user.create_user_request
        """

        api.team.create_team(base_team.copy())

        uid = None
        for i in range(api.team.max_team_users):
            test_user = base_user.copy()
            test_user['username'] += str(i)
            uid = api.user.create_user_request(test_user)

        with pytest.raises(WebException):
            api.user.create_user_request(base_user.copy())
            assert False, "Team has too many users"

        api.user.disable_account(uid)

        #Should be able to add another user after disabling one.
        test_user = base_user.copy()
        test_user['username'] += "addition"
        api.user.create_user_request(test_user)
Esempio n. 2
0
    def test_create_user_request_team_size_validation(self):
        """
        Tests the team size restriction

        Covers:
            team.create_team
            user.create_user_request
        """

        team = base_team.copy()
        tid = api.team.create_team(team)

        uid = None
        for i in range(api.config.get_settings()["max_team_size"]):
            test_user = base_user.copy()
            test_user['username'] += str(i)
            uid = api.user.create_simple_user_request(test_user)
            # join a real team
            api.team.join_team(team["team_name"], team["password"], uid)

        with pytest.raises(InternalException):
            uid_fail = api.user.create_simple_user_request(base_user.copy())
            # join a real team
            api.team.join_team(team["team_name"], team["password"], uid_fail)
            assert False, "Team has too many users"

        api.user.disable_account(uid)

        #Should be able to add another user after disabling one.
        test_user = base_user.copy()
        test_user['username'] += "addition"
        uid = api.user.create_simple_user_request(test_user)
        api.team.join_team(team["team_name"], team["password"], uid)
Esempio n. 3
0
    def test_create_simple_user_request_email_validation(self):
        """
        Tests the email validation during user registration.

        Covers:
            partially: user.create_simple_user_request
        """

        team = base_team.copy()
        api.team.create_team(team)

        invalid_email_user = base_user.copy()
        invalid_email_user["email"] = "not_an_email"

        with pytest.raises(Exception):
            api.user.create_simple_user_request(invalid_email_user)
            assert False, "Was able to register a user with something that doesn't look like an email."

        invalid_email_user["email"] = "[email protected]"

        with pytest.raises(WebException):
            api.user.create_simple_user_request(invalid_email_user)
            assert False, "Was able to register a user with invalid characters"

        valid_email_user = base_user.copy()
        assert api.user.create_simple_user_request(
            valid_email_user), "Was not able to register a valid email."
Esempio n. 4
0
    def te_st_create_user_request_team_size_validation(self):
        """
        Tests the team size restriction

        Covers:
            team.create_team
            user.create_user_request
        """

        api.team.create_team(base_team.copy())

        uid = None
        for i in range(api.config.get_settings()["max_team_size"]):
            test_user = base_user.copy()
            test_user['username'] += str(i)
            uid = api.user.create_user_request(test_user)

        with pytest.raises(WebException):
            api.user.create_user_request(base_user.copy())
            assert False, "Team has too many users"

        api.user.disable_account(uid)

        #Should be able to add another user after disabling one.
        test_user = base_user.copy()
        test_user['username'] += "addition"
        api.user.create_user_request(test_user)
Esempio n. 5
0
    def test_create_user_request_team_size_validation(self):
        """
        Tests the team size restriction

        Covers:
            team.create_team
            user.create_user_request
        """

        team = base_team.copy()
        tid = api.team.create_team(team)

        uid = None
        for i in range(api.config.get_settings()["max_team_size"]):
            test_user = base_user.copy()
            test_user['username'] += str(i)
            uid = api.user.create_simple_user_request(test_user)
            # join a real team
            api.team.join_team(team["team_name"], team["password"], uid)

        with pytest.raises(InternalException):
            uid_fail = api.user.create_simple_user_request(base_user.copy())
            # join a real team
            api.team.join_team(team["team_name"], team["password"], uid_fail)
            assert False, "Team has too many users"

        api.user.disable_account(uid)

        # Should be able to add another user after disabling one.
        test_user = base_user.copy()
        test_user['username'] += "addition"
        uid = api.user.create_simple_user_request(test_user)
        api.team.join_team(team["team_name"], team["password"], uid)
Esempio n. 6
0
    def test_create_user_request_email_validation(self):
        """
        Tests the email validation during user registration.

        Covers:
            partially: user.create_user_request
        """

        team = base_team.copy()
        api.team.create_team(team)

        invalid_email_user = base_user.copy()
        invalid_email_user["email"] = "not_an_email"

        with pytest.raises(Exception):
            api.user.create_user_request(invalid_email_user)
            assert False, "Was able to register a user with something that doesn't look like an email."

        invalid_email_user["email"] = "[email protected]"

        with pytest.raises(WebException):
            api.user.create_user_request(invalid_email_user)
            assert False, "Was able to register a user with invalid characters"

        valid_email_user = base_user.copy()
        assert api.user.create_user_request(
            valid_email_user), "Was not able to register a valid email."
Esempio n. 7
0
    def test_create_simple_user_request_existing_team(self):
        """
        Tests the registration of users on existing teams.

        Covers:
            partially: user.create_simple_user_request
            team.get_team_uids
            team.create_team
        """

        team = base_team.copy()
        tid = api.team.create_team(team)
        assert tid, "Team was not created."

        # create a new user and join and existing team
        uid = api.user.create_simple_user_request(base_user.copy())
        assert uid == api.user.get_user(
            name=base_user["username"]
        )["uid"], "Good user created unsuccessfully."

        assert api.team.join_team(
            team["team_name"], team["password"],
            uid), "User unable to joining an existing team"

        with pytest.raises(InternalException):
            api.team.join_team(team["team_name"], team["password"], uid)
            assert False, "Was able to register and join the team twice."

        # attempt to join a non existent team
        with pytest.raises(InternalException):
            invalid_team_user = base_user.copy()
            invalid_team_user["username"] = "******"
            invalid_uid = api.user.create_simple_user_request(
                invalid_team_user)
            api.team.join_team("Totally Invalid", team["password"], uid)
            assert False, "Was able to join a team that doesn't exist."

        # attempt to join an existing team with an invalid password
        with pytest.raises(WebException):
            invalid_team_user = base_user.copy()
            invalid_team_user["username"] = "******"
            invalid_uid = api.user.create_simple_user_request(
                invalid_team_user)
            api.team.join_team(team["team_name"], "bad-password", uid)
            assert False, "Was able to join a team with an invalid password."

        team_uids = api.team.get_team_uids(tid)

        assert len(
            team_uids
        ) == 1, "Invalid teams were created though the tests passed."
        assert uid in team_uids, "User was not successfully placed into the existing team."
Esempio n. 8
0
    def test_create_simple_user_request_existing_team(self):
        """
        Tests the registration of users on existing teams.

        Covers:
            partially: user.create_simple_user_request
            team.get_team_uids
            team.create_team
        """

        team = base_team.copy()
        tid = api.team.create_team(team)
        assert tid, "Team was not created."

        # create a new user and join and existing team
        uid = api.user.create_simple_user_request(base_user.copy())
        assert uid == api.user.get_user(name=base_user["username"])[
            "uid"], "Good user created unsuccessfully."

        assert api.team.join_team(
            team["team_name"], team["password"],
            uid), "User unable to joining an existing team"

        with pytest.raises(InternalException):
            api.team.join_team(team["team_name"], team["password"], uid)
            assert False, "Was able to register and join the team twice."

        # attempt to join a non existent team
        with pytest.raises(InternalException):
            invalid_team_user = base_user.copy()
            invalid_team_user["username"] = "******"
            invalid_uid = api.user.create_simple_user_request(invalid_team_user)
            api.team.join_team("Totally Invalid", team["password"], uid)
            assert False, "Was able to join a team that doesn't exist."

        # attempt to join an existing team with an invalid password
        with pytest.raises(WebException):
            invalid_team_user = base_user.copy()
            invalid_team_user["username"] = "******"
            invalid_uid = api.user.create_simple_user_request(invalid_team_user)
            api.team.join_team(team["team_name"], "bad-password", uid)
            assert False, "Was able to join a team with an invalid password."

        team_uids = api.team.get_team_uids(tid)

        assert len(team_uids
                  ) == 1, "Invalid teams were created though the tests passed."
        assert uid in team_uids, "User was not successfully placed into the existing team."
Esempio n. 9
0
    def test_get_team_uids(self):
        """
        Tests the code that retrieves the list of uids on a team

        Covers:
            team.create_team
            user.create_simple_user_request
            team.get_team_uids
        """

        team = base_team.copy()
        tid = api.team.create_team(team)

        uids = []
        for i in range(api.config.get_settings()["max_team_size"]):
            test_user = base_user.copy()
            test_user['username'] += str(i)
            uid = api.user.create_simple_user_request(test_user)
            uids.append(uid)

            # join a real team
            api.team.join_team(team["team_name"], team["password"], uid)

        team_uids = api.team.get_team_uids(tid)
        assert len(team_uids) == api.config.get_settings(
        )["max_team_size"], "Team does not have correct number of members"
        assert sorted(uids) == sorted(
            team_uids), "Team does not have the correct members"
Esempio n. 10
0
    def test_get_team_uids(self):
        """
        Tests the code that retrieves the list of uids on a team

        Covers:
            team.create_team
            user.create_simple_user_request
            team.get_team_uids
        """

        team = base_team.copy()
        tid = api.team.create_team(team)

        uids = []
        for i in range(api.config.get_settings()["max_team_size"]):
            test_user = base_user.copy()
            test_user['username'] += str(i)
            uid = api.user.create_simple_user_request(test_user)
            uids.append(uid)

            # join a real team
            api.team.join_team(team["team_name"], team["password"], uid)

        team_uids = api.team.get_team_uids(tid)
        assert len(team_uids) == api.config.get_settings()[
            "max_team_size"], "Team does not have correct number of members"
        assert sorted(uids) == sorted(
            team_uids), "Team does not have the correct members"
Esempio n. 11
0
    def test_create_user_request_existing_team(self):
        """
        Tests the registration of users on existing teams.

        Covers:
            partially: user.create_user_request
            team.get_team_uids
            team.create_team
        """

        tid = api.team.create_team(base_team.copy())
        assert tid, "Team was not created."

        uid = api.user.create_user_request(base_user.copy())
        assert uid == api.user.get_user(
            name=base_user["username"]
        )["uid"], "Good user created unsuccessfully."

        with pytest.raises(WebException):
            api.user.create_user_request(base_user.copy())
            assert False, "Was able to register and join the team twice."

        with pytest.raises(WebException):
            invalid_team_user = base_user.copy()
            invalid_team_user["team-name-existing"] = "Totally Invalid"
            api.user.create_user_request(invalid_team_user)
            assert False, "Was able to join a team that doesn't exist."

        with pytest.raises(WebException):
            invalid_team_user = base_user.copy()
            invalid_team_user["team-password-existing"] = "Not correct"
            api.user.create_user_request(invalid_team_user)
            assert False, "Was able to join a team with an invalid password."

        team_uids = api.team.get_team_uids(tid)

        assert uid in team_uids, "User was not successfully placed into the existing team."
        assert len(
            team_uids
        ) == 1, "Invalid teams were created though the tests passed."
Esempio n. 12
0
    def test_simple_user_creation(self):
        """
        Tests the newer and simplified user creation.
        """

        user = dict_filter(base_user.copy(), ["username", "firstname", "lastname", "email"])
        user["password"] = "******"
        uid = api.user.create_simple_user_request(user)

        team = api.user.get_team(uid=uid)

        assert team["team_name"] == user["username"], "Team name does not match username."
        assert team["size"] == 1, "Individual team size is incorrect."
Esempio n. 13
0
    def test_create_user_request_existing_team(self):
        """
        Tests the registration of users on existing teams.

        Covers:
            partially: user.create_user_request
            team.get_team_uids
            team.create_team
        """

        tid = api.team.create_team(base_team.copy())
        assert tid, "Team was not created."

        uid = api.user.create_user_request(base_user.copy())
        assert uid == api.user.get_user(name=base_user["username"])["uid"], "Good user created unsuccessfully."

        with pytest.raises(WebException):
            api.user.create_user_request(base_user.copy())
            assert False, "Was able to register and join the team twice."

        with pytest.raises(WebException):
            invalid_team_user = base_user.copy()
            invalid_team_user["username"] = "******"
            invalid_team_user["team-name-existing"] = "Totally Invalid"
            api.user.create_user_request(invalid_team_user)
            assert False, "Was able to join a team that doesn't exist."

        with pytest.raises(WebException):
            invalid_team_user = base_user.copy()
            invalid_team_user["username"] = "******"
            invalid_team_user["team-password-existing"] = "Not correct"
            api.user.create_user_request(invalid_team_user)
            assert False, "Was able to join a team with an invalid password."

        team_uids = api.team.get_team_uids(tid)

        assert len(team_uids) == 1, "Invalid teams were created though the tests passed."
        assert uid in team_uids, "User was not successfully placed into the existing team."
Esempio n. 14
0
    def test_simple_user_creation(self):
        """
        Tests the newer and simplified user creation.
        """

        user = dict_filter(base_user.copy(),
                ["username", "firstname", "lastname", "email","eligibility","affiliation"])
        user["password"] = "******"
        uid = api.user.create_simple_user_request(user)

        team = api.user.get_team(uid=uid)

        assert team["team_name"] == user["username"], "Team name does not match username."
        assert team["size"] == 1, "Individual team size is incorrect."
Esempio n. 15
0
    def test_user_team_registration(self):
        """
        Tests the newer and simplified user creation.
        """
        user = dict_filter(base_user.copy(), ["username", "firstname", "lastname", "email","eligibility","affiliation"])
        user["password"] = "******"
        uid = api.user.create_simple_user_request(user)

        team_data = {"team_name": "lolhax", "team_password": "******"}
        api.team.create_new_team_request(team_data, uid=uid)

        team = api.user.get_team(uid=uid)

        assert team["team_name"] == team_data["team_name"], "User does not belong to the new team."
        assert api.team.get_team(name=user["username"])["size"] == 0 and api.team.get_team(name=team_data["team_name"])["size"] == 1, \
            "Size calculations are incorrect for new registered team."
Esempio n. 16
0
    def test_get_team(self):
        """
        Tests retrieving the team from a given uid.

        Covers:
            team.create_team
            user.create_user_request
            user.get_team
        """

        team = base_team.copy()
        tid = api.team.create_team(team)
        uid = api.user.create_user_request(base_user.copy())

        result_team = api.user.get_team(uid=uid)
        assert tid == result_team['tid'], "Unable to pair uid and tid."
Esempio n. 17
0
    def test_get_team(self):
        """
        Tests retrieving the team from a given uid.

        Covers:
            team.create_team
            user.create_user_request
            user.get_team
        """

        team = base_team.copy()
        tid = api.team.create_team(team)
        uid = api.user.create_user_request(base_user.copy())

        result_team = api.user.get_team(uid=uid)
        assert tid == result_team['tid'], "Unable to pair uid and tid."
Esempio n. 18
0
    def test_get_team(self):
        """
        Tests retrieving the team from a given uid.

        Covers:
            team.create_team
            user.create_user
            user.get_team
        """

        team = base_team.copy()
        tid = api.team.create_team(team)

        # user is now on an auto created individual team
        uid = api.user.create_simple_user_request(base_user.copy())
        # join a real team
        api.team.join_team(team["team_name"], team["password"], uid)
        result_team = api.user.get_team(uid=uid)
        assert tid == result_team['tid'], "Unable to pair uid and tid."
Esempio n. 19
0
    def test_get_team(self):
        """
        Tests retrieving the team from a given uid.

        Covers:
            team.create_team
            user.create_user
            user.get_team
        """

        team = base_team.copy()
        tid = api.team.create_team(team)

        # user is now on an auto created individual team
        uid = api.user.create_simple_user_request(base_user.copy())
        # join a real team
        api.team.join_team(team["team_name"], team["password"], uid)
        result_team = api.user.get_team(uid=uid)
        assert tid == result_team['tid'], "Unable to pair uid and tid."
Esempio n. 20
0
    def test_get_team_uids(self):
        """
        Tests the code that retrieves the list of uids on a team

        Covers:
            team.create_team
            user.create_user_request
            team.get_team_uids
        """

        tid = api.team.create_team(base_team.copy())

        uids = []
        for i in range(api.team.max_team_users):
            test_user = base_user.copy()
            test_user['username'] += str(i)
            uids.append(api.user.create_user_request(test_user))

        team_uids = api.team.get_team_uids(tid)
        assert len(team_uids) == api.team.max_team_users, "Team does not have correct number of members"
        assert sorted(uids) == sorted(team_uids), "Team does not have the correct members"
Esempio n. 21
0
    def test_get_team_uids(self):
        """
        Tests the code that retrieves the list of uids on a team

        Covers:
            team.create_team
            user.create_user_request
            team.get_team_uids
        """

        tid = api.team.create_team(base_team.copy())

        uids = []
        for i in range(api.team.max_team_users):
            test_user = base_user.copy()
            test_user['username'] += str(i)
            uids.append(api.user.create_user_request(test_user))

        team_uids = api.team.get_team_uids(tid)
        assert len(
            team_uids
        ) == api.team.max_team_users, "Team does not have correct number of members"
        assert sorted(uids) == sorted(
            team_uids), "Team does not have the correct members"