def test_is_valid_key(self):
        response = api_user.is_valid_key("NOTVALID")
        assert_equals(response, False)

        response = api_user.is_valid_key("samplekey")
        assert_equals(response, True)

        response = api_user.is_valid_key(self.existing_api_user.api_key)
        assert_equals(response, True)
Example #2
0
    def test_is_valid_key(self):
        response = api_user.is_valid_key("NOTVALID")
        assert_equals(response, False)

        response = api_user.is_valid_key("samplekey")
        assert_equals(response, True)

        response = api_user.is_valid_key(self.existing_api_user.api_key)
        assert_equals(response, True)
Example #3
0
def check_key():
    if "/v1/" in request.url:
        api_key = request.values.get('key', '')
        if not api_key:
            api_key = request.args.get("api_admin_key", "")
        if not api_user.is_valid_key(api_key):
            abort_custom(403, "You must include key=YOURKEY in your query.  Contact [email protected] for a valid api key.")
    return # if success don't return any content
Example #4
0
def check_key():
    if "/v1/" in request.url:
        api_key = request.values.get('key', '')
        if not api_key:
            api_key = request.args.get("api_admin_key", "")
        if not api_user.is_valid_key(api_key):
            abort_custom(
                403,
                "You must include key=YOURKEY in your query.  Contact [email protected] for a valid api key."
            )
    return  # if success don't return any content