mirror of
https://github.com/Luzifer/nginx-sso.git
synced 2024-12-30 09:41:19 +00:00
63 lines
1.4 KiB
Go
63 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")
|
||
|
}
|
||
|
}
|