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
Beispiel #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.")
Beispiel #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.")
Beispiel #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.")
Beispiel #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.")
Beispiel #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.")
Beispiel #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.")
Beispiel #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.")
Beispiel #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.")
Beispiel #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.")
Beispiel #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.")
Beispiel #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.")
Beispiel #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.")
Beispiel #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.")
Beispiel #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.")