示例#1
0
    def test_first_uid(self):
        connection = mock.Mock(response=[
            {
                'attributes': {
                    'uidNumber': 999000
                }
            },
            {
                'attributes': {
                    'uidNumber': 999200
                }
            },
            {
                'attributes': {
                    'uidNumber': 999100
                }
            },
        ])

        @contextmanager
        def ldap_ocf():
            yield connection

        with mock.patch('ocflib.account.creation.ldap_ocf', ldap_ocf):
            next_uid = _get_first_available_uid()

        assert next_uid == 999201
示例#2
0
    def test_reserved_uid(self):
        """Test that we skip over the reserved UID range of 61184-65535.
        """

        connection = mock.Mock(response=[
            {
                'attributes': {
                    'uidNumber': 61183
                }
            },
            {
                'attributes': {
                    'uidNumber': 60000
                }
            },
        ])

        @contextmanager
        def ldap_ocf():
            yield connection

        with mock.patch('ocflib.account.creation.ldap_ocf', ldap_ocf):
            next_uid = _get_first_available_uid()

        assert next_uid == 65536
示例#3
0
    def test_first_uid(self):
        connection = mock.Mock(response=[
            {'attributes': {'uidNumber': [999000]}},
            {'attributes': {'uidNumber': [999200]}},
            {'attributes': {'uidNumber': [999100]}},
        ])

        @contextmanager
        def ldap_ocf():
            yield connection

        with mock.patch('ocflib.account.creation.ldap_ocf', ldap_ocf):
            next_uid = _get_first_available_uid()

        assert next_uid == 999201
示例#4
0
    def test_alerts_staff_if_too_many(self, send_problem_report):
        connection = mock.Mock(response=[
            {'attributes': {'uidNumber': [n]}}
            for n in range(100000, 100000 + 5000)
        ])

        @contextmanager
        def ldap_ocf():
            yield connection

        with mock.patch('ocflib.account.creation.ldap_ocf', ldap_ocf):
            next_uid = _get_first_available_uid()

        assert next_uid == 105000
        assert send_problem_report.called
示例#5
0
    def test_alerts_staff_if_too_many(self, send_problem_report):
        connection = mock.Mock(response=[{
            'attributes': {
                'uidNumber': [n]
            }
        } for n in range(100000, 100000 + 5000)])

        @contextmanager
        def ldap_ocf():
            yield connection

        with mock.patch('ocflib.account.creation.ldap_ocf', ldap_ocf):
            next_uid = _get_first_available_uid()

        assert next_uid == 105000
        assert send_problem_report.called