Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
48ba0aed
Unverified
Commit
48ba0aed
authored
1 year ago
by
Tim Macdonald
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Add unit test for MB_PASSWORD_LENGTH (#31690)
[Fixes #29884]
parent
1fb0b3d9
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
src/metabase/util/password.clj
+3
-3
3 additions, 3 deletions
src/metabase/util/password.clj
test/metabase/util/password_test.clj
+14
-1
14 additions, 1 deletion
test/metabase/util/password_test.clj
with
17 additions
and
4 deletions
src/metabase/util/password.clj
+
3
−
3
View file @
48ba0aed
...
...
@@ -13,7 +13,7 @@
"Return a map of the counts of each class of character for `password`.
(count-occurrences \"GoodPw!!\")
-> {:total
8, :lower 4, :upper 2, :letter 6, :digit 0, :special 2}"
-> {:total 8, :lower 4, :upper 2, :letter 6, :digit 0, :special 2}"
[
password
]
(
loop
[[
^
Character
c
&
more
]
password,
counts
{
:total
0
,
:lower
0
,
:upper
0
,
:letter
0
,
:digit
0
,
:special
0
}]
(
if-not
c
...
...
@@ -46,10 +46,10 @@
[
char-type->min
password
]
{
:pre
[(
map?
char-type->min
)
(
string?
password
)]}
(
let
[
occur
a
nces
(
count-occurrences
password
)]
(
let
[
occur
e
nces
(
count-occurrences
password
)]
(
boolean
(
loop
[[[
char-type
min-count
]
&
more
]
(
seq
char-type->min
)]
(
if-not
char-type
true
(
when
(
>=
(
occur
a
nces
char-type
)
min-count
)
(
when
(
>=
(
occur
e
nces
char-type
)
min-count
)
(
recur
more
)))))))
(
defn
active-password-complexity
...
...
This diff is collapsed.
Click to expand it.
test/metabase/util/password_test.clj
+
14
−
1
View file @
48ba0aed
...
...
@@ -81,6 +81,19 @@
(
is
(
=
expected
(
u.password/is-valid?
input
))))))))
(
deftest
passsword-length-test
(
testing
"Password length can be set by the env variable MB_PASSWORD_LENGTH"
(
mt/with-temp-env-var-value
[
:mb-password-length
3
:mb-password-complexity
"weak"
]
;; Don't confuse the issue with other complexity requirements
(
doseq
[[
input
expected
]
{
"A"
false
"AB"
false
"ABC"
true
"ABCD"
true
"ABCD1"
true
}]
(
testing
(
pr-str
(
list
'is-valid?
input
))
(
is
(
=
expected
(
u.password/is-valid?
input
))))))))
(
deftest
^
:parallel
hash-bcrypt-tests
;; these functions were copied from cemerick/friend and just call out to org.mindrot.jbcrypt.BCrypt so these tests
;; are a bit perfunctory
...
...
@@ -89,4 +102,4 @@
hashed
(
u.password/hash-bcrypt
password
)]
(
is
(
not=
password
hashed
))
(
testing
"Can verify our hashed passwords"
(
is
(
u.password/bcrypt-verify
password
hashed
)
"Password did not verify"
))))
(
is
(
u.password/bcrypt-verify
password
hashed
)
"Password did not verify"
))))
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