From 35a11dda7e81f80834465d4d45e76eaab45beabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 7 Dec 2021 16:16:54 +0000 Subject: [PATCH] fix ocs unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- ocs/pkg/server/http/svc_test.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/ocs/pkg/server/http/svc_test.go b/ocs/pkg/server/http/svc_test.go index 0e432054bb2..ec50679b6ab 100644 --- a/ocs/pkg/server/http/svc_test.go +++ b/ocs/pkg/server/http/svc_test.go @@ -482,6 +482,22 @@ func assertUsersSame(t *testing.T, expected, actual User, quotaAvailable bool) { } } +func findAccount(t *testing.T, username string) (*accountsProto.Account, error) { + cl := accountsProto.NewAccountsService("com.owncloud.api.accounts", service.Client()) + + req := &accountsProto.ListAccountsRequest{ + Query: "preferred_name eq '" + username + "'", + } + res, err := cl.ListAccounts(context.Background(), req) + if err != nil { + return nil, err + } + if len(res.Accounts) == 0 { + return nil, fmt.Errorf("username %s not found", username) + } + return res.Accounts[0], err +} + func deleteAccount(t *testing.T, id string) (*empty.Empty, error) { cl := accountsProto.NewAccountsService("com.owncloud.api.accounts", service.Client()) @@ -1435,12 +1451,17 @@ func TestGetSingleUser(t *testing.T) { t.Fatal(err) } + a, err := findAccount(t, user.ID) + if err != nil { + t.Fatal(err) + } + formatpart := getFormatString(format) res, err := sendRequest( "GET", fmt.Sprintf("/%v/cloud/user%v", ocsVersion, formatpart), "", - &User{ID: user.ID}, + &User{ID: a.Id}, []string{ssvc.BundleUUIDRoleUser}, )