Merge pull request #2885 from owncloud/update-graph-api
Change: Update graph api to 0.5.0
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
Change: Update the graph api
|
||||||
|
|
||||||
|
GraphApi has been updated to version 0.4.1 and the existing dependency was removed
|
||||||
|
|
||||||
|
https://github.com/owncloud/ocis/pull/2885
|
||||||
@@ -46,7 +46,7 @@ require (
|
|||||||
github.com/olekukonko/tablewriter v0.0.5
|
github.com/olekukonko/tablewriter v0.0.5
|
||||||
github.com/onsi/ginkgo v1.16.5
|
github.com/onsi/ginkgo v1.16.5
|
||||||
github.com/onsi/gomega v1.17.0
|
github.com/onsi/gomega v1.17.0
|
||||||
github.com/owncloud/libre-graph-api-go v0.3.0
|
github.com/owncloud/libre-graph-api-go v0.5.0
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/prometheus/client_golang v1.11.0
|
github.com/prometheus/client_golang v1.11.0
|
||||||
github.com/rs/zerolog v1.26.1
|
github.com/rs/zerolog v1.26.1
|
||||||
@@ -55,7 +55,6 @@ require (
|
|||||||
github.com/stretchr/testify v1.7.0
|
github.com/stretchr/testify v1.7.0
|
||||||
github.com/thejerf/suture/v4 v4.0.1
|
github.com/thejerf/suture/v4 v4.0.1
|
||||||
github.com/urfave/cli/v2 v2.3.0
|
github.com/urfave/cli/v2 v2.3.0
|
||||||
github.com/yaegashi/msgraph.go v0.1.4
|
|
||||||
go-micro.dev/v4 v4.4.0
|
go-micro.dev/v4 v4.4.0
|
||||||
go.opencensus.io v0.23.0
|
go.opencensus.io v0.23.0
|
||||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.28.0
|
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.28.0
|
||||||
@@ -218,6 +217,7 @@ require (
|
|||||||
github.com/tus/tusd v1.6.0 // indirect
|
github.com/tus/tusd v1.6.0 // indirect
|
||||||
github.com/wk8/go-ordered-map v0.2.0 // indirect
|
github.com/wk8/go-ordered-map v0.2.0 // indirect
|
||||||
github.com/xanzy/ssh-agent v0.3.1 // indirect
|
github.com/xanzy/ssh-agent v0.3.1 // indirect
|
||||||
|
github.com/yaegashi/msgraph.go v0.1.4 // indirect
|
||||||
go.etcd.io/bbolt v1.3.6 // indirect
|
go.etcd.io/bbolt v1.3.6 // indirect
|
||||||
go.etcd.io/etcd/api/v3 v3.5.1 // indirect
|
go.etcd.io/etcd/api/v3 v3.5.1 // indirect
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.1 // indirect
|
go.etcd.io/etcd/client/pkg/v3 v3.5.1 // indirect
|
||||||
|
|||||||
@@ -1052,8 +1052,10 @@ github.com/oracle/oci-go-sdk v24.3.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35uk
|
|||||||
github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc h1:Ak86L+yDSOzKFa7WM5bf5itSOo1e3Xh8bm5YCMUXIjQ=
|
github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc h1:Ak86L+yDSOzKFa7WM5bf5itSOo1e3Xh8bm5YCMUXIjQ=
|
||||||
github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
|
github.com/orcaman/concurrent-map v0.0.0-20210501183033-44dafcb38ecc/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
|
||||||
github.com/ovh/go-ovh v1.1.0/go.mod h1:AxitLZ5HBRPyUd+Zl60Ajaag+rNTdVXWIkzfrVuTXWA=
|
github.com/ovh/go-ovh v1.1.0/go.mod h1:AxitLZ5HBRPyUd+Zl60Ajaag+rNTdVXWIkzfrVuTXWA=
|
||||||
github.com/owncloud/libre-graph-api-go v0.3.0 h1:CjSWuL6Gd+HgIlZfBLjYTloH1F/8naxaL5xZZz4N+ms=
|
github.com/owncloud/libre-graph-api-go v0.4.1 h1:B0y57Em+MEge1EQMCbvOtQS0WxqlaY3qzWPZ8roBNd8=
|
||||||
github.com/owncloud/libre-graph-api-go v0.3.0/go.mod h1:dOt7+kXldpyUGBFdfFBs6PbWElqqa2/Q5+pMF9izL3w=
|
github.com/owncloud/libre-graph-api-go v0.4.1/go.mod h1:dOt7+kXldpyUGBFdfFBs6PbWElqqa2/Q5+pMF9izL3w=
|
||||||
|
github.com/owncloud/libre-graph-api-go v0.5.0 h1:Dgj3W/Ywhi7BluuWNH37ft26eZLBS3jj08x+wAyFW5g=
|
||||||
|
github.com/owncloud/libre-graph-api-go v0.5.0/go.mod h1:dOt7+kXldpyUGBFdfFBs6PbWElqqa2/Q5+pMF9izL3w=
|
||||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
|
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
|
||||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
|
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
|
||||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||||
|
|||||||
@@ -5,36 +5,25 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
cs3 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
cs3 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||||
msgraph "github.com/yaegashi/msgraph.go/beta"
|
libregraph "github.com/owncloud/libre-graph-api-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Backend interface {
|
type Backend interface {
|
||||||
GetUser(ctx context.Context, nameOrId string) (*msgraph.User, error)
|
GetUser(ctx context.Context, nameOrId string) (*libregraph.User, error)
|
||||||
GetUsers(ctx context.Context, queryParam url.Values) ([]*msgraph.User, error)
|
GetUsers(ctx context.Context, queryParam url.Values) ([]*libregraph.User, error)
|
||||||
|
|
||||||
GetGroup(ctx context.Context, nameOrId string) (*msgraph.Group, error)
|
GetGroup(ctx context.Context, nameOrId string) (*libregraph.Group, error)
|
||||||
GetGroups(ctx context.Context, queryParam url.Values) ([]*msgraph.Group, error)
|
GetGroups(ctx context.Context, queryParam url.Values) ([]*libregraph.Group, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateUserModelFromCS3(u *cs3.User) *msgraph.User {
|
func CreateUserModelFromCS3(u *cs3.User) *libregraph.User {
|
||||||
if u.Id == nil {
|
if u.Id == nil {
|
||||||
u.Id = &cs3.UserId{}
|
u.Id = &cs3.UserId{}
|
||||||
}
|
}
|
||||||
return &msgraph.User{
|
return &libregraph.User{
|
||||||
DisplayName: &u.DisplayName,
|
DisplayName: &u.DisplayName,
|
||||||
Mail: &u.Mail,
|
Mail: &u.Mail,
|
||||||
// TODO u.Groups are those ids or group names?
|
|
||||||
OnPremisesSamAccountName: &u.Username,
|
OnPremisesSamAccountName: &u.Username,
|
||||||
DirectoryObject: msgraph.DirectoryObject{
|
Id: &u.Id.OpaqueId,
|
||||||
Entity: msgraph.Entity{
|
|
||||||
ID: &u.Id.OpaqueId,
|
|
||||||
Object: msgraph.Object{
|
|
||||||
AdditionalData: map[string]interface{}{
|
|
||||||
"uidnumber": u.UidNumber,
|
|
||||||
"gidnumber": u.GidNumber,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-14
@@ -8,7 +8,7 @@ import (
|
|||||||
cs3user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
cs3user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||||
cs3rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
|
cs3rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
|
||||||
"github.com/cs3org/reva/pkg/rgrpc/todo/pool"
|
"github.com/cs3org/reva/pkg/rgrpc/todo/pool"
|
||||||
msgraph "github.com/yaegashi/msgraph.go/beta"
|
libregraph "github.com/owncloud/libre-graph-api-go"
|
||||||
|
|
||||||
"github.com/owncloud/ocis/graph/pkg/config"
|
"github.com/owncloud/ocis/graph/pkg/config"
|
||||||
"github.com/owncloud/ocis/graph/pkg/service/v0/errorcode"
|
"github.com/owncloud/ocis/graph/pkg/service/v0/errorcode"
|
||||||
@@ -20,7 +20,7 @@ type CS3 struct {
|
|||||||
Logger *log.Logger
|
Logger *log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *CS3) GetUser(ctx context.Context, userID string) (*msgraph.User, error) {
|
func (i *CS3) GetUser(ctx context.Context, userID string) (*libregraph.User, error) {
|
||||||
client, err := pool.GetGatewayServiceClient(i.Config.Address)
|
client, err := pool.GetGatewayServiceClient(i.Config.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
i.Logger.Error().Err(err).Msg("could not get client")
|
i.Logger.Error().Err(err).Msg("could not get client")
|
||||||
@@ -46,7 +46,7 @@ func (i *CS3) GetUser(ctx context.Context, userID string) (*msgraph.User, error)
|
|||||||
return CreateUserModelFromCS3(res.User), nil
|
return CreateUserModelFromCS3(res.User), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *CS3) GetUsers(ctx context.Context, queryParam url.Values) ([]*msgraph.User, error) {
|
func (i *CS3) GetUsers(ctx context.Context, queryParam url.Values) ([]*libregraph.User, error) {
|
||||||
client, err := pool.GetGatewayServiceClient(i.Config.Address)
|
client, err := pool.GetGatewayServiceClient(i.Config.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
i.Logger.Error().Err(err).Msg("could not get client")
|
i.Logger.Error().Err(err).Msg("could not get client")
|
||||||
@@ -75,7 +75,7 @@ func (i *CS3) GetUsers(ctx context.Context, queryParam url.Values) ([]*msgraph.U
|
|||||||
return nil, errorcode.New(errorcode.GeneralException, res.Status.Message)
|
return nil, errorcode.New(errorcode.GeneralException, res.Status.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
users := make([]*msgraph.User, 0, len(res.Users))
|
users := make([]*libregraph.User, 0, len(res.Users))
|
||||||
|
|
||||||
for _, user := range res.Users {
|
for _, user := range res.Users {
|
||||||
users = append(users, CreateUserModelFromCS3(user))
|
users = append(users, CreateUserModelFromCS3(user))
|
||||||
@@ -84,7 +84,7 @@ func (i *CS3) GetUsers(ctx context.Context, queryParam url.Values) ([]*msgraph.U
|
|||||||
return users, nil
|
return users, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *CS3) GetGroups(ctx context.Context, queryParam url.Values) ([]*msgraph.Group, error) {
|
func (i *CS3) GetGroups(ctx context.Context, queryParam url.Values) ([]*libregraph.Group, error) {
|
||||||
client, err := pool.GetGatewayServiceClient(i.Config.Address)
|
client, err := pool.GetGatewayServiceClient(i.Config.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
i.Logger.Error().Err(err).Msg("could not get client")
|
i.Logger.Error().Err(err).Msg("could not get client")
|
||||||
@@ -114,7 +114,7 @@ func (i *CS3) GetGroups(ctx context.Context, queryParam url.Values) ([]*msgraph.
|
|||||||
return nil, errorcode.New(errorcode.GeneralException, res.Status.Message)
|
return nil, errorcode.New(errorcode.GeneralException, res.Status.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
groups := make([]*msgraph.Group, 0, len(res.Groups))
|
groups := make([]*libregraph.Group, 0, len(res.Groups))
|
||||||
|
|
||||||
for _, group := range res.Groups {
|
for _, group := range res.Groups {
|
||||||
groups = append(groups, createGroupModelFromCS3(group))
|
groups = append(groups, createGroupModelFromCS3(group))
|
||||||
@@ -123,7 +123,7 @@ func (i *CS3) GetGroups(ctx context.Context, queryParam url.Values) ([]*msgraph.
|
|||||||
return groups, nil
|
return groups, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *CS3) GetGroup(ctx context.Context, groupID string) (*msgraph.Group, error) {
|
func (i *CS3) GetGroup(ctx context.Context, groupID string) (*libregraph.Group, error) {
|
||||||
client, err := pool.GetGatewayServiceClient(i.Config.Address)
|
client, err := pool.GetGatewayServiceClient(i.Config.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
i.Logger.Error().Err(err).Msg("could not get client")
|
i.Logger.Error().Err(err).Msg("could not get client")
|
||||||
@@ -150,16 +150,12 @@ func (i *CS3) GetGroup(ctx context.Context, groupID string) (*msgraph.Group, err
|
|||||||
return createGroupModelFromCS3(res.Group), nil
|
return createGroupModelFromCS3(res.Group), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createGroupModelFromCS3(g *cs3group.Group) *msgraph.Group {
|
func createGroupModelFromCS3(g *cs3group.Group) *libregraph.Group {
|
||||||
if g.Id == nil {
|
if g.Id == nil {
|
||||||
g.Id = &cs3group.GroupId{}
|
g.Id = &cs3group.GroupId{}
|
||||||
}
|
}
|
||||||
return &msgraph.Group{
|
return &libregraph.Group{
|
||||||
DirectoryObject: msgraph.DirectoryObject{
|
Id: &g.Id.OpaqueId,
|
||||||
Entity: msgraph.Entity{
|
|
||||||
ID: &g.Id.OpaqueId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
OnPremisesDomainName: &g.Id.Idp,
|
OnPremisesDomainName: &g.Id.Idp,
|
||||||
OnPremisesSamAccountName: &g.GroupName,
|
OnPremisesSamAccountName: &g.GroupName,
|
||||||
DisplayName: &g.DisplayName,
|
DisplayName: &g.DisplayName,
|
||||||
|
|||||||
+13
-21
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/go-ldap/ldap/v3"
|
"github.com/go-ldap/ldap/v3"
|
||||||
msgraph "github.com/yaegashi/msgraph.go/beta"
|
libregraph "github.com/owncloud/libre-graph-api-go"
|
||||||
|
|
||||||
"github.com/owncloud/ocis/graph/pkg/config"
|
"github.com/owncloud/ocis/graph/pkg/config"
|
||||||
"github.com/owncloud/ocis/graph/pkg/service/v0/errorcode"
|
"github.com/owncloud/ocis/graph/pkg/service/v0/errorcode"
|
||||||
@@ -84,7 +84,7 @@ func NewLDAPBackend(lc ldap.Client, config config.LDAP, logger *log.Logger) (*LD
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *LDAP) GetUser(ctx context.Context, userID string) (*msgraph.User, error) {
|
func (i *LDAP) GetUser(ctx context.Context, userID string) (*libregraph.User, error) {
|
||||||
i.logger.Debug().Str("backend", "ldap").Msg("GetUser")
|
i.logger.Debug().Str("backend", "ldap").Msg("GetUser")
|
||||||
userID = ldap.EscapeFilter(userID)
|
userID = ldap.EscapeFilter(userID)
|
||||||
searchRequest := ldap.NewSearchRequest(
|
searchRequest := ldap.NewSearchRequest(
|
||||||
@@ -118,7 +118,7 @@ func (i *LDAP) GetUser(ctx context.Context, userID string) (*msgraph.User, error
|
|||||||
return i.createUserModelFromLDAP(res.Entries[0]), nil
|
return i.createUserModelFromLDAP(res.Entries[0]), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *LDAP) GetUsers(ctx context.Context, queryParam url.Values) ([]*msgraph.User, error) {
|
func (i *LDAP) GetUsers(ctx context.Context, queryParam url.Values) ([]*libregraph.User, error) {
|
||||||
i.logger.Debug().Str("backend", "ldap").Msg("GetUsers")
|
i.logger.Debug().Str("backend", "ldap").Msg("GetUsers")
|
||||||
|
|
||||||
search := queryParam.Get("search")
|
search := queryParam.Get("search")
|
||||||
@@ -153,7 +153,7 @@ func (i *LDAP) GetUsers(ctx context.Context, queryParam url.Values) ([]*msgraph.
|
|||||||
return nil, errorcode.New(errorcode.ItemNotFound, err.Error())
|
return nil, errorcode.New(errorcode.ItemNotFound, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
users := make([]*msgraph.User, 0, len(res.Entries))
|
users := make([]*libregraph.User, 0, len(res.Entries))
|
||||||
|
|
||||||
for _, e := range res.Entries {
|
for _, e := range res.Entries {
|
||||||
users = append(users, i.createUserModelFromLDAP(e))
|
users = append(users, i.createUserModelFromLDAP(e))
|
||||||
@@ -161,7 +161,7 @@ func (i *LDAP) GetUsers(ctx context.Context, queryParam url.Values) ([]*msgraph.
|
|||||||
return users, nil
|
return users, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *LDAP) GetGroup(ctx context.Context, groupID string) (*msgraph.Group, error) {
|
func (i *LDAP) GetGroup(ctx context.Context, groupID string) (*libregraph.Group, error) {
|
||||||
i.logger.Debug().Str("backend", "ldap").Msg("GetGroup")
|
i.logger.Debug().Str("backend", "ldap").Msg("GetGroup")
|
||||||
groupID = ldap.EscapeFilter(groupID)
|
groupID = ldap.EscapeFilter(groupID)
|
||||||
searchRequest := ldap.NewSearchRequest(
|
searchRequest := ldap.NewSearchRequest(
|
||||||
@@ -193,7 +193,7 @@ func (i *LDAP) GetGroup(ctx context.Context, groupID string) (*msgraph.Group, er
|
|||||||
return i.createGroupModelFromLDAP(res.Entries[0]), nil
|
return i.createGroupModelFromLDAP(res.Entries[0]), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *LDAP) GetGroups(ctx context.Context, queryParam url.Values) ([]*msgraph.Group, error) {
|
func (i *LDAP) GetGroups(ctx context.Context, queryParam url.Values) ([]*libregraph.Group, error) {
|
||||||
i.logger.Debug().Str("backend", "ldap").Msg("GetGroups")
|
i.logger.Debug().Str("backend", "ldap").Msg("GetGroups")
|
||||||
|
|
||||||
search := queryParam.Get("search")
|
search := queryParam.Get("search")
|
||||||
@@ -225,7 +225,7 @@ func (i *LDAP) GetGroups(ctx context.Context, queryParam url.Values) ([]*msgraph
|
|||||||
return nil, errorcode.New(errorcode.ItemNotFound, err.Error())
|
return nil, errorcode.New(errorcode.ItemNotFound, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
groups := make([]*msgraph.Group, 0, len(res.Entries))
|
groups := make([]*libregraph.Group, 0, len(res.Entries))
|
||||||
|
|
||||||
for _, e := range res.Entries {
|
for _, e := range res.Entries {
|
||||||
groups = append(groups, i.createGroupModelFromLDAP(e))
|
groups = append(groups, i.createGroupModelFromLDAP(e))
|
||||||
@@ -233,31 +233,23 @@ func (i *LDAP) GetGroups(ctx context.Context, queryParam url.Values) ([]*msgraph
|
|||||||
return groups, nil
|
return groups, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *LDAP) createUserModelFromLDAP(e *ldap.Entry) *msgraph.User {
|
func (i *LDAP) createUserModelFromLDAP(e *ldap.Entry) *libregraph.User {
|
||||||
if e == nil {
|
if e == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &msgraph.User{
|
return &libregraph.User{
|
||||||
DisplayName: pointerOrNil(e.GetEqualFoldAttributeValue(i.userAttributeMap.displayName)),
|
DisplayName: pointerOrNil(e.GetEqualFoldAttributeValue(i.userAttributeMap.displayName)),
|
||||||
Mail: pointerOrNil(e.GetEqualFoldAttributeValue(i.userAttributeMap.mail)),
|
Mail: pointerOrNil(e.GetEqualFoldAttributeValue(i.userAttributeMap.mail)),
|
||||||
OnPremisesSamAccountName: pointerOrNil(e.GetEqualFoldAttributeValue(i.userAttributeMap.userName)),
|
OnPremisesSamAccountName: pointerOrNil(e.GetEqualFoldAttributeValue(i.userAttributeMap.userName)),
|
||||||
DirectoryObject: msgraph.DirectoryObject{
|
Id: pointerOrNil(e.GetEqualFoldAttributeValue(i.userAttributeMap.id)),
|
||||||
Entity: msgraph.Entity{
|
|
||||||
ID: pointerOrNil(e.GetEqualFoldAttributeValue(i.userAttributeMap.id)),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *LDAP) createGroupModelFromLDAP(e *ldap.Entry) *msgraph.Group {
|
func (i *LDAP) createGroupModelFromLDAP(e *ldap.Entry) *libregraph.Group {
|
||||||
return &msgraph.Group{
|
return &libregraph.Group{
|
||||||
DisplayName: pointerOrNil(e.GetEqualFoldAttributeValue(i.groupAttributeMap.name)),
|
DisplayName: pointerOrNil(e.GetEqualFoldAttributeValue(i.groupAttributeMap.name)),
|
||||||
OnPremisesSamAccountName: pointerOrNil(e.GetEqualFoldAttributeValue(i.groupAttributeMap.name)),
|
OnPremisesSamAccountName: pointerOrNil(e.GetEqualFoldAttributeValue(i.groupAttributeMap.name)),
|
||||||
DirectoryObject: msgraph.DirectoryObject{
|
Id: pointerOrNil(e.GetEqualFoldAttributeValue(i.groupAttributeMap.id)),
|
||||||
Entity: msgraph.Entity{
|
|
||||||
ID: pointerOrNil(e.GetEqualFoldAttributeValue(i.groupAttributeMap.id)),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func pointerOrNil(val string) *string {
|
func pointerOrNil(val string) *string {
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ func TestCreateUserModelFromLDAP(t *testing.T) {
|
|||||||
t.Error("Converting a valid LDAP Entry should succeed")
|
t.Error("Converting a valid LDAP Entry should succeed")
|
||||||
} else {
|
} else {
|
||||||
if *user.OnPremisesSamAccountName != userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.userName) {
|
if *user.OnPremisesSamAccountName != userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.userName) {
|
||||||
t.Errorf("Error creating msGraph User from LDAP Entry: %s != %s", *user.OnPremisesSamAccountName, userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.userName))
|
t.Errorf("Error creating msGraph User from LDAP Entry: %v != %v", user.OnPremisesSamAccountName, pointerOrNil(userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.userName)))
|
||||||
}
|
}
|
||||||
if *user.Mail != userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.mail) {
|
if *user.Mail != userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.mail) {
|
||||||
t.Errorf("Error creating msGraph User from LDAP Entry: %s != %s", *user.Mail, userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.mail))
|
t.Errorf("Error creating msGraph User from LDAP Entry: %s != %s", *user.Mail, userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.mail))
|
||||||
@@ -113,8 +113,8 @@ func TestCreateUserModelFromLDAP(t *testing.T) {
|
|||||||
if *user.DisplayName != userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.displayName) {
|
if *user.DisplayName != userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.displayName) {
|
||||||
t.Errorf("Error creating msGraph User from LDAP Entry: %s != %s", *user.DisplayName, userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.displayName))
|
t.Errorf("Error creating msGraph User from LDAP Entry: %s != %s", *user.DisplayName, userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.displayName))
|
||||||
}
|
}
|
||||||
if *user.ID != userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.id) {
|
if *user.Id != userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.id) {
|
||||||
t.Errorf("Error creating msGraph User from LDAP Entry: %s != %s", *user.ID, userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.id))
|
t.Errorf("Error creating msGraph User from LDAP Entry: %s != %s", *user.Id, userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ func TestGetUser(t *testing.T) {
|
|||||||
u, err := b.GetUser(context.Background(), "user")
|
u, err := b.GetUser(context.Background(), "user")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Expected GetUser to succeed. Got %s", err.Error())
|
t.Errorf("Expected GetUser to succeed. Got %s", err.Error())
|
||||||
} else if *u.ID != userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.id) {
|
} else if *u.Id != userEntry.GetEqualFoldAttributeValue(b.userAttributeMap.id) {
|
||||||
t.Errorf("Expected GetUser to return a valid user")
|
t.Errorf("Expected GetUser to return a valid user")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,7 +208,7 @@ func TestGetGroup(t *testing.T) {
|
|||||||
g, err := b.GetGroup(context.Background(), "group")
|
g, err := b.GetGroup(context.Background(), "group")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Expected GetGroup to succeed. Got %s", err.Error())
|
t.Errorf("Expected GetGroup to succeed. Got %s", err.Error())
|
||||||
} else if *g.ID != groupEntry.GetEqualFoldAttributeValue(b.groupAttributeMap.id) {
|
} else if *g.Id != groupEntry.GetEqualFoldAttributeValue(b.groupAttributeMap.id) {
|
||||||
t.Errorf("Expected GetGroup to return a valid group")
|
t.Errorf("Expected GetGroup to return a valid group")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user