<commit_before>try:
    import unittest2 as unittest
except ImportError:
    import unittest

import requests


class SimpleTest(unittest.TestCase):

    def test_flask_ok(self):
        r = requests.get('http://localhost:5000')
        self.assertEqual(r.status_code, 200,
                         'HTTP target service is not running')

    def test_proxy_ok(self):
        r = requests.get('http://localhost/')
        self.assertEqual(r.status_code, 200,
                         'Proxy service is not running properly')

    def test_dummy_uri(self):
        r = requests.get('http://localhost/abc')
        self.assertEqual(r.status_code, 404,
                         'Filtering service not working')

    def test_whitelisted_uri(self):
        r = requests.get('http://localhost/int/123')
        self.assertEqual(r.status_code, 200)

    # parameters testing (all parameters must match)
    # Rule definition
    #{
    #    "match": {
    #        "url": "^/parameters$",
    #        "parameters": [
    #            ["var1", "^val1$"],
    #            ["var2", "^val2$"]
    #            ]
    #    },
    #    "action_if_match": {
    #        "whitelist": "True"
    #    }
    #}
    def test_parameters_03(self):
        r = requests.get('http://localhost/parameters?var1=val1&var2=val2')
        self.assertEqual(r.status_code, 200)

    def test_parameters_04(self):
        r = requests.get('http://localhost/parameters?var2=val2&var1=val1')
        self.assertEqual(r.status_code, 200)

    def test_parameters_05(self):
        r = requests.get('http://localhost/parameters?var2=val2&var1=val1')
        self.assertEqual(r.status_code, 200)

    def test_parameters_06(self):
        r = requests.get('http://localhost/parameters?var2=val2')
        self.assertEqual(r.status_code, 404)

    def test_parameters_07(self):
        r = requests.get('http://localhost/parameters?var1=ValueNotExpected&var2=val2')
        self.assertEqual(r.status_code, 404)

    def test_parameters_08(self):
        r = requests.get('http://localhost/parameters?var1=val1&var2=val2&UnexpectedParameter=whatever')
        self.assertEqual(r.status_code, 404)

    def test_content_url_encoded_09(self):
        content = {"var1": "val1", "var2": "val2"}
        r = requests.post('http://localhost/post/', data=content)
        self.assertEqual(r.status_code, 200)

    def test_content_url_encoded_10(self):
        content = {"var2": "val2", "var1": "val1"}
        r = requests.post('http://localhost/post/', data=content)
        self.assertEqual(r.status_code, 200)

    def test_content_url_encoded_11(self):
        content = {"var1": "val1"}
        r = requests.post('http://localhost/post/', data=content)
        self.assertEqual(r.status_code, 404)

    def test_content_url_encoded_12(self):
        content = {"var1": "UnexpectedValue", "var2": "val2"}
        r = requests.post('http://localhost/post/', data=content)
        self.assertEqual(r.status_code, 404)

    def test_content_url_encoded_13(self):
        content = {"var1": "val1", "var2": "val2", "UnexpectedParamter": "whatever"}
        r = requests.post('http://localhost/post/', data=content)
        self.assertEqual(r.status_code, 404)
<commit_msg>first test for content max read<commit_after>try:
    import unittest2 as unittest
except ImportError:
    import unittest

import requests


class SimpleTest(unittest.TestCase):

    def test_flask_ok(self):
        r = requests.get('http://localhost:5000')
        self.assertEqual(r.status_code, 200,
                         'HTTP target service is not running')

    def test_proxy_ok(self):
        r = requests.get('http://localhost/')
        self.assertEqual(r.status_code, 200,
                         'Proxy service is not running properly')

    def test_dummy_uri(self):
        r = requests.get('http://localhost/abc')
        self.assertEqual(r.status_code, 404,
                         'Filtering service not working')

    def test_whitelisted_uri(self):
        r = requests.get('http://localhost/int/123')
        self.assertEqual(r.status_code, 200)

    # parameters testing (all parameters must match)
    # Rule definition
    #{
    #    "match": {
    #        "url": "^/parameters$",
    #        "parameters": [
    #            ["var1", "^val1$"],
    #            ["var2", "^val2$"]
    #            ]
    #    },
    #    "action_if_match": {
    #        "whitelist": "True"
    #    }
    #}
    def test_parameters_03(self):
        r = requests.get('http://localhost/parameters?var1=val1&var2=val2')
        self.assertEqual(r.status_code, 200)

    def test_parameters_04(self):
        r = requests.get('http://localhost/parameters?var2=val2&var1=val1')
        self.assertEqual(r.status_code, 200)

    def test_parameters_05(self):
        r = requests.get('http://localhost/parameters?var2=val2&var1=val1')
        self.assertEqual(r.status_code, 200)

    def test_parameters_06(self):
        r = requests.get('http://localhost/parameters?var2=val2')
        self.assertEqual(r.status_code, 404)

    def test_parameters_07(self):
        r = requests.get('http://localhost/parameters?var1=ValueNotExpected&var2=val2')
        self.assertEqual(r.status_code, 404)

    def test_parameters_08(self):
        r = requests.get('http://localhost/parameters?var1=val1&var2=val2&UnexpectedParameter=whatever')
        self.assertEqual(r.status_code, 404)

    def test_content_url_encoded_09(self):
        content = {"var1": "val1", "var2": "val2"}
        r = requests.post('http://localhost/post/', data=content)
        self.assertEqual(r.status_code, 200)

    def test_content_url_encoded_10(self):
        content = {"var2": "val2", "var1": "val1"}
        r = requests.post('http://localhost/post/', data=content)
        self.assertEqual(r.status_code, 200)

    def test_content_url_encoded_11(self):
        content = {"var1": "val1"}
        r = requests.post('http://localhost/post/', data=content)
        self.assertEqual(r.status_code, 404)

    def test_content_url_encoded_12(self):
        content = {"var1": "UnexpectedValue", "var2": "val2"}
        r = requests.post('http://localhost/post/', data=content)
        self.assertEqual(r.status_code, 404)

    def test_content_url_encoded_13(self):
        content = {"var1": "val1", "var2": "val2", "UnexpectedParamter": "whatever"}
        r = requests.post('http://localhost/post/', data=content)
        self.assertEqual(r.status_code, 404)

    def test_content_url_encoded_1r43(self):
        v = 'val1' * 10000
        content = {"var1": v}
        r = requests.post('http://localhost/post/', data=content)
        self.assertEqual(r.status_code, 404)

{'fraction_non_alphanumeric': 0.1434756643774261, 'fraction_numerical': 0.036876679605852496, 'mean_word_length': 2.715474209650582, 'pattern_counts': {'":': 31, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1033731', 'n_tokens_mistral': 2248, 'n_tokens_neox': 2069, 'n_words': 354}