Skip to content
Snippets Groups Projects
Commit 712b7ba2 authored by Lars Seipel's avatar Lars Seipel
Browse files

connector/ldap: fix tests after encoding UserID

parent 9d9698a1
No related branches found
No related tags found
No related merge requests found
...@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment