Merge remote-tracking branch 'origin/main' into feature/guest-links
This commit is contained in:
@@ -114,7 +114,7 @@ func (e ErrorCode) Render(w http.ResponseWriter, r *http.Request, status int, ms
|
||||
|
||||
// CreateOdataError creates and populates a Graph ErrorCode object
|
||||
func (e ErrorCode) CreateOdataError(ctx context.Context, msg string) *libregraph.OdataError {
|
||||
innererror := map[string]interface{}{
|
||||
innererror := map[string]any{
|
||||
"date": time.Now().UTC().Format(time.RFC3339),
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
"github.com/opencloud-eu/opencloud/services/graph/pkg/identity/mocks"
|
||||
libregraph "github.com/opencloud-eu/libre-graph-api-go"
|
||||
"github.com/opencloud-eu/opencloud/services/graph/pkg/identity/mocks"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
@@ -333,7 +333,7 @@ func TestLDAP_UpdateEducationClass(t *testing.T) {
|
||||
modifyDNData modifyDNData
|
||||
modifyData modifyData
|
||||
searchData searchData
|
||||
assertion func(assert.TestingT, error, ...interface{}) bool
|
||||
assertion func(assert.TestingT, error, ...any) bool
|
||||
}{
|
||||
{
|
||||
name: "Change name",
|
||||
@@ -343,7 +343,7 @@ func TestLDAP_UpdateEducationClass(t *testing.T) {
|
||||
DisplayName: "Math-2",
|
||||
},
|
||||
},
|
||||
assertion: func(tt assert.TestingT, err error, i ...interface{}) bool { return assert.Nil(tt, err) },
|
||||
assertion: func(tt assert.TestingT, err error, i ...any) bool { return assert.Nil(tt, err) },
|
||||
modifyData: modifyData{
|
||||
arg: &ldap.ModifyRequest{
|
||||
DN: "openCloudEducationExternalId=Math0123",
|
||||
@@ -377,7 +377,7 @@ func TestLDAP_UpdateEducationClass(t *testing.T) {
|
||||
ExternalId: &externalIDs[0],
|
||||
},
|
||||
},
|
||||
assertion: func(tt assert.TestingT, err error, i ...interface{}) bool { return assert.Nil(tt, err) },
|
||||
assertion: func(tt assert.TestingT, err error, i ...any) bool { return assert.Nil(tt, err) },
|
||||
modifyData: modifyData{
|
||||
arg: &ldap.ModifyRequest{},
|
||||
},
|
||||
@@ -406,7 +406,7 @@ func TestLDAP_UpdateEducationClass(t *testing.T) {
|
||||
ExternalId: &externalIDs[0],
|
||||
},
|
||||
},
|
||||
assertion: func(tt assert.TestingT, err error, i ...interface{}) bool { return assert.Nil(tt, err) },
|
||||
assertion: func(tt assert.TestingT, err error, i ...any) bool { return assert.Nil(tt, err) },
|
||||
modifyData: modifyData{
|
||||
arg: &ldap.ModifyRequest{
|
||||
DN: "openCloudEducationExternalId=Math3210,ou=groups,dc=test",
|
||||
@@ -445,7 +445,7 @@ func TestLDAP_UpdateEducationClass(t *testing.T) {
|
||||
Id: &changeString,
|
||||
},
|
||||
},
|
||||
assertion: func(tt assert.TestingT, err error, i ...interface{}) bool { return assert.Error(tt, err) },
|
||||
assertion: func(tt assert.TestingT, err error, i ...any) bool { return assert.Error(tt, err) },
|
||||
modifyData: modifyData{
|
||||
arg: &ldap.ModifyRequest{},
|
||||
},
|
||||
@@ -468,7 +468,7 @@ func TestLDAP_UpdateEducationClass(t *testing.T) {
|
||||
Description: &changeString,
|
||||
},
|
||||
},
|
||||
assertion: func(tt assert.TestingT, err error, i ...interface{}) bool { return assert.Error(tt, err) },
|
||||
assertion: func(tt assert.TestingT, err error, i ...any) bool { return assert.Error(tt, err) },
|
||||
modifyData: modifyData{
|
||||
arg: &ldap.ModifyRequest{},
|
||||
},
|
||||
@@ -491,7 +491,7 @@ func TestLDAP_UpdateEducationClass(t *testing.T) {
|
||||
Classification: changeString,
|
||||
},
|
||||
},
|
||||
assertion: func(tt assert.TestingT, err error, i ...interface{}) bool { return assert.Error(tt, err) },
|
||||
assertion: func(tt assert.TestingT, err error, i ...any) bool { return assert.Error(tt, err) },
|
||||
modifyData: modifyData{
|
||||
arg: &ldap.ModifyRequest{},
|
||||
},
|
||||
@@ -514,7 +514,7 @@ func TestLDAP_UpdateEducationClass(t *testing.T) {
|
||||
Members: []libregraph.User{*libregraph.NewUser("display name", "username")},
|
||||
},
|
||||
},
|
||||
assertion: func(tt assert.TestingT, err error, i ...interface{}) bool { return assert.Error(tt, err) },
|
||||
assertion: func(tt assert.TestingT, err error, i ...any) bool { return assert.Error(tt, err) },
|
||||
modifyData: modifyData{
|
||||
arg: &ldap.ModifyRequest{},
|
||||
},
|
||||
|
||||
@@ -327,8 +327,8 @@ func TestUpdateGroupName(t *testing.T) {
|
||||
|
||||
type mockInputs struct {
|
||||
funcName string
|
||||
args []interface{}
|
||||
returns []interface{}
|
||||
args []any
|
||||
returns []any
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@@ -343,13 +343,13 @@ func TestUpdateGroupName(t *testing.T) {
|
||||
groupId: "some-uuid-string",
|
||||
newName: "TheGroup",
|
||||
},
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.Nil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
"ou=groups,dc=test",
|
||||
ldap.ScopeWholeSubtree,
|
||||
@@ -359,7 +359,7 @@ func TestUpdateGroupName(t *testing.T) {
|
||||
nil,
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -384,13 +384,13 @@ func TestUpdateGroupName(t *testing.T) {
|
||||
groupId: "some-uuid-string",
|
||||
newName: "TheGroupWithShinyNewName",
|
||||
},
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.Nil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
"ou=groups,dc=test",
|
||||
ldap.ScopeWholeSubtree,
|
||||
@@ -400,7 +400,7 @@ func TestUpdateGroupName(t *testing.T) {
|
||||
nil,
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -419,7 +419,7 @@ func TestUpdateGroupName(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "ModifyDN",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.ModifyDNRequest{
|
||||
DN: groupDn,
|
||||
NewRDN: "cn=TheGroupWithShinyNewName",
|
||||
@@ -428,7 +428,7 @@ func TestUpdateGroupName(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
nil,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -405,8 +405,8 @@ func TestUpdateUser(t *testing.T) {
|
||||
}
|
||||
type mockInputs struct {
|
||||
funcName string
|
||||
args []interface{}
|
||||
returns []interface{}
|
||||
args []any
|
||||
returns []any
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -424,13 +424,13 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: nil,
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.NotNil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
"ou=people,dc=test",
|
||||
ldap.ScopeWholeSubtree,
|
||||
@@ -440,7 +440,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
nil,
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -469,13 +469,13 @@ func TestUpdateUser(t *testing.T) {
|
||||
accountEnabled: nil,
|
||||
userType: &memberType,
|
||||
},
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.Nil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
"ou=people,dc=test",
|
||||
ldap.ScopeWholeSubtree,
|
||||
@@ -485,7 +485,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
nil,
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -516,7 +516,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.SearchRequest{
|
||||
BaseDN: "uid=oldName",
|
||||
Scope: 0,
|
||||
@@ -529,7 +529,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -564,7 +564,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.ModifyRequest{
|
||||
DN: "uid=oldName",
|
||||
Changes: []ldap.Change{
|
||||
@@ -579,7 +579,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
returns: []any{nil},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -599,13 +599,13 @@ func TestUpdateUser(t *testing.T) {
|
||||
accountEnabled: nil,
|
||||
userType: &memberType,
|
||||
},
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.Nil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
"ou=people,dc=test",
|
||||
ldap.ScopeWholeSubtree,
|
||||
@@ -615,7 +615,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
nil,
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -646,7 +646,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.SearchRequest{
|
||||
BaseDN: "uid=oldName",
|
||||
Scope: 0,
|
||||
@@ -659,7 +659,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -694,7 +694,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.ModifyRequest{
|
||||
DN: "uid=oldName",
|
||||
Changes: []ldap.Change{
|
||||
@@ -709,7 +709,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
returns: []any{nil},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -729,13 +729,13 @@ func TestUpdateUser(t *testing.T) {
|
||||
accountEnabled: nil,
|
||||
userType: &memberType,
|
||||
},
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.Nil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
"ou=people,dc=test",
|
||||
ldap.ScopeWholeSubtree,
|
||||
@@ -745,7 +745,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
nil,
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -780,7 +780,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.SearchRequest{
|
||||
BaseDN: "ou=groups,dc=test",
|
||||
Scope: 2, DerefAliases: 0, SizeLimit: 0, TimeLimit: 0,
|
||||
@@ -790,7 +790,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -813,7 +813,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "ModifyDN",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.ModifyDNRequest{
|
||||
DN: "uid=oldName,ou=people,dc=test,dc=net",
|
||||
NewRDN: "uid=newName",
|
||||
@@ -822,13 +822,13 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.SearchRequest{
|
||||
BaseDN: "uid=newName,ou=people,dc=test,dc=net",
|
||||
Scope: 0,
|
||||
@@ -841,7 +841,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -876,7 +876,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.ModifyRequest{
|
||||
DN: "cn=group1",
|
||||
Changes: []ldap.Change{
|
||||
@@ -898,7 +898,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
returns: []any{nil},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -919,13 +919,13 @@ func TestUpdateUser(t *testing.T) {
|
||||
accountEnabled: &falseBool,
|
||||
userType: &memberType,
|
||||
},
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.Nil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
"ou=people,dc=test",
|
||||
ldap.ScopeWholeSubtree,
|
||||
@@ -935,7 +935,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
nil,
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -966,7 +966,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.SearchRequest{
|
||||
BaseDN: "uid=name",
|
||||
Scope: 0,
|
||||
@@ -979,7 +979,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -1014,7 +1014,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.ModifyRequest{
|
||||
DN: "uid=name",
|
||||
Changes: []ldap.Change{
|
||||
@@ -1029,7 +1029,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
returns: []any{nil},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1050,13 +1050,13 @@ func TestUpdateUser(t *testing.T) {
|
||||
accountEnabled: &falseBool,
|
||||
userType: &memberType,
|
||||
},
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.Nil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
"ou=people,dc=test",
|
||||
ldap.ScopeWholeSubtree,
|
||||
@@ -1066,7 +1066,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
nil,
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -1097,7 +1097,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.SearchRequest{
|
||||
BaseDN: disableUsersGroup,
|
||||
Scope: 0,
|
||||
@@ -1110,7 +1110,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -1129,7 +1129,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.ModifyRequest{
|
||||
DN: "uid=name",
|
||||
Changes: []ldap.Change{
|
||||
@@ -1144,22 +1144,22 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
returns: []any{nil},
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.ModifyRequest{
|
||||
DN: "uid=name",
|
||||
Changes: []ldap.Change(nil),
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
returns: []any{nil},
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
"uid=name",
|
||||
ldap.ScopeBaseObject,
|
||||
@@ -1169,7 +1169,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
[]ldap.Control(nil),
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -1217,13 +1217,13 @@ func TestUpdateUser(t *testing.T) {
|
||||
accountEnabled: &trueBool,
|
||||
userType: &memberType,
|
||||
},
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.Nil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
"ou=people,dc=test",
|
||||
ldap.ScopeWholeSubtree,
|
||||
@@ -1233,7 +1233,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
nil,
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -1264,7 +1264,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.SearchRequest{
|
||||
BaseDN: disableUsersGroup,
|
||||
Scope: 0,
|
||||
@@ -1277,7 +1277,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -1296,7 +1296,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.ModifyRequest{
|
||||
DN: "uid=name",
|
||||
Changes: []ldap.Change{
|
||||
@@ -1311,22 +1311,22 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
returns: []any{nil},
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.ModifyRequest{
|
||||
DN: "uid=name",
|
||||
Changes: []ldap.Change(nil),
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
returns: []any{nil},
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
"uid=name",
|
||||
ldap.ScopeBaseObject,
|
||||
@@ -1336,7 +1336,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
[]ldap.Control(nil),
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -1383,13 +1383,13 @@ func TestUpdateUser(t *testing.T) {
|
||||
onPremisesSamAccountName: "testUser",
|
||||
userType: &memberType,
|
||||
},
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.Nil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
"ou=people,dc=test",
|
||||
ldap.ScopeWholeSubtree,
|
||||
@@ -1399,7 +1399,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
nil,
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -1430,7 +1430,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.ModifyRequest{
|
||||
DN: "uid=name",
|
||||
Changes: []ldap.Change{
|
||||
@@ -1445,22 +1445,22 @@ func TestUpdateUser(t *testing.T) {
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
returns: []any{nil},
|
||||
},
|
||||
{
|
||||
funcName: "Modify",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
&ldap.ModifyRequest{
|
||||
DN: "uid=name",
|
||||
Changes: []ldap.Change(nil),
|
||||
Controls: []ldap.Control(nil),
|
||||
},
|
||||
},
|
||||
returns: []interface{}{nil},
|
||||
returns: []any{nil},
|
||||
},
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
"uid=name",
|
||||
ldap.ScopeBaseObject,
|
||||
@@ -1470,7 +1470,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
[]ldap.Control(nil),
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -1588,8 +1588,8 @@ func TestUsersEnabledState(t *testing.T) {
|
||||
}
|
||||
type mockInputs struct {
|
||||
funcName string
|
||||
args []interface{}
|
||||
returns []interface{}
|
||||
args []any
|
||||
returns []any
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -1606,7 +1606,7 @@ func TestUsersEnabledState(t *testing.T) {
|
||||
disableUserMechanism: "attribute",
|
||||
},
|
||||
want: map[string]bool{},
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.Nil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{},
|
||||
@@ -1619,7 +1619,7 @@ func TestUsersEnabledState(t *testing.T) {
|
||||
disableUserMechanism: "attribute",
|
||||
},
|
||||
want: map[string]bool{"alice": true, "bob": false, "carol": true},
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.Nil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{},
|
||||
@@ -1632,13 +1632,13 @@ func TestUsersEnabledState(t *testing.T) {
|
||||
disableUserMechanism: "group",
|
||||
},
|
||||
want: map[string]bool{"alice": true, "bob": true, "carol": true},
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.Nil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
disableUsersGroup,
|
||||
ldap.ScopeBaseObject,
|
||||
@@ -1648,7 +1648,7 @@ func TestUsersEnabledState(t *testing.T) {
|
||||
[]ldap.Control(nil),
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -1675,13 +1675,13 @@ func TestUsersEnabledState(t *testing.T) {
|
||||
disableUserMechanism: "group",
|
||||
},
|
||||
want: map[string]bool{"alice": false, "bob": true, "carol": false},
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.Nil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
disableUsersGroup,
|
||||
ldap.ScopeBaseObject,
|
||||
@@ -1691,7 +1691,7 @@ func TestUsersEnabledState(t *testing.T) {
|
||||
[]ldap.Control(nil),
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
&ldap.SearchResult{
|
||||
Entries: []*ldap.Entry{
|
||||
{
|
||||
@@ -1718,13 +1718,13 @@ func TestUsersEnabledState(t *testing.T) {
|
||||
disableUserMechanism: "group",
|
||||
},
|
||||
want: nil,
|
||||
assertion: func(t assert.TestingT, err error, args ...interface{}) bool {
|
||||
assertion: func(t assert.TestingT, err error, args ...any) bool {
|
||||
return assert.NotNil(t, err, args...)
|
||||
},
|
||||
ldapMocks: []mockInputs{
|
||||
{
|
||||
funcName: "Search",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
ldap.NewSearchRequest(
|
||||
disableUsersGroup,
|
||||
ldap.ScopeBaseObject,
|
||||
@@ -1734,7 +1734,7 @@ func TestUsersEnabledState(t *testing.T) {
|
||||
[]ldap.Control(nil),
|
||||
),
|
||||
},
|
||||
returns: []interface{}{
|
||||
returns: []any{
|
||||
nil,
|
||||
&ldap.Error{
|
||||
Err: fmt.Errorf("very problematic problems"),
|
||||
|
||||
@@ -32,7 +32,7 @@ func Auth(opts ...account.Option) func(http.Handler) http.Handler {
|
||||
// Note: This largely duplicates what pkg/middleware/account.go already does (apart from a slightly different error
|
||||
// handling). Ideally we should merge both middlewares.
|
||||
opt := authOptions(opts...)
|
||||
tokenManager, err := jwt.New(map[string]interface{}{
|
||||
tokenManager, err := jwt.New(map[string]any{
|
||||
"secret": opt.JWTSecret,
|
||||
"expires": int64(24 * 60 * 60),
|
||||
})
|
||||
|
||||
@@ -678,7 +678,7 @@ func (api DriveItemPermissionsApi) Invite(w http.ResponseWriter, r *http.Request
|
||||
}
|
||||
|
||||
render.Status(r, http.StatusOK)
|
||||
render.JSON(w, r, &ListResponse{Value: []interface{}{permission}})
|
||||
render.JSON(w, r, &ListResponse{Value: []any{permission}})
|
||||
}
|
||||
|
||||
// SpaceRootInvite handles DriveItemInvite requests on a space root
|
||||
@@ -711,7 +711,7 @@ func (api DriveItemPermissionsApi) SpaceRootInvite(w http.ResponseWriter, r *htt
|
||||
}
|
||||
|
||||
render.Status(r, http.StatusOK)
|
||||
render.JSON(w, r, &ListResponse{Value: []interface{}{permission}})
|
||||
render.JSON(w, r, &ListResponse{Value: []any{permission}})
|
||||
}
|
||||
|
||||
// ListPermissions handles ListPermissions requests
|
||||
|
||||
@@ -158,7 +158,7 @@ var _ = Describe("EducationClass", func() {
|
||||
res := service.ListResponse{}
|
||||
err = json.Unmarshal(data, &res)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(res.Value).To(Equal([]interface{}{}))
|
||||
Expect(res.Value).To(Equal([]any{}))
|
||||
})
|
||||
|
||||
It("renders a list of classes", func() {
|
||||
|
||||
@@ -157,7 +157,7 @@ var _ = Describe("Schools", func() {
|
||||
res := service.ListResponse{}
|
||||
err = json.Unmarshal(data, &res)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(res.Value).To(Equal([]interface{}{}))
|
||||
Expect(res.Value).To(Equal([]any{}))
|
||||
})
|
||||
|
||||
It("renders a list of schools", func() {
|
||||
|
||||
@@ -12,6 +12,8 @@ import (
|
||||
"github.com/opencloud-eu/reva/v2/pkg/events"
|
||||
)
|
||||
|
||||
const _favoriteLabel = "favorite"
|
||||
|
||||
// FollowDriveItem marks a drive item as favorite.
|
||||
func (g Graph) FollowDriveItem(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
@@ -59,34 +61,36 @@ func (g Graph) FollowDriveItem(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
req := &provider.AddFavoriteRequest{
|
||||
req := &provider.AddLabelRequest{
|
||||
Ref: ref,
|
||||
UserId: u.Id,
|
||||
Label: _favoriteLabel,
|
||||
}
|
||||
|
||||
res, err := gatewayClient.AddFavorite(ctx, req)
|
||||
res, err := gatewayClient.AddLabel(ctx, req)
|
||||
if err != nil {
|
||||
g.logger.Error().Err(err).Msg("could not add favorite")
|
||||
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, "could not add favorite")
|
||||
g.logger.Error().Err(err).Msg("could not add label")
|
||||
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, "could not add label")
|
||||
return
|
||||
}
|
||||
|
||||
if res.Status.Code != rpc.Code_CODE_OK {
|
||||
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, "could not add favorite")
|
||||
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, "could not add label")
|
||||
return
|
||||
}
|
||||
|
||||
if g.eventsPublisher != nil {
|
||||
ev := events.FavoriteAdded{
|
||||
ev := events.LabelAdded{
|
||||
Ref: &provider.Reference{
|
||||
ResourceId: &itemID,
|
||||
Path: ".",
|
||||
},
|
||||
Label: _favoriteLabel,
|
||||
UserID: u.Id,
|
||||
Executant: revaCtx.ContextMustGetUser(r.Context()).Id,
|
||||
}
|
||||
if err := events.Publish(r.Context(), g.eventsPublisher, ev); err != nil {
|
||||
g.logger.Error().Err(err).Msg("Failed to publish FavoriteAdded event")
|
||||
g.logger.Error().Err(err).Msg("Failed to publish LabelAdded event")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,15 +130,16 @@ func (g Graph) UnfollowDriveItem(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
req := &provider.RemoveFavoriteRequest{
|
||||
req := &provider.RemoveLabelRequest{
|
||||
Ref: ref,
|
||||
UserId: u.Id,
|
||||
Label: _favoriteLabel,
|
||||
}
|
||||
|
||||
res, err := gatewayClient.RemoveFavorite(ctx, req)
|
||||
res, err := gatewayClient.RemoveLabel(ctx, req)
|
||||
if err != nil {
|
||||
g.logger.Error().Err(err).Msg("could not remove favorite")
|
||||
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, "could not remove favorite")
|
||||
g.logger.Error().Err(err).Msg("could not remove label")
|
||||
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, "could not remove label")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -150,16 +155,17 @@ func (g Graph) UnfollowDriveItem(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if g.eventsPublisher != nil {
|
||||
ev := events.FavoriteRemoved{
|
||||
ev := events.LabelRemoved{
|
||||
Ref: &provider.Reference{
|
||||
ResourceId: &itemID,
|
||||
Path: ".",
|
||||
},
|
||||
Label: _favoriteLabel,
|
||||
UserID: u.Id,
|
||||
Executant: revaCtx.ContextMustGetUser(r.Context()).Id,
|
||||
}
|
||||
if err := events.Publish(r.Context(), g.eventsPublisher, ev); err != nil {
|
||||
g.logger.Error().Err(err).Msg("Failed to publish FavoriteRemoved event")
|
||||
g.logger.Error().Err(err).Msg("Failed to publish LabelRemoved event")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ type Graph struct {
|
||||
roleService RoleService
|
||||
permissionsService Permissions
|
||||
valueService settingssvc.ValueService
|
||||
specialDriveItemsCache *ttlcache.Cache[string, interface{}]
|
||||
specialDriveItemsCache *ttlcache.Cache[string, any]
|
||||
eventsPublisher events.Publisher
|
||||
eventsConsumer events.Consumer
|
||||
searchService searchsvc.SearchProviderService
|
||||
@@ -83,7 +83,7 @@ func (g Graph) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
g.mux.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
func (g Graph) publishEvent(ctx context.Context, ev interface{}) {
|
||||
func (g Graph) publishEvent(ctx context.Context, ev any) {
|
||||
if g.eventsPublisher != nil {
|
||||
if err := events.Publish(ctx, g.eventsPublisher, ev); err != nil {
|
||||
g.logger.Error().
|
||||
@@ -104,7 +104,7 @@ func (g Graph) getWebDavBaseURL() (*url.URL, error) {
|
||||
|
||||
// ListResponse is used for proper marshalling of Graph list responses
|
||||
type ListResponse struct {
|
||||
Value interface{} `json:"value,omitempty"`
|
||||
Value any `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@@ -188,7 +188,7 @@ var _ = Describe("Groups", func() {
|
||||
res := service.ListResponse{}
|
||||
err = json.Unmarshal(data, &res)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(res.Value).To(Equal([]interface{}{}))
|
||||
Expect(res.Value).To(Equal([]any{}))
|
||||
})
|
||||
|
||||
It("renders a list of groups", func() {
|
||||
|
||||
@@ -150,7 +150,7 @@ func (g Graph) GatherPersonalData(usr *user.User, ref *provider.Reference, token
|
||||
g.logger.Error().Err(err).Str("userID", usr.GetId().GetOpaqueId()).Msg("cannot impersonate user")
|
||||
}
|
||||
// create data
|
||||
data := make(map[string]interface{})
|
||||
data := make(map[string]any)
|
||||
|
||||
// reva user
|
||||
data["user"] = usr
|
||||
@@ -316,12 +316,12 @@ func getLocation(r *http.Request) string {
|
||||
}
|
||||
|
||||
// we want the events to look nice in the file, don't we?
|
||||
func convertEvents(evs []*ehmsg.Event) []map[string]interface{} {
|
||||
out := make([]map[string]interface{}, len(evs))
|
||||
func convertEvents(evs []*ehmsg.Event) []map[string]any {
|
||||
out := make([]map[string]any, len(evs))
|
||||
for i, e := range evs {
|
||||
var content map[string]interface{}
|
||||
var content map[string]any
|
||||
_ = json.Unmarshal(e.GetEvent(), &content)
|
||||
out[i] = map[string]interface{}{
|
||||
out[i] = map[string]any{
|
||||
"id": e.GetId(),
|
||||
"type": e.GetType(),
|
||||
"event": content,
|
||||
|
||||
@@ -141,10 +141,10 @@ func NewService(opts ...Option) (Graph, error) { //nolint:maintidx
|
||||
)
|
||||
|
||||
spacePropertiesCache := ttlcache.New(
|
||||
ttlcache.WithTTL[string, interface{}](
|
||||
ttlcache.WithTTL[string, any](
|
||||
time.Duration(options.Config.Spaces.ExtendedSpacePropertiesCacheTTL),
|
||||
),
|
||||
ttlcache.WithDisableTouchOnHit[string, interface{}](),
|
||||
ttlcache.WithDisableTouchOnHit[string, any](),
|
||||
)
|
||||
go spacePropertiesCache.Start()
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
// StrictJSONUnmarshal is a wrapper around json.Unmarshal that returns an error if the json contains unknown fields.
|
||||
func StrictJSONUnmarshal(r io.Reader, v interface{}) error {
|
||||
func StrictJSONUnmarshal(r io.Reader, v any) error {
|
||||
dec := json.NewDecoder(r)
|
||||
dec.DisallowUnknownFields()
|
||||
return dec.Decode(v)
|
||||
|
||||
@@ -21,6 +21,6 @@ func init() {
|
||||
func Default() *validator.Validate { return defaultValidator.Load().(*validator.Validate) }
|
||||
|
||||
// StructCtx validates a struct and returns the error.
|
||||
func StructCtx(ctx context.Context, s interface{}) error {
|
||||
func StructCtx(ctx context.Context, s any) error {
|
||||
return Default().StructCtx(ctx, s)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user