Beispiel #1
0
def test_accounts_get_all():
    # superuser & read perms
    dummy_accounts_fn.__module__ = "accounts"
    dummy_accounts_fn.__name__ = "get"
    for perms in perms_list:
        config.add_token("TESTING_token", username, perms)
        if perms.get("read") and perms.get("superuser"):
            has_access = 200
        else:
            has_access = 401
        output, ret_code = accounts_decorator(dummy_accounts_fn)()
        assert has_access == ret_code
Beispiel #2
0
def test_senate_version_get():
    # superuser and read perms
    dummy_accounts_fn.__module__ = "senate_version"
    dummy_accounts_fn.__name__ = "get"
    for perms in perms_list:
        config.add_token("TESTING_token", username, perms)
        if perms.get("read") and perms.get("superuser"):
            has_access = 200
        else:
            has_access = 401
        output, ret_code = accounts_decorator(dummy_accounts_fn)(
            acad_session=2019)
        assert has_access == ret_code
Beispiel #3
0
def test_accounts_delete():
    # superuser and write perms
    dummy_accounts_fn.__module__ = "accounts"
    dummy_accounts_fn.__name__ = "delete"
    for perms in perms_list:
        config.add_token("TESTING_token", username, perms)
        if perms.get("write") and perms.get("superuser"):
            has_access = 200
        else:
            has_access = 401
        output, ret_code = accounts_decorator(dummy_accounts_fn)(
            username=username)
        assert has_access == ret_code
Beispiel #4
0
def test_accounts_get_managed():
    # usernames and read perms
    dummy_accounts_fn.__module__ = "accounts"
    dummy_accounts_fn.__name__ = "get"
    for perms in perms_list:
        config.add_token("TESTING_token", username, perms)
        if perms.get("read") and (perms.get("superuser")
                                  or "lordfme" in perms.get("usernames", [])):
            has_access = 200
        else:
            has_access = 401
        output, ret_code = accounts_decorator(dummy_accounts_fn)(
            username="******")
        assert has_access == ret_code
Beispiel #5
0
def test_accounts_manage_other():
    # usernames and write perms
    dummy_accounts_fn.__module__ = "accounts"
    dummy_accounts_fn.__name__ = "patch"
    for perms in perms_list:
        config.add_token("TESTING_token", username, perms)
        if perms.get("write") and (perms.get("superuser")
                                   or "lordfme" in perms.get("usernames", [])):
            has_access = 200
        else:
            has_access = 401
        output, ret_code = accounts_decorator(dummy_accounts_fn)(
            data={
                "username": "******"
            })
        assert has_access == ret_code