Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
diceware-debian
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drebs
diceware-debian
Commits
85feb8c1
Commit
85feb8c1
authored
10 years ago
by
ulif
Browse files
Options
Downloads
Patches
Plain Diff
Use new wordlist.
parent
b6598e42
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
diceware/diceware.py
+2
-6
2 additions, 6 deletions
diceware/diceware.py
tests/test_diceware.py
+8
-20
8 additions, 20 deletions
tests/test_diceware.py
with
10 additions
and
26 deletions
diceware/diceware.py
+
2
−
6
View file @
85feb8c1
...
@@ -26,12 +26,8 @@ def get_wordlist(path):
...
@@ -26,12 +26,8 @@ def get_wordlist(path):
"""
"""
result
=
[]
result
=
[]
with
open
(
path
,
'
r
'
)
as
fd
:
with
open
(
path
,
'
r
'
)
as
fd
:
for
line
in
fd
.
readlines
():
result
=
[
line
.
strip
()
for
line
in
fd
.
readlines
()
if
not
'
\t
'
in
line
:
if
line
.
strip
()
!=
''
]
continue
term
=
line
.
split
(
'
\t
'
)[
1
].
strip
()
if
term
!=
''
:
# do not accept empty strings
result
.
append
(
term
)
return
result
return
result
...
...
This diff is collapsed.
Click to expand it.
tests/test_diceware.py
+
8
−
20
View file @
85feb8c1
...
@@ -9,35 +9,23 @@ class Test_GetWordList(object):
...
@@ -9,35 +9,23 @@ class Test_GetWordList(object):
def
test_get_wordlist_en
(
self
):
def
test_get_wordlist_en
(
self
):
# we can get a list of words out of english wordlist.
# we can get a list of words out of english wordlist.
en_src
=
os
.
path
.
join
(
SRC_DIR
,
'
wordlist_en.
asc
'
)
en_src
=
os
.
path
.
join
(
SRC_DIR
,
'
wordlist_en.
txt
'
)
en_result
=
get_wordlist
(
en_src
)
en_result
=
get_wordlist
(
en_src
)
assert
en_result
[
0
]
==
'
a
'
assert
en_result
[
0
]
==
'
a
'
assert
en_result
[
-
1
]
==
'
@
'
assert
en_result
[
-
1
]
==
'
@
'
assert
len
(
en_result
)
==
7776
assert
len
(
en_result
)
==
8192
def
test_get_wordlist_simple
(
self
,
tmpdir
):
def
test_get_wordlist_simple
(
self
,
tmpdir
):
# simple wordlists can be created
# simple wordlists can be created
in_file
=
tmpdir
.
mkdir
(
"
work
"
).
join
(
"
mywordlist
"
)
in_file
=
tmpdir
.
mkdir
(
"
work
"
).
join
(
"
mywordlist
"
)
in_file
.
write
(
"
01
\t
a
\n
02
\t
b
\n
"
)
in_file
.
write
(
"
a
\n
b
\n
"
)
assert
[
'
a
'
,
'
b
'
]
==
get_wordlist
(
in_file
.
strpath
)
assert
[
'
a
'
,
'
b
'
]
==
get_wordlist
(
in_file
.
strpath
)
def
test_get_wordlist_ignore_empty_lines
(
self
,
tmpdir
):
def
test_get_wordlist_ignore_empty_lines
(
self
,
tmpdir
):
# we ignore empty lines in wordlists
# we ignore empty lines in wordlists
in_file
=
tmpdir
.
mkdir
(
"
work
"
).
join
(
"
mywordlist
"
)
in_file
=
tmpdir
.
mkdir
(
"
work
"
).
join
(
"
mywordlist
"
)
in_file
.
write
(
"
\n\n\n
"
)
in_file
.
write
(
"
\n\n
a
\n\n
"
)
assert
[]
==
get_wordlist
(
in_file
.
strpath
)
assert
[
'
a
'
]
==
get_wordlist
(
in_file
.
strpath
)
def
test_get_wordlist_ignore_non_data
(
self
,
tmpdir
):
# lines without tabs ('\t') are ignored
in_file
=
tmpdir
.
mkdir
(
"
work
"
).
join
(
"
mywordlist
"
)
in_file
.
write
(
"
111111 a
\n
111112 b
\n
"
)
assert
[]
==
get_wordlist
(
in_file
.
strpath
)
def
test_get_wordlist_broken
(
self
,
tmpdir
):
# we handle broken lines gracefully
in_file
=
tmpdir
.
mkdir
(
"
work
"
).
join
(
"
mywordlist
"
)
in_file
.
write
(
"
11
\t
a
\t
12
\n
22
\t\n\n
33
\t
c
"
)
assert
[
'
a
'
,
'
c
'
]
==
get_wordlist
(
in_file
.
strpath
)
class
TestDicewareModule
(
object
):
class
TestDicewareModule
(
object
):
...
@@ -56,9 +44,9 @@ class TestDicewareModule(object):
...
@@ -56,9 +44,9 @@ class TestDicewareModule(object):
def
test_get_wordlist_path_loweres_country_code
(
self
):
def
test_get_wordlist_path_loweres_country_code
(
self
):
# upper case country codes are lowered
# upper case country codes are lowered
assert
os
.
path
.
basename
(
get_wordlist_path
(
'
de
'
))
==
'
wordlist_de.
asc
'
assert
os
.
path
.
basename
(
get_wordlist_path
(
'
de
'
))
==
'
wordlist_de.
txt
'
assert
os
.
path
.
basename
(
get_wordlist_path
(
'
De
'
))
==
'
wordlist_de.
asc
'
assert
os
.
path
.
basename
(
get_wordlist_path
(
'
De
'
))
==
'
wordlist_de.
txt
'
assert
os
.
path
.
basename
(
get_wordlist_path
(
'
DE
'
))
==
'
wordlist_de.
asc
'
assert
os
.
path
.
basename
(
get_wordlist_path
(
'
DE
'
))
==
'
wordlist_de.
txt
'
def
test_get_passphrase
(
self
):
def
test_get_passphrase
(
self
):
# we can get passphrases
# we can get passphrases
...
...
This diff is collapsed.
Click to expand it.
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