LDAP: nitpicks (#18309)

* LDAP: nitpicks

* Add more tests

* Correct and clarify comment for Login() method

* Rename methods (hail consistency!)

* Uppercases first letter of the logs everywhere

* Moves method definitions around to more appropriate places

Fixes #18295
This commit is contained in:
Oleg Gaidarenko
2019-08-02 19:24:44 +03:00
committed by GitHub
parent 3063ef6c2a
commit fb273cb874
3 changed files with 108 additions and 59 deletions

View File

@ -182,7 +182,7 @@ func TestLDAPPrivateMethods(t *testing.T) {
})
})
Convey("shouldAuthAdmin()", t, func() {
Convey("shouldAdminBind()", t, func() {
Convey("it should require admin userBind", func() {
server := &Server{
Config: &ServerConfig{
@ -190,7 +190,7 @@ func TestLDAPPrivateMethods(t *testing.T) {
},
}
result := server.shouldAuthAdmin()
result := server.shouldAdminBind()
So(result, ShouldBeTrue)
})
@ -201,9 +201,46 @@ func TestLDAPPrivateMethods(t *testing.T) {
},
}
result := server.shouldAuthAdmin()
result := server.shouldAdminBind()
So(result, ShouldBeFalse)
})
})
Convey("shouldSingleBind()", t, func() {
Convey("it should allow single bind", func() {
server := &Server{
Config: &ServerConfig{
BindDN: "cn=%s,dc=grafana,dc=org",
},
}
result := server.shouldSingleBind()
So(result, ShouldBeTrue)
})
Convey("it should not allow single bind", func() {
server := &Server{
Config: &ServerConfig{
BindDN: "cn=admin,dc=grafana,dc=org",
},
}
result := server.shouldSingleBind()
So(result, ShouldBeFalse)
})
})
Convey("singleBindDN()", t, func() {
Convey("it should allow single bind", func() {
server := &Server{
Config: &ServerConfig{
BindDN: "cn=%s,dc=grafana,dc=org",
},
}
result := server.singleBindDN("test")
So(result, ShouldEqual, "cn=test,dc=grafana,dc=org")
})
})
}