1
0
Fork 0
mirror of https://github.com/Luzifer/nginx-sso.git synced 2024-12-21 05:11:17 +00:00
nginx-sso/vendor/github.com/jda/go-crowd/groups_test.go
Knut Ahlers 6fa934880e
Implement Crowd authentication (#2)
* Re-add example configuration for Crowd
* Implement Crowd authentication
* Fix: Some errors just mean there is no user
* Document crowd provider
* Vendor new dependencies
* Reduce error messages: Check for config details
2018-02-04 14:51:08 +01:00

62 lines
1.4 KiB
Go

package crowd
import (
"os"
"testing"
)
func TestGetDirectGroups(t *testing.T) {
tv := PrepVars(t)
c, err := New(tv.AppUsername, tv.AppPassword, tv.AppURL)
if err != nil {
t.Error(err)
}
user := os.Getenv("APP_USER_USERNAME")
if user == "" {
t.Skip("Can't run test because APP_USER_USERNAME undefined")
}
// test new session
groups, err := c.GetDirectGroups(user)
if err != nil {
t.Errorf("Error getting user's direct group membership list: %s\n", err)
} else {
t.Logf("Got user's direct group membership list:")
for _, element := range groups {
t.Logf(" %s", element.Name)
}
}
if len(groups) == 0 {
t.Error("groups list was empty so we didn't get/decode a response from GetIndirectGroups")
}
}
func TestGetNestedGroups(t *testing.T) {
tv := PrepVars(t)
c, err := New(tv.AppUsername, tv.AppPassword, tv.AppURL)
if err != nil {
t.Error(err)
}
user := os.Getenv("APP_USER_USERNAME")
if user == "" {
t.Skip("Can't run test because APP_USER_USERNAME undefined")
}
// test new session
groups, err := c.GetNestedGroups(user)
if err != nil {
t.Errorf("Error getting user's nested group membership list: %s\n", err)
} else {
t.Logf("Got user's nested group membership list:")
for _, element := range groups {
t.Logf(" %s", element.Name)
}
}
if len(groups) == 0 {
t.Error("groups list was empty so we didn't get/decode a response from GetIndirectGroups")
}
}