Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdacloud
dex
Commits
8f113548
Unverified
Commit
8f113548
authored
6 years ago
by
Joel Speed
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #1249 from srenatus/sr/add-ldap-filter-test
ldap_test: add filter tests
parents
b6f4740a
df18cb0c
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
connector/ldap/ldap_test.go
+202
-0
202 additions, 0 deletions
connector/ldap/ldap_test.go
with
202 additions
and
0 deletions
connector/ldap/ldap_test.go
+
202
−
0
View file @
8f113548
...
...
@@ -185,6 +185,102 @@ userpassword: bar
runTests
(
t
,
schema
,
connectLDAP
,
c
,
tests
)
}
func
TestUserFilter
(
t
*
testing
.
T
)
{
schema
:=
`
dn: dc=example,dc=org
objectClass: dcObject
objectClass: organization
o: Example Company
dc: example
dn: ou=Seattle,dc=example,dc=org
objectClass: organizationalUnit
ou: Seattle
dn: ou=Portland,dc=example,dc=org
objectClass: organizationalUnit
ou: Portland
dn: ou=People,ou=Seattle,dc=example,dc=org
objectClass: organizationalUnit
ou: People
dn: ou=People,ou=Portland,dc=example,dc=org
objectClass: organizationalUnit
ou: People
dn: cn=jane,ou=People,ou=Seattle,dc=example,dc=org
objectClass: person
objectClass: inetOrgPerson
sn: doe
cn: jane
mail: janedoe@example.com
userpassword: foo
dn: cn=jane,ou=People,ou=Portland,dc=example,dc=org
objectClass: person
objectClass: inetOrgPerson
sn: doe
cn: jane
mail: janedoefromportland@example.com
userpassword: baz
dn: cn=john,ou=People,ou=Seattle,dc=example,dc=org
objectClass: person
objectClass: inetOrgPerson
sn: doe
cn: john
mail: johndoe@example.com
userpassword: bar
`
c
:=
&
Config
{}
c
.
UserSearch
.
BaseDN
=
"dc=example,dc=org"
c
.
UserSearch
.
NameAttr
=
"cn"
c
.
UserSearch
.
EmailAttr
=
"mail"
c
.
UserSearch
.
IDAttr
=
"DN"
c
.
UserSearch
.
Username
=
"cn"
c
.
UserSearch
.
Filter
=
"(ou:dn:=Seattle)"
tests
:=
[]
subtest
{
{
name
:
"validpassword"
,
username
:
"jane"
,
password
:
"foo"
,
want
:
connector
.
Identity
{
UserID
:
"cn=jane,ou=People,ou=Seattle,dc=example,dc=org"
,
Username
:
"jane"
,
Email
:
"janedoe@example.com"
,
EmailVerified
:
true
,
},
},
{
name
:
"validpassword2"
,
username
:
"john"
,
password
:
"bar"
,
want
:
connector
.
Identity
{
UserID
:
"cn=john,ou=People,ou=Seattle,dc=example,dc=org"
,
Username
:
"john"
,
Email
:
"johndoe@example.com"
,
EmailVerified
:
true
,
},
},
{
name
:
"invalidpassword"
,
username
:
"jane"
,
password
:
"badpassword"
,
wantBadPW
:
true
,
},
{
name
:
"invaliduser"
,
username
:
"idontexist"
,
password
:
"foo"
,
wantBadPW
:
true
,
// Want invalid password, not a query error.
},
}
runTests
(
t
,
schema
,
connectLDAP
,
c
,
tests
)
}
func
TestGroupQuery
(
t
*
testing
.
T
)
{
schema
:=
`
dn: dc=example,dc=org
...
...
@@ -370,6 +466,112 @@ gidNumber: 1002
runTests
(
t
,
schema
,
connectLDAP
,
c
,
tests
)
}
func
TestGroupFilter
(
t
*
testing
.
T
)
{
schema
:=
`
dn: dc=example,dc=org
objectClass: dcObject
objectClass: organization
o: Example Company
dc: example
dn: ou=People,dc=example,dc=org
objectClass: organizationalUnit
ou: People
dn: cn=jane,ou=People,dc=example,dc=org
objectClass: person
objectClass: inetOrgPerson
sn: doe
cn: jane
mail: janedoe@example.com
userpassword: foo
dn: cn=john,ou=People,dc=example,dc=org
objectClass: person
objectClass: inetOrgPerson
sn: doe
cn: john
mail: johndoe@example.com
userpassword: bar
# Group definitions.
dn: ou=Seattle,dc=example,dc=org
objectClass: organizationalUnit
ou: Seattle
dn: ou=Portland,dc=example,dc=org
objectClass: organizationalUnit
ou: Portland
dn: ou=Groups,ou=Seattle,dc=example,dc=org
objectClass: organizationalUnit
ou: Groups
dn: ou=Groups,ou=Portland,dc=example,dc=org
objectClass: organizationalUnit
ou: Groups
dn: cn=qa,ou=Groups,ou=Portland,dc=example,dc=org
objectClass: groupOfNames
cn: qa
member: cn=john,ou=People,dc=example,dc=org
dn: cn=admins,ou=Groups,ou=Seattle,dc=example,dc=org
objectClass: groupOfNames
cn: admins
member: cn=john,ou=People,dc=example,dc=org
member: cn=jane,ou=People,dc=example,dc=org
dn: cn=developers,ou=Groups,ou=Seattle,dc=example,dc=org
objectClass: groupOfNames
cn: developers
member: cn=jane,ou=People,dc=example,dc=org
`
c
:=
&
Config
{}
c
.
UserSearch
.
BaseDN
=
"ou=People,dc=example,dc=org"
c
.
UserSearch
.
NameAttr
=
"cn"
c
.
UserSearch
.
EmailAttr
=
"mail"
c
.
UserSearch
.
IDAttr
=
"DN"
c
.
UserSearch
.
Username
=
"cn"
c
.
GroupSearch
.
BaseDN
=
"dc=example,dc=org"
c
.
GroupSearch
.
UserAttr
=
"DN"
c
.
GroupSearch
.
GroupAttr
=
"member"
c
.
GroupSearch
.
NameAttr
=
"cn"
c
.
GroupSearch
.
Filter
=
"(ou:dn:=Seattle)"
// ignore other groups
tests
:=
[]
subtest
{
{
name
:
"validpassword"
,
username
:
"jane"
,
password
:
"foo"
,
groups
:
true
,
want
:
connector
.
Identity
{
UserID
:
"cn=jane,ou=People,dc=example,dc=org"
,
Username
:
"jane"
,
Email
:
"janedoe@example.com"
,
EmailVerified
:
true
,
Groups
:
[]
string
{
"admins"
,
"developers"
},
},
},
{
name
:
"validpassword2"
,
username
:
"john"
,
password
:
"bar"
,
groups
:
true
,
want
:
connector
.
Identity
{
UserID
:
"cn=john,ou=People,dc=example,dc=org"
,
Username
:
"john"
,
Email
:
"johndoe@example.com"
,
EmailVerified
:
true
,
Groups
:
[]
string
{
"admins"
},
},
},
}
runTests
(
t
,
schema
,
connectLDAP
,
c
,
tests
)
}
func
TestStartTLS
(
t
*
testing
.
T
)
{
schema
:=
`
dn: dc=example,dc=org
...
...
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