Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-ldapserver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
uffd
python-ldapserver
Commits
a0fdd249
Commit
a0fdd249
authored
3 years ago
by
Julian Rother
Browse files
Options
Downloads
Patches
Plain Diff
Unit tests for RFC4518 stringprep
parent
ca251f6f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#8890
passed
3 years ago
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_stringprep.py
+29
-4
29 additions, 4 deletions
tests/test_stringprep.py
with
29 additions
and
4 deletions
tests/test_stringprep.py
+
29
−
4
View file @
a0fdd249
...
@@ -5,12 +5,37 @@ from ldapserver.rfc4518_stringprep import prepare, MatchingType, SubstringType
...
@@ -5,12 +5,37 @@ from ldapserver.rfc4518_stringprep import prepare, MatchingType, SubstringType
class
TestStringprep
(
unittest
.
TestCase
):
class
TestStringprep
(
unittest
.
TestCase
):
def
test_map
(
self
):
def
test_map
(
self
):
# [...] COMBINING GRAPHEME JOINER (U+034F) [...] code points are also mapped to nothing.
self
.
assertEqual
(
prepare
(
'
foo
\u034F
bar
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
NONE
),
'
foobar
'
)
# [...] LINE FEED (LF) (U+000A) [...] are mapped to SPACE (U+0020).
self
.
assertEqual
(
prepare
(
'
foo
\n\r
bar
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
NONE
),
'
foo bar
'
)
self
.
assertEqual
(
prepare
(
'
foo
\n\r
bar
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
NONE
),
'
foo bar
'
)
self
.
assertEqual
(
prepare
(
'
foo
\u200B
bar
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
NONE
),
'
foobar
'
)
# For case ignore, numeric, and stored prefix string matching rules,
# characters are case folded per B.2 of [RFC3454].
self
.
assertEqual
(
prepare
(
'
FooBar
'
,
MatchingType
.
CASE_IGNORE_STRING
,
SubstringType
.
NONE
),
'
foobar
'
)
# Not that a valid numeric string can contain any characters affected by case-folding?!
self
.
assertEqual
(
prepare
(
'
FooBar
'
,
MatchingType
.
NUMERIC_STRING
,
SubstringType
.
NONE
),
'
foobar
'
)
# TODO: systematic test cases
def
test_normalize
(
self
):
self
.
assertEqual
(
prepare
(
'
\u00C5
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
NONE
),
'
\u00C5
'
)
self
.
assertEqual
(
prepare
(
'
\u212B
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
NONE
),
'
\u00C5
'
)
self
.
assertEqual
(
prepare
(
'
\u0041\u030A
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
NONE
),
'
\u00C5
'
)
def
test_check_prohibited
(
self
):
with
self
.
assertRaises
(
ValueError
):
prepare
(
'
foo
\uFFFD
bar
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
NONE
)
def
test_insignificant_characters
(
self
):
self
.
assertEqual
(
prepare
(
'
foo bar
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
NONE
),
'
foo bar
'
)
# Test special case of SPACE followed by combining mark
self
.
assertEqual
(
prepare
(
'
foo
\u030A
bar
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
NONE
),
'
foo
\u030A
bar
'
)
self
.
assertEqual
(
prepare
(
'
\u030A
foobar
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
NONE
),
'
\u030A
foobar
'
)
self
.
assertEqual
(
prepare
(
'
foobar
\u030A
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
NONE
),
'
foobar
\u030A
'
)
# Not that a numeric string or a telephone number can contain any combining
# marks, but the RFC says that SPACES followed by combining marks are
# special, so ...?!
self
.
assertEqual
(
prepare
(
'
foo
\u030A
bar
'
,
MatchingType
.
NUMERIC_STRING
),
'
foo
\u030A
bar
'
)
self
.
assertEqual
(
prepare
(
'
foo
\u030A
bar
'
,
MatchingType
.
TELEPHONE_NUMBER
),
'
foo
\u030A
bar
'
)
def
test_examples
(
self
):
# Examples from RFC4518 for "Insignificant Character Handling"
# Examples from RFC4518 for "Insignificant Character Handling"
self
.
assertEqual
(
prepare
(
'
foo bar
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
NONE
),
'
foo bar
'
)
self
.
assertEqual
(
prepare
(
'
foo bar
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
NONE
),
'
foo bar
'
)
self
.
assertEqual
(
prepare
(
'
foo bar
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
INITIAL
),
'
foo bar
'
)
self
.
assertEqual
(
prepare
(
'
foo bar
'
,
MatchingType
.
EXACT_STRING
,
SubstringType
.
INITIAL
),
'
foo bar
'
)
...
...
This diff is collapsed.
Click to expand it.
Julian
@julian
mentioned in issue
#10 (closed)
·
3 years ago
mentioned in issue
#10 (closed)
mentioned in issue #10
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment