| 1 |
# --- BEGIN COPYRIGHT BLOCK --- |
| 2 |
# Copyright (C) 2022 William Brown <[email protected]> |
| 3 |
# All rights reserved. |
| 4 |
# |
| 5 |
# License: GPL (version 3 or any later version). |
| 6 |
# See LICENSE for details. |
| 7 |
# --- END COPYRIGHT BLOCK --- |
| 8 |
# |
| 9 |
|
| 10 |
|
| 11 |
import os |
| 12 |
import logging |
| 13 |
import pytest |
| 14 |
import ldap |
| 15 |
|
| 16 |
from test389.topologies import topology_st as topology |
| 17 |
from lib389._constants import DEFAULT_SUFFIX |
| 18 |
from lib389.schema import Schema |
| 19 |
|
| 20 |
pytestmark = pytest.mark.tier1 |
| 21 |
|
| 22 |
def test_x_descr_oid(topology): |
| 23 |
"""Test import of an attribute using descr-oid format that starts |
| 24 |
with an X-. This should "fail" with a descriptive error message. |
| 25 |
|
| 26 |
:id: 9308bdbd-363c-45a9-8223-9a6c925dba37 |
| 27 |
|
| 28 |
:setup: Standalone instance |
| 29 |
|
| 30 |
:steps: |
| 31 |
1. Add invalid x-attribute |
| 32 |
2. Add valid x-attribute |
| 33 |
3. Add invalid x-object |
| 34 |
4. Add valid x-object |
| 35 |
|
| 36 |
:expectedresults: |
| 37 |
1. raises INVALID_SYNTAX |
| 38 |
2. success |
| 39 |
3. raises INVALID_SYNTAX |
| 40 |
4. success |
| 41 |
""" |
| 42 |
inst = topology.standalone |
| 43 |
|
| 44 |
schema = Schema(inst) |
| 45 |
|
| 46 |
with pytest.raises(ldap.INVALID_SYNTAX): |
| 47 |
schema.add('attributeTypes', "( x-attribute-oid NAME 'x-attribute' DESC 'desc' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'user defined' )") |
| 48 |
schema.add('attributeTypes', "( 1.2.3.4.5.6.7.8.9.10 NAME 'x-attribute' DESC 'desc' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'user defined' )") |
| 49 |
|
| 50 |
with pytest.raises(ldap.INVALID_SYNTAX): |
| 51 |
schema.add('objectClasses', "( x-object-oid NAME 'x-object' DESC 'desc' SUP TOP AUXILIARY MAY ( x-attribute ) X-ORIGIN 'user defined' )") |
| 52 |
schema.add('objectClasses', "( 1.2.3.4.5.6.7.8.9.11 NAME 'x-object' DESC 'desc' SUP TOP AUXILIARY MAY ( x-attribute ) X-ORIGIN 'user defined' )") |
| 53 |
|