providers/ldap: making ldap compatible with synology (#4694)
* internal/outpost/ldap: making ldap compatible with synology * fix duplicate attributes Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add docs about homedirectory Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix duplicate attributes Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add substitution to values Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -19,16 +19,26 @@ func TestAKAttrsToLDAP_String(t *testing.T) {
|
||||
u.Attributes = map[string]interface{}{
|
||||
"foo": "bar",
|
||||
}
|
||||
assert.Equal(t, 1, len(AttributesToLDAP(u.Attributes, true)))
|
||||
assert.Equal(t, "foo", AttributesToLDAP(u.Attributes, true)[0].Name)
|
||||
assert.Equal(t, []string{"bar"}, AttributesToLDAP(u.Attributes, true)[0].Values)
|
||||
mapped := AttributesToLDAP(u.Attributes, func(key string) string {
|
||||
return AttributeKeySanitize(key)
|
||||
}, func(value []string) []string {
|
||||
return value
|
||||
})
|
||||
assert.Equal(t, 1, len(mapped))
|
||||
assert.Equal(t, "foo", mapped[0].Name)
|
||||
assert.Equal(t, []string{"bar"}, mapped[0].Values)
|
||||
// pointer string
|
||||
u.Attributes = map[string]interface{}{
|
||||
"foo": api.PtrString("bar"),
|
||||
}
|
||||
assert.Equal(t, 1, len(AttributesToLDAP(u.Attributes, true)))
|
||||
assert.Equal(t, "foo", AttributesToLDAP(u.Attributes, true)[0].Name)
|
||||
assert.Equal(t, []string{"bar"}, AttributesToLDAP(u.Attributes, true)[0].Values)
|
||||
mapped = AttributesToLDAP(u.Attributes, func(key string) string {
|
||||
return AttributeKeySanitize(key)
|
||||
}, func(value []string) []string {
|
||||
return value
|
||||
})
|
||||
assert.Equal(t, 1, len(mapped))
|
||||
assert.Equal(t, "foo", mapped[0].Name)
|
||||
assert.Equal(t, []string{"bar"}, mapped[0].Values)
|
||||
}
|
||||
|
||||
func TestAKAttrsToLDAP_String_List(t *testing.T) {
|
||||
@ -37,16 +47,26 @@ func TestAKAttrsToLDAP_String_List(t *testing.T) {
|
||||
u.Attributes = map[string]interface{}{
|
||||
"foo": []string{"bar"},
|
||||
}
|
||||
assert.Equal(t, 1, len(AttributesToLDAP(u.Attributes, true)))
|
||||
assert.Equal(t, "foo", AttributesToLDAP(u.Attributes, true)[0].Name)
|
||||
assert.Equal(t, []string{"bar"}, AttributesToLDAP(u.Attributes, true)[0].Values)
|
||||
mapped := AttributesToLDAP(u.Attributes, func(key string) string {
|
||||
return AttributeKeySanitize(key)
|
||||
}, func(value []string) []string {
|
||||
return value
|
||||
})
|
||||
assert.Equal(t, 1, len(mapped))
|
||||
assert.Equal(t, "foo", mapped[0].Name)
|
||||
assert.Equal(t, []string{"bar"}, mapped[0].Values)
|
||||
// pointer string list
|
||||
u.Attributes = map[string]interface{}{
|
||||
"foo": &[]string{"bar"},
|
||||
}
|
||||
assert.Equal(t, 1, len(AttributesToLDAP(u.Attributes, true)))
|
||||
assert.Equal(t, "foo", AttributesToLDAP(u.Attributes, true)[0].Name)
|
||||
assert.Equal(t, []string{"bar"}, AttributesToLDAP(u.Attributes, true)[0].Values)
|
||||
mapped = AttributesToLDAP(u.Attributes, func(key string) string {
|
||||
return AttributeKeySanitize(key)
|
||||
}, func(value []string) []string {
|
||||
return value
|
||||
})
|
||||
assert.Equal(t, 1, len(mapped))
|
||||
assert.Equal(t, "foo", mapped[0].Name)
|
||||
assert.Equal(t, []string{"bar"}, mapped[0].Values)
|
||||
}
|
||||
|
||||
func TestAKAttrsToLDAP_Dict(t *testing.T) {
|
||||
@ -56,9 +76,14 @@ func TestAKAttrsToLDAP_Dict(t *testing.T) {
|
||||
"foo": "bar",
|
||||
},
|
||||
}
|
||||
assert.Equal(t, 1, len(AttributesToLDAP(d, true)))
|
||||
assert.Equal(t, "foo", AttributesToLDAP(d, true)[0].Name)
|
||||
assert.Equal(t, []string{"map[foo:bar]"}, AttributesToLDAP(d, true)[0].Values)
|
||||
mapped := AttributesToLDAP(d, func(key string) string {
|
||||
return AttributeKeySanitize(key)
|
||||
}, func(value []string) []string {
|
||||
return value
|
||||
})
|
||||
assert.Equal(t, 1, len(mapped))
|
||||
assert.Equal(t, "foo", mapped[0].Name)
|
||||
assert.Equal(t, []string{"map[foo:bar]"}, mapped[0].Values)
|
||||
}
|
||||
|
||||
func TestAKAttrsToLDAP_Mixed(t *testing.T) {
|
||||
@ -69,7 +94,12 @@ func TestAKAttrsToLDAP_Mixed(t *testing.T) {
|
||||
6,
|
||||
},
|
||||
}
|
||||
assert.Equal(t, 1, len(AttributesToLDAP(d, true)))
|
||||
assert.Equal(t, "foo", AttributesToLDAP(d, true)[0].Name)
|
||||
assert.Equal(t, []string{"foo", "6"}, AttributesToLDAP(d, true)[0].Values)
|
||||
mapped := AttributesToLDAP(d, func(key string) string {
|
||||
return AttributeKeySanitize(key)
|
||||
}, func(value []string) []string {
|
||||
return value
|
||||
})
|
||||
assert.Equal(t, 1, len(mapped))
|
||||
assert.Equal(t, "foo", mapped[0].Name)
|
||||
assert.Equal(t, []string{"foo", "6"}, mapped[0].Values)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user