|
@@ -94,7 +94,7 @@ func TestGetUserFromLDAPApiEndpoint_UserNotFound(t *testing.T) {
|
|
|
sc := getUserFromLDAPContext(t, "/api/admin/ldap/user-that-does-not-exist")
|
|
sc := getUserFromLDAPContext(t, "/api/admin/ldap/user-that-does-not-exist")
|
|
|
|
|
|
|
|
require.Equal(t, sc.resp.Code, http.StatusNotFound)
|
|
require.Equal(t, sc.resp.Code, http.StatusNotFound)
|
|
|
- assert.JSONEq(t, "{\"message\":\"No user was found on the LDAP server(s)\"}", sc.resp.Body.String())
|
|
|
|
|
|
|
+ assert.JSONEq(t, "{\"message\":\"No user was found in the LDAP server(s) with that username\"}", sc.resp.Body.String())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func TestGetUserFromLDAPApiEndpoint_OrgNotfound(t *testing.T) {
|
|
func TestGetUserFromLDAPApiEndpoint_OrgNotfound(t *testing.T) {
|
|
@@ -103,6 +103,7 @@ func TestGetUserFromLDAPApiEndpoint_OrgNotfound(t *testing.T) {
|
|
|
Name: "John Doe",
|
|
Name: "John Doe",
|
|
|
Email: "john.doe@example.com",
|
|
Email: "john.doe@example.com",
|
|
|
Login: "johndoe",
|
|
Login: "johndoe",
|
|
|
|
|
+ Groups: []string{"cn=admins,ou=groups,dc=grafana,dc=org"},
|
|
|
OrgRoles: map[int64]models.RoleType{1: models.ROLE_ADMIN, 2: models.ROLE_VIEWER},
|
|
OrgRoles: map[int64]models.RoleType{1: models.ROLE_ADMIN, 2: models.ROLE_VIEWER},
|
|
|
IsGrafanaAdmin: &isAdmin,
|
|
IsGrafanaAdmin: &isAdmin,
|
|
|
}
|
|
}
|
|
@@ -117,12 +118,12 @@ func TestGetUserFromLDAPApiEndpoint_OrgNotfound(t *testing.T) {
|
|
|
Groups: []*ldap.GroupToOrgRole{
|
|
Groups: []*ldap.GroupToOrgRole{
|
|
|
{
|
|
{
|
|
|
GroupDN: "cn=admins,ou=groups,dc=grafana,dc=org",
|
|
GroupDN: "cn=admins,ou=groups,dc=grafana,dc=org",
|
|
|
- OrgID: 1,
|
|
|
|
|
|
|
+ OrgId: 1,
|
|
|
OrgRole: models.ROLE_ADMIN,
|
|
OrgRole: models.ROLE_ADMIN,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
GroupDN: "cn=admins,ou=groups,dc=grafana2,dc=org",
|
|
GroupDN: "cn=admins,ou=groups,dc=grafana2,dc=org",
|
|
|
- OrgID: 2,
|
|
|
|
|
|
|
+ OrgId: 2,
|
|
|
OrgRole: models.ROLE_VIEWER,
|
|
OrgRole: models.ROLE_VIEWER,
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -164,6 +165,7 @@ func TestGetUserFromLDAPApiEndpoint(t *testing.T) {
|
|
|
Name: "John Doe",
|
|
Name: "John Doe",
|
|
|
Email: "john.doe@example.com",
|
|
Email: "john.doe@example.com",
|
|
|
Login: "johndoe",
|
|
Login: "johndoe",
|
|
|
|
|
+ Groups: []string{"cn=admins,ou=groups,dc=grafana,dc=org", "another-group-not-matched"},
|
|
|
OrgRoles: map[int64]models.RoleType{1: models.ROLE_ADMIN},
|
|
OrgRoles: map[int64]models.RoleType{1: models.ROLE_ADMIN},
|
|
|
IsGrafanaAdmin: &isAdmin,
|
|
IsGrafanaAdmin: &isAdmin,
|
|
|
}
|
|
}
|
|
@@ -178,7 +180,7 @@ func TestGetUserFromLDAPApiEndpoint(t *testing.T) {
|
|
|
Groups: []*ldap.GroupToOrgRole{
|
|
Groups: []*ldap.GroupToOrgRole{
|
|
|
{
|
|
{
|
|
|
GroupDN: "cn=admins,ou=groups,dc=grafana,dc=org",
|
|
GroupDN: "cn=admins,ou=groups,dc=grafana,dc=org",
|
|
|
- OrgID: 1,
|
|
|
|
|
|
|
+ OrgId: 1,
|
|
|
OrgRole: models.ROLE_ADMIN,
|
|
OrgRole: models.ROLE_ADMIN,
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -203,7 +205,7 @@ func TestGetUserFromLDAPApiEndpoint(t *testing.T) {
|
|
|
|
|
|
|
|
sc := getUserFromLDAPContext(t, "/api/admin/ldap/johndoe")
|
|
sc := getUserFromLDAPContext(t, "/api/admin/ldap/johndoe")
|
|
|
|
|
|
|
|
- require.Equal(t, sc.resp.Code, http.StatusOK)
|
|
|
|
|
|
|
+ assert.Equal(t, sc.resp.Code, http.StatusOK)
|
|
|
|
|
|
|
|
expected := `
|
|
expected := `
|
|
|
{
|
|
{
|
|
@@ -222,7 +224,8 @@ func TestGetUserFromLDAPApiEndpoint(t *testing.T) {
|
|
|
"isGrafanaAdmin": true,
|
|
"isGrafanaAdmin": true,
|
|
|
"isDisabled": false,
|
|
"isDisabled": false,
|
|
|
"roles": [
|
|
"roles": [
|
|
|
- { "orgId": 1, "orgRole": "Admin", "orgName": "Main Org.", "groupDN": "cn=admins,ou=groups,dc=grafana,dc=org" }
|
|
|
|
|
|
|
+ { "orgId": 1, "orgRole": "Admin", "orgName": "Main Org.", "groupDN": "cn=admins,ou=groups,dc=grafana,dc=org" },
|
|
|
|
|
+ { "orgId": 0, "orgRole": "", "orgName": "", "groupDN": "another-group-not-matched" }
|
|
|
],
|
|
],
|
|
|
"teams": null
|
|
"teams": null
|
|
|
}
|
|
}
|
|
@@ -251,7 +254,7 @@ func TestGetUserFromLDAPApiEndpoint_WithTeamHandler(t *testing.T) {
|
|
|
Groups: []*ldap.GroupToOrgRole{
|
|
Groups: []*ldap.GroupToOrgRole{
|
|
|
{
|
|
{
|
|
|
GroupDN: "cn=admins,ou=groups,dc=grafana,dc=org",
|
|
GroupDN: "cn=admins,ou=groups,dc=grafana,dc=org",
|
|
|
- OrgID: 1,
|
|
|
|
|
|
|
+ OrgId: 1,
|
|
|
OrgRole: models.ROLE_ADMIN,
|
|
OrgRole: models.ROLE_ADMIN,
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|