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
712b7ba2
Commit
712b7ba2
authored
1 month ago
by
Lars Seipel
Browse files
Options
Downloads
Patches
Plain Diff
connector/ldap: fix tests after encoding UserID
parent
9d9698a1
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
+24
-19
24 additions, 19 deletions
connector/ldap/ldap_test.go
with
24 additions
and
19 deletions
connector/ldap/ldap_test.go
+
24
−
19
View file @
712b7ba2
...
@@ -2,6 +2,7 @@ package ldap
...
@@ -2,6 +2,7 @@ package ldap
import
(
import
(
"context"
"context"
"encoding/hex"
"fmt"
"fmt"
"io"
"io"
"log/slog"
"log/slog"
...
@@ -40,6 +41,10 @@ type subtest struct {
...
@@ -40,6 +41,10 @@ type subtest struct {
want
connector
.
Identity
want
connector
.
Identity
}
}
func
enc
(
s
string
)
string
{
return
hex
.
EncodeToString
([]
byte
(
s
))
}
func
TestQuery
(
t
*
testing
.
T
)
{
func
TestQuery
(
t
*
testing
.
T
)
{
c
:=
&
Config
{}
c
:=
&
Config
{}
c
.
UserSearch
.
BaseDN
=
"ou=People,ou=TestQuery,dc=example,dc=org"
c
.
UserSearch
.
BaseDN
=
"ou=People,ou=TestQuery,dc=example,dc=org"
...
@@ -54,7 +59,7 @@ func TestQuery(t *testing.T) {
...
@@ -54,7 +59,7 @@ func TestQuery(t *testing.T) {
username
:
"jane"
,
username
:
"jane"
,
password
:
"foo"
,
password
:
"foo"
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=jane,ou=People,ou=TestQuery,dc=example,dc=org"
,
UserID
:
enc
(
"cn=jane,ou=People,ou=TestQuery,dc=example,dc=org"
)
,
Username
:
"jane"
,
Username
:
"jane"
,
Email
:
"janedoe@example.com"
,
Email
:
"janedoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -65,7 +70,7 @@ func TestQuery(t *testing.T) {
...
@@ -65,7 +70,7 @@ func TestQuery(t *testing.T) {
username
:
"john"
,
username
:
"john"
,
password
:
"bar"
,
password
:
"bar"
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=john,ou=People,ou=TestQuery,dc=example,dc=org"
,
UserID
:
enc
(
"cn=john,ou=People,ou=TestQuery,dc=example,dc=org"
)
,
Username
:
"john"
,
Username
:
"john"
,
Email
:
"johndoe@example.com"
,
Email
:
"johndoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -114,7 +119,7 @@ func TestQueryWithEmailSuffix(t *testing.T) {
...
@@ -114,7 +119,7 @@ func TestQueryWithEmailSuffix(t *testing.T) {
username
:
"jane"
,
username
:
"jane"
,
password
:
"foo"
,
password
:
"foo"
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=jane,ou=People,ou=TestQueryWithEmailSuffix,dc=example,dc=org"
,
UserID
:
enc
(
"cn=jane,ou=People,ou=TestQueryWithEmailSuffix,dc=example,dc=org"
)
,
Username
:
"jane"
,
Username
:
"jane"
,
Email
:
"jane@test.example.com"
,
Email
:
"jane@test.example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -125,7 +130,7 @@ func TestQueryWithEmailSuffix(t *testing.T) {
...
@@ -125,7 +130,7 @@ func TestQueryWithEmailSuffix(t *testing.T) {
username
:
"john"
,
username
:
"john"
,
password
:
"bar"
,
password
:
"bar"
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=john,ou=People,ou=TestQueryWithEmailSuffix,dc=example,dc=org"
,
UserID
:
enc
(
"cn=john,ou=People,ou=TestQueryWithEmailSuffix,dc=example,dc=org"
)
,
Username
:
"john"
,
Username
:
"john"
,
Email
:
"john@test.example.com"
,
Email
:
"john@test.example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -151,7 +156,7 @@ func TestUserFilter(t *testing.T) {
...
@@ -151,7 +156,7 @@ func TestUserFilter(t *testing.T) {
username
:
"jane"
,
username
:
"jane"
,
password
:
"foo"
,
password
:
"foo"
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=jane,ou=People,ou=Seattle,ou=TestUserFilter,dc=example,dc=org"
,
UserID
:
enc
(
"cn=jane,ou=People,ou=Seattle,ou=TestUserFilter,dc=example,dc=org"
)
,
Username
:
"jane"
,
Username
:
"jane"
,
Email
:
"janedoe@example.com"
,
Email
:
"janedoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -162,7 +167,7 @@ func TestUserFilter(t *testing.T) {
...
@@ -162,7 +167,7 @@ func TestUserFilter(t *testing.T) {
username
:
"john"
,
username
:
"john"
,
password
:
"bar"
,
password
:
"bar"
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=john,ou=People,ou=Seattle,ou=TestUserFilter,dc=example,dc=org"
,
UserID
:
enc
(
"cn=john,ou=People,ou=Seattle,ou=TestUserFilter,dc=example,dc=org"
)
,
Username
:
"john"
,
Username
:
"john"
,
Email
:
"johndoe@example.com"
,
Email
:
"johndoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -208,7 +213,7 @@ func TestGroupQuery(t *testing.T) {
...
@@ -208,7 +213,7 @@ func TestGroupQuery(t *testing.T) {
password
:
"foo"
,
password
:
"foo"
,
groups
:
true
,
groups
:
true
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=jane,ou=People,ou=TestGroupQuery,dc=example,dc=org"
,
UserID
:
enc
(
"cn=jane,ou=People,ou=TestGroupQuery,dc=example,dc=org"
)
,
Username
:
"jane"
,
Username
:
"jane"
,
Email
:
"janedoe@example.com"
,
Email
:
"janedoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -221,7 +226,7 @@ func TestGroupQuery(t *testing.T) {
...
@@ -221,7 +226,7 @@ func TestGroupQuery(t *testing.T) {
password
:
"bar"
,
password
:
"bar"
,
groups
:
true
,
groups
:
true
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=john,ou=People,ou=TestGroupQuery,dc=example,dc=org"
,
UserID
:
enc
(
"cn=john,ou=People,ou=TestGroupQuery,dc=example,dc=org"
)
,
Username
:
"john"
,
Username
:
"john"
,
Email
:
"johndoe@example.com"
,
Email
:
"johndoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -255,7 +260,7 @@ func TestGroupsOnUserEntity(t *testing.T) {
...
@@ -255,7 +260,7 @@ func TestGroupsOnUserEntity(t *testing.T) {
password
:
"foo"
,
password
:
"foo"
,
groups
:
true
,
groups
:
true
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=jane,ou=People,ou=TestGroupsOnUserEntity,dc=example,dc=org"
,
UserID
:
enc
(
"cn=jane,ou=People,ou=TestGroupsOnUserEntity,dc=example,dc=org"
)
,
Username
:
"jane"
,
Username
:
"jane"
,
Email
:
"janedoe@example.com"
,
Email
:
"janedoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -268,7 +273,7 @@ func TestGroupsOnUserEntity(t *testing.T) {
...
@@ -268,7 +273,7 @@ func TestGroupsOnUserEntity(t *testing.T) {
password
:
"bar"
,
password
:
"bar"
,
groups
:
true
,
groups
:
true
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=john,ou=People,ou=TestGroupsOnUserEntity,dc=example,dc=org"
,
UserID
:
enc
(
"cn=john,ou=People,ou=TestGroupsOnUserEntity,dc=example,dc=org"
)
,
Username
:
"john"
,
Username
:
"john"
,
Email
:
"johndoe@example.com"
,
Email
:
"johndoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -303,7 +308,7 @@ func TestGroupFilter(t *testing.T) {
...
@@ -303,7 +308,7 @@ func TestGroupFilter(t *testing.T) {
password
:
"foo"
,
password
:
"foo"
,
groups
:
true
,
groups
:
true
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=jane,ou=People,ou=TestGroupFilter,dc=example,dc=org"
,
UserID
:
enc
(
"cn=jane,ou=People,ou=TestGroupFilter,dc=example,dc=org"
)
,
Username
:
"jane"
,
Username
:
"jane"
,
Email
:
"janedoe@example.com"
,
Email
:
"janedoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -316,7 +321,7 @@ func TestGroupFilter(t *testing.T) {
...
@@ -316,7 +321,7 @@ func TestGroupFilter(t *testing.T) {
password
:
"bar"
,
password
:
"bar"
,
groups
:
true
,
groups
:
true
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=john,ou=People,ou=TestGroupFilter,dc=example,dc=org"
,
UserID
:
enc
(
"cn=john,ou=People,ou=TestGroupFilter,dc=example,dc=org"
)
,
Username
:
"john"
,
Username
:
"john"
,
Email
:
"johndoe@example.com"
,
Email
:
"johndoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -356,7 +361,7 @@ func TestGroupToUserMatchers(t *testing.T) {
...
@@ -356,7 +361,7 @@ func TestGroupToUserMatchers(t *testing.T) {
password
:
"foo"
,
password
:
"foo"
,
groups
:
true
,
groups
:
true
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=jane,ou=People,ou=TestGroupToUserMatchers,dc=example,dc=org"
,
UserID
:
enc
(
"cn=jane,ou=People,ou=TestGroupToUserMatchers,dc=example,dc=org"
)
,
Username
:
"jane"
,
Username
:
"jane"
,
Email
:
"janedoe@example.com"
,
Email
:
"janedoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -369,7 +374,7 @@ func TestGroupToUserMatchers(t *testing.T) {
...
@@ -369,7 +374,7 @@ func TestGroupToUserMatchers(t *testing.T) {
password
:
"bar"
,
password
:
"bar"
,
groups
:
true
,
groups
:
true
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=john,ou=People,ou=TestGroupToUserMatchers,dc=example,dc=org"
,
UserID
:
enc
(
"cn=john,ou=People,ou=TestGroupToUserMatchers,dc=example,dc=org"
)
,
Username
:
"john"
,
Username
:
"john"
,
Email
:
"johndoe@example.com"
,
Email
:
"johndoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -404,7 +409,7 @@ func TestDeprecatedGroupToUserMatcher(t *testing.T) {
...
@@ -404,7 +409,7 @@ func TestDeprecatedGroupToUserMatcher(t *testing.T) {
password
:
"foo"
,
password
:
"foo"
,
groups
:
true
,
groups
:
true
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=jane,ou=People,ou=TestDeprecatedGroupToUserMatcher,dc=example,dc=org"
,
UserID
:
enc
(
"cn=jane,ou=People,ou=TestDeprecatedGroupToUserMatcher,dc=example,dc=org"
)
,
Username
:
"jane"
,
Username
:
"jane"
,
Email
:
"janedoe@example.com"
,
Email
:
"janedoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -417,7 +422,7 @@ func TestDeprecatedGroupToUserMatcher(t *testing.T) {
...
@@ -417,7 +422,7 @@ func TestDeprecatedGroupToUserMatcher(t *testing.T) {
password
:
"bar"
,
password
:
"bar"
,
groups
:
true
,
groups
:
true
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=john,ou=People,ou=TestDeprecatedGroupToUserMatcher,dc=example,dc=org"
,
UserID
:
enc
(
"cn=john,ou=People,ou=TestDeprecatedGroupToUserMatcher,dc=example,dc=org"
)
,
Username
:
"john"
,
Username
:
"john"
,
Email
:
"johndoe@example.com"
,
Email
:
"johndoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -443,7 +448,7 @@ func TestStartTLS(t *testing.T) {
...
@@ -443,7 +448,7 @@ func TestStartTLS(t *testing.T) {
username
:
"jane"
,
username
:
"jane"
,
password
:
"foo"
,
password
:
"foo"
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=jane,ou=People,ou=TestStartTLS,dc=example,dc=org"
,
UserID
:
enc
(
"cn=jane,ou=People,ou=TestStartTLS,dc=example,dc=org"
)
,
Username
:
"jane"
,
Username
:
"jane"
,
Email
:
"janedoe@example.com"
,
Email
:
"janedoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -467,7 +472,7 @@ func TestInsecureSkipVerify(t *testing.T) {
...
@@ -467,7 +472,7 @@ func TestInsecureSkipVerify(t *testing.T) {
username
:
"jane"
,
username
:
"jane"
,
password
:
"foo"
,
password
:
"foo"
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=jane,ou=People,ou=TestInsecureSkipVerify,dc=example,dc=org"
,
UserID
:
enc
(
"cn=jane,ou=People,ou=TestInsecureSkipVerify,dc=example,dc=org"
)
,
Username
:
"jane"
,
Username
:
"jane"
,
Email
:
"janedoe@example.com"
,
Email
:
"janedoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
@@ -491,7 +496,7 @@ func TestLDAPS(t *testing.T) {
...
@@ -491,7 +496,7 @@ func TestLDAPS(t *testing.T) {
username
:
"jane"
,
username
:
"jane"
,
password
:
"foo"
,
password
:
"foo"
,
want
:
connector
.
Identity
{
want
:
connector
.
Identity
{
UserID
:
"cn=jane,ou=People,ou=TestLDAPS,dc=example,dc=org"
,
UserID
:
enc
(
"cn=jane,ou=People,ou=TestLDAPS,dc=example,dc=org"
)
,
Username
:
"jane"
,
Username
:
"jane"
,
Email
:
"janedoe@example.com"
,
Email
:
"janedoe@example.com"
,
EmailVerified
:
true
,
EmailVerified
:
true
,
...
...
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