mirror of
https://github.com/Luzifer/nginx-sso.git
synced 2024-12-20 21:01:17 +00:00
6fa934880e
* 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
62 lines
1.4 KiB
Go
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")
|
|
}
|
|
}
|