Esempio n. 1
0
 def AD_get_children(connection, parent):
     connection.search(
         settings.LDAP_GROUPS_BASE_DN,
         "(&(objectCategory=group)(memberOf={group_name}))".
         format(group_name=escape_query(parent)))
     children = connection.entries
     results = []
     for child in children:
         results.append(child.entry_dn)
     return results
Esempio n. 2
0
    def test_string_with_no_escaped_characters(self):
        input_string = "Hello World! I have no problem characters in me!"

        self.assertEqual(input_string, escape_query(input_string), "Regular characters were unexpectedly escaped.")
Esempio n. 3
0
    def test_string_with_all_escaped_characters(self):
        input_string = "\\*()"
        expected_output = r"\5C\2A\28\29"

        self.assertEqual(expected_output, escape_query(input_string), "All symbols were not correctly escaped.")
Esempio n. 4
0
    def test_string_with_asterisk(self):
        input_string = "*"
        expected_output = r"\2A"

        self.assertEqual(expected_output, escape_query(input_string), "Asterisk was not correctly escaped.")
Esempio n. 5
0
    def test_string_with_backslash(self):
        input_string = "\\"
        expected_output = r"\5C"

        self.assertEqual(expected_output, escape_query(input_string), "Literal backslash was not correctly escaped.")
Esempio n. 6
0
    def test_string_with_right_parenthesis(self):
        input_string = ")"
        expected_output = r"\29"

        self.assertEqual(expected_output, escape_query(input_string), "Right parenthesis was not correctly escaped.")
Esempio n. 7
0
    def test_string_with_left_parenthesis(self):
        input_string = "("
        expected_output = r"\28"

        self.assertEqual(expected_output, escape_query(input_string), "Left parenthesis was not correctly escaped.")
Esempio n. 8
0
    def test_real_world_example(self):
        input_string = "CN=StateHRDept - IS-ITS-Engineering Services (133200 FacStf All)"
        expected_output = r"CN=StateHRDept - IS-ITS-Engineering Services \28133200 FacStf All\29"

        self.assertEqual(expected_output, escape_query(input_string), "Parentheses were not correctly escaped.")
Esempio n. 9
0
    def test_string_with_no_escaped_characters(self):
        input_string = "Hello World! I have no problem characters in me!"

        self.assertEqual(input_string, escape_query(input_string),
                         "Regular characters were unexpectedly escaped.")
Esempio n. 10
0
    def test_string_with_all_escaped_characters(self):
        input_string = "\\*()"
        expected_output = r"\5C\2A\28\29"

        self.assertEqual(expected_output, escape_query(input_string),
                         "All symbols were not correctly escaped.")
Esempio n. 11
0
    def test_string_with_asterisk(self):
        input_string = "*"
        expected_output = r"\2A"

        self.assertEqual(expected_output, escape_query(input_string),
                         "Asterisk was not correctly escaped.")
Esempio n. 12
0
    def test_string_with_backslash(self):
        input_string = "\\"
        expected_output = r"\5C"

        self.assertEqual(expected_output, escape_query(input_string),
                         "Literal backslash was not correctly escaped.")
Esempio n. 13
0
    def test_string_with_right_parenthesis(self):
        input_string = ")"
        expected_output = r"\29"

        self.assertEqual(expected_output, escape_query(input_string),
                         "Right parenthesis was not correctly escaped.")
Esempio n. 14
0
    def test_string_with_left_parenthesis(self):
        input_string = "("
        expected_output = r"\28"

        self.assertEqual(expected_output, escape_query(input_string),
                         "Left parenthesis was not correctly escaped.")
Esempio n. 15
0
    def test_real_world_example(self):
        input_string = "CN=StateHRDept - IS-ITS-Engineering Services (133200 FacStf All)"
        expected_output = r"CN=StateHRDept - IS-ITS-Engineering Services \28133200 FacStf All\29"

        self.assertEqual(expected_output, escape_query(input_string),
                         "Parentheses were not correctly escaped.")