mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-07 12:50:21 -06:00
- Implemented delete + some test
This commit is contained in:
committed by
Benedikt Kulmann
parent
901ada3ffc
commit
4428b771bc
@@ -122,23 +122,16 @@ func (r CS3Repo) DeleteAccount(ctx context.Context, id string) (err error) {
|
||||
|
||||
ctx = metadata.AppendToOutgoingContext(ctx, token.TokenHeader, t)
|
||||
|
||||
ureq, err := http.NewRequest("DELETE", fmt.Sprintf("http://localhost:9187/data/accounts/%s", id), nil)
|
||||
_, err = r.storageClient.Delete(ctx, &provider.DeleteRequest{
|
||||
Ref: &provider.Reference{
|
||||
Spec: &provider.Reference_Path{Path: fmt.Sprintf("/meta/accounts/%s", id)},
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ureq.Header.Add("x-access-token", t)
|
||||
cl := http.Client{
|
||||
Transport: http.DefaultTransport,
|
||||
}
|
||||
|
||||
resp, err := cl.Do(ureq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -149,7 +142,6 @@ func (r CS3Repo) DeleteGroup(ctx context.Context, id string) (err error) {
|
||||
}
|
||||
|
||||
ctx = metadata.AppendToOutgoingContext(ctx, token.TokenHeader, t)
|
||||
|
||||
ureq, err := http.NewRequest("DELETE", fmt.Sprintf("http://localhost:9187/data/groups/%s", id), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package storage
|
||||
|
||||
/*
|
||||
func TestFoo(t *testing.T) {
|
||||
import (
|
||||
"context"
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCS3Repo_WriteAccount(t *testing.T) {
|
||||
r, err := NewCS3Repo("fooo")
|
||||
assert.NoError(t, err)
|
||||
|
||||
@@ -15,4 +21,39 @@ func TestFoo(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
*/
|
||||
func TestCS3Repo_LoadAccount(t *testing.T) {
|
||||
r, err := NewCS3Repo("fooo")
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = r.WriteAccount(context.Background(), &proto.Account{
|
||||
Id: "fefef-egegweg-gegeg",
|
||||
AccountEnabled: true,
|
||||
DisplayName: "Mike Jones",
|
||||
Mail: "mike@example.com",
|
||||
})
|
||||
|
||||
acc := &proto.Account{}
|
||||
err = r.LoadAccount(context.Background(), "fefef-egegweg-gegeg", acc)
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "fefef-egegweg-gegeg", acc.Id)
|
||||
assert.Equal(t, "Mike Jones", acc.DisplayName)
|
||||
assert.Equal(t, "mike@example.com", acc.Mail)
|
||||
}
|
||||
|
||||
func TestCS3Repo_DeleteAccount(t *testing.T) {
|
||||
r, err := NewCS3Repo("fooo")
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = r.WriteAccount(context.Background(), &proto.Account{
|
||||
Id: "delete-me-id",
|
||||
AccountEnabled: true,
|
||||
DisplayName: "Mike Jones",
|
||||
Mail: "mike@example.com",
|
||||
})
|
||||
|
||||
err = r.DeleteAccount(context.Background(), "delete-me-id")
|
||||
|
||||
assert.NoError(t, err)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user