<commit_before><commit_msg>Added tests for is_valid_origin<commit_after># -*- coding: utf-8 -*-

import unittest
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from flask_cors import CORSMiddleware

class CORSMiddlewareTest(unittest.TestCase):
	def test_is_valid_origin(self):
		cors = CORSMiddleware(None)
		self.assertTrue(cors.is_valid_origin('http://www.w3.org'))

	def test_is_valid_origin_crlf(self):
		cors = CORSMiddleware(None)
		self.assertFalse(cors.is_valid_origin('http://www.w3.org\r\n'))

	def test_is_valid_origin_encoded_crlf1(self):
		cors = CORSMiddleware(None)
		self.assertFalse(cors.is_valid_origin('http://www.w3.org%0d%0a'))

	def test_is_valid_origin_encoded_crlf2(self):
		cors = CORSMiddleware(None)
		self.assertFalse(cors.is_valid_origin('http://www.w3.org%0D%0A'))

	def test_is_valid_origin_encoded_crlf3(self):
		cors = CORSMiddleware(None)
		self.assertFalse(cors.is_valid_origin('http://www.w3.org%0%0d%0ad%0%0d%0aa'))

if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.14615384615384616, 'fraction_numerical': 0.019230769230769232, 'mean_word_length': 6.382978723404255, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 5, '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': '3985648', 'n_tokens_mistral': 434, 'n_tokens_neox': 415, 'n_words': 49}