summaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2020-03-05 07:30:33 +0100
committerGitHub <noreply@github.com>2020-03-05 07:30:33 +0100
commit37c3db7be6dd6fc5ee085979cc5f5dda09d978c3 (patch)
treef77e1d61daaee11f6aab8e491120620e597c2782 /integrations
parentVersions (#10597) (diff)
downloadforgejo-37c3db7be6dd6fc5ee085979cc5f5dda09d978c3.tar.xz
forgejo-37c3db7be6dd6fc5ee085979cc5f5dda09d978c3.zip
Add restricted user filter to LDAP authentication (#10600)
* Add restricted user filter to LDAP authentification * Fix unit test cases
Diffstat (limited to 'integrations')
-rw-r--r--integrations/auth_ldap_test.go30
1 files changed, 19 insertions, 11 deletions
diff --git a/integrations/auth_ldap_test.go b/integrations/auth_ldap_test.go
index 80286c09e6..6c6147f20e 100644
--- a/integrations/auth_ldap_test.go
+++ b/integrations/auth_ldap_test.go
@@ -18,13 +18,14 @@ import (
)
type ldapUser struct {
- UserName string
- Password string
- FullName string
- Email string
- OtherEmails []string
- IsAdmin bool
- SSHKeys []string
+ UserName string
+ Password string
+ FullName string
+ Email string
+ OtherEmails []string
+ IsAdmin bool
+ IsRestricted bool
+ SSHKeys []string
}
var gitLDAPUsers = []ldapUser{
@@ -55,10 +56,11 @@ var gitLDAPUsers = []ldapUser{
Email: "fry@planetexpress.com",
},
{
- UserName: "leela",
- Password: "leela",
- FullName: "Leela Turanga",
- Email: "leela@planetexpress.com",
+ UserName: "leela",
+ Password: "leela",
+ FullName: "Leela Turanga",
+ Email: "leela@planetexpress.com",
+ IsRestricted: true,
},
{
UserName: "bender",
@@ -109,6 +111,7 @@ func addAuthSourceLDAP(t *testing.T, sshKeyAttribute string) {
"user_base": "ou=people,dc=planetexpress,dc=com",
"filter": "(&(objectClass=inetOrgPerson)(memberOf=cn=git,ou=people,dc=planetexpress,dc=com)(uid=%s))",
"admin_filter": "(memberOf=cn=admin_staff,ou=people,dc=planetexpress,dc=com)",
+ "restricted_filter": "(uid=leela)",
"attribute_username": "uid",
"attribute_name": "givenName",
"attribute_surname": "sn",
@@ -173,6 +176,11 @@ func TestLDAPUserSync(t *testing.T) {
} else {
assert.True(t, tds.Find("td:nth-child(5) i").HasClass("fa-square-o"))
}
+ if u.IsRestricted {
+ assert.True(t, tds.Find("td:nth-child(6) i").HasClass("fa-check-square-o"))
+ } else {
+ assert.True(t, tds.Find("td:nth-child(6) i").HasClass("fa-square-o"))
+ }
}
// Check if no users exist