Optimized replace logic for oc
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import unittest
|
||||
from unittest.mock import patch, MagicMock
|
||||
import main as manage_schema
|
||||
import sys
|
||||
|
||||
class TestManageSchema(unittest.TestCase):
|
||||
|
||||
@@ -53,6 +54,21 @@ class TestManageSchema(unittest.TestCase):
|
||||
dn, [(0, 'olcObjectClasses', [encoded])]
|
||||
)
|
||||
|
||||
# Test no double add
|
||||
mock_conn.modify_s.reset_mock()
|
||||
mock_conn.search_s.return_value = [("cn={0}nextcloud,cn=schema,cn=config", {'olcObjectClasses': [encoded]})]
|
||||
with patch.object(sys, 'argv', [
|
||||
'manage_schema.py',
|
||||
'-s', 'ldap://localhost',
|
||||
'-D', 'cn=admin,dc=example,dc=org',
|
||||
'-W', 'secret',
|
||||
'-n', 'nextcloud',
|
||||
'-c', ocdef
|
||||
]):
|
||||
manage_schema.main()
|
||||
mock_conn.modify_s.assert_not_called()
|
||||
|
||||
|
||||
def test_extract_oid_from_definition(self):
|
||||
ldif = "( 1.3.6.1.4.1.99999.1 NAME 'example' DESC 'something' )"
|
||||
oid = manage_schema.extract_oid(ldif)
|
||||
|
||||
Reference in New Issue
Block a user