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
223c7188
Commit
223c7188
authored
7 years ago
by
William Turner
Browse files
Options
Downloads
Patches
Plain Diff
Removes unused LDAP test utils
parent
7d95a088
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/metabase/test/integrations/ldap.clj
+6
-29
6 additions, 29 deletions
test/metabase/test/integrations/ldap.clj
with
6 additions
and
29 deletions
test/metabase/test/integrations/ldap.clj
+
6
−
29
View file @
223c7188
...
...
@@ -3,27 +3,23 @@
[
expectations
:refer
[
expect
]]
[
metabase.test.util
:as
tu
])
(
:import
(
com.unboundid.ldap.listener
InMemoryDirectoryServer
InMemoryDirectoryServerConfig
InMemoryListenerConfig
))
(
:import
(
com.unboundid.ldap.sdk.schema
Schema
)
)
(
:import
(
com.unboundid.ldif
LDIFReader
))
)
(
:import
com.unboundid.ldap.sdk.schema
.
Schema
)
(
:import
com.unboundid.ldif
.
LDIFReader
))
(
def
^
:dynamic
*ldap-server*
"An in-memory testing LDAP server."
nil
)
(
def
^
:dynamic
*ldap-connection*
"A connection to the in-memory LDAP server in `*ldap-server*`."
"An in-memory LDAP testing server."
nil
)
(
defn-
get-server-config
[]
(
doto
(
new
InMemoryDirectoryServerConfig
(
into-array
String
[
"dc=metabase,dc=com"
]))
(
doto
(
InMemoryDirectoryServerConfig
.
(
into-array
String
[
"dc=metabase,dc=com"
]))
(
.addAdditionalBindCredentials
"cn=Directory Manager"
"password"
)
(
.setSchema
(
Schema/getDefaultStandardSchema
))
(
.setListenerConfigs
(
into-array
InMemoryListenerConfig
[(
InMemoryListenerConfig/createLDAPConfig
"LDAP"
0
)]))))
(
defn-
start-ldap-server!
[]
(
with-open
[
ldif
(
new
LDIFReader
(
io/file
(
io/resource
"ldap.ldif"
)))]
(
doto
(
new
InMemoryDirectoryServer
(
get-server-config
))
(
with-open
[
ldif
(
LDIFReader
.
(
io/file
(
io/resource
"ldap.ldif"
)))]
(
doto
(
InMemoryDirectoryServer
.
(
get-server-config
))
(
.importFromLDIF
true
ldif
)
(
.startListening
))))
...
...
@@ -57,22 +53,3 @@
"Generate a unit test that runs ACTUAL with a bound `*ldap-server*` and relevant settings."
[
expected
actual
]
`
(
expect
~
expected
(
with-ldap-server
~
actual
)))
(
defn
do-with-ldap-connection
"Bind `*ldap-connection*` to a connection to an in-memory LDAP testing server and executes `f`."
[
f
]
(
with-ldap-server
(
binding
[
*ldap-connection*
(
.getConnection
*ldap-server*
)]
(
try
(
f
)
(
finally
(
.close
*ldap-connection*
))))))
(
defmacro
with-ldap-connection
"Bind `*ldap-connection*` to a connection to an in-memory LDAP testing server and executes BODY."
[
&
body
]
`
(
do-with-ldap-connection
(
fn
[]
~@
body
)))
(
defmacro
expect-with-ldap-connection
"Generate a unit test that runs ACTUAL with a bound `*ldap-server*` and `*ldap-connection*`."
[
expected
actual
]
`
(
expect
~
expected
(
with-ldap-connection
~
actual
)))
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