accounts running
This commit is contained in:
@@ -180,7 +180,7 @@ The following sections list the changes in ocis-accounts 0.3.0.
|
||||
adjusts ocis-accounts accordingly.
|
||||
|
||||
https://github.com/owncloud/ocis/accounts/pull/87
|
||||
https://github.com/owncloud/ocis-settings/pull/46
|
||||
https://github.com/owncloud/ocis/settings/pull/46
|
||||
|
||||
|
||||
* Change - Add permissions for language to default roles: [#88](https://github.com/owncloud/ocis/accounts/pull/88)
|
||||
|
||||
@@ -3,4 +3,4 @@ Change: Adapt to new ocis-settings data model
|
||||
ocis-settings introduced UUIDs and less verbose endpoint and message type names. This PR adjusts ocis-accounts accordingly.
|
||||
|
||||
https://github.com/owncloud/ocis/accounts/pull/87
|
||||
https://github.com/owncloud/ocis-settings/pull/46
|
||||
https://github.com/owncloud/ocis/settings/pull/46
|
||||
|
||||
+7
-3
@@ -15,8 +15,8 @@ require (
|
||||
github.com/oklog/run v1.1.0
|
||||
github.com/olekukonko/tablewriter v0.0.4
|
||||
github.com/owncloud/ocis v1.0.0-rc1 // indirect
|
||||
github.com/owncloud/ocis-pkg/v2 v2.4.1-0.20200902134813-1e87c6173ada
|
||||
github.com/owncloud/ocis-settings v0.3.2-0.20200903035407-ad5de8264f91
|
||||
github.com/owncloud/ocis/ocis-pkg v0.0.0-20200918114005-1a0ddd2190ee
|
||||
github.com/owncloud/ocis/settings v0.0.0-20200918114005-1a0ddd2190ee
|
||||
github.com/restic/calens v0.2.0
|
||||
github.com/rs/zerolog v1.19.0
|
||||
github.com/spf13/viper v1.7.0
|
||||
@@ -27,4 +27,8 @@ require (
|
||||
google.golang.org/protobuf v1.25.0
|
||||
)
|
||||
|
||||
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0
|
||||
replace (
|
||||
github.com/owncloud/ocis/ocis-pkg => ../ocis-pkg
|
||||
github.com/owncloud/ocis/settings => ../settings
|
||||
google.golang.org/grpc => google.golang.org/grpc v1.26.0
|
||||
)
|
||||
|
||||
@@ -1212,6 +1212,7 @@ github.com/owncloud/flaex v0.2.0 h1:3FLf8oyMgA6HLK7w4+VJ5N1oVA8G7MptLCVjfxxIaww=
|
||||
github.com/owncloud/flaex v0.2.0/go.mod h1:jip86t4OVURJTf8CM/0e2qcji/Y4NG3l2lR8kex4JWw=
|
||||
github.com/owncloud/ocis v1.0.0-rc1 h1:5pxFes3myh5cwfvyZ0l6akN9wneSc9UxB5Veg2Xr1Rc=
|
||||
github.com/owncloud/ocis v1.0.0-rc1/go.mod h1:TmghyYp0UgfxWlJobYshsOzJ3i99+OaTYxmbiHPIxDo=
|
||||
github.com/owncloud/ocis v1.0.0-rc1.0.20200918114005-1a0ddd2190ee h1:EXT7AIO8bc6HEcnvybGQUkzRXin2KagJBpuv12oZksM=
|
||||
github.com/owncloud/ocis-accounts v0.1.2-0.20200618163128-aa8ae58dd95e/go.mod h1:ohb58AUSUgq+kPOFAjy1s1k5Bi33YtPg45qOOPsepeM=
|
||||
github.com/owncloud/ocis-accounts v0.1.2-0.20200710152724-fa35a81beb2f/go.mod h1:wxo2B5EoTQlf3ryDeOTR/RAs3z6IHkllu1CvBxrLf1A=
|
||||
github.com/owncloud/ocis-accounts v0.4.2-0.20200828150703-2ca83cf4ac20/go.mod h1:R2mNcvDvma7D7n1yxpLHIJR9dHUx4As7QfiJlD8e9DE=
|
||||
@@ -1243,6 +1244,7 @@ github.com/owncloud/ocis-pkg/v2 v2.2.2-0.20200527082518-5641fa4a4c8c/go.mod h1:s
|
||||
github.com/owncloud/ocis-pkg/v2 v2.2.2-0.20200602070144-cd0620668170/go.mod h1:s894msGwDsULmsROHkbsXFCP/eSqDcteDFUntZOiJdc=
|
||||
github.com/owncloud/ocis-pkg/v2 v2.3.0/go.mod h1:FSzIvhx9HcZcq4jgNaDowNvM7PTX/XCyoMvyfzidUpE=
|
||||
github.com/owncloud/ocis-pkg/v2 v2.4.0/go.mod h1:FSzIvhx9HcZcq4jgNaDowNvM7PTX/XCyoMvyfzidUpE=
|
||||
github.com/owncloud/ocis-pkg/v2 v2.4.1-0.20200828095914-d3b859484b2b h1:PRw0b4abdrDKloh417qPsS5lkB/bjJ3Rc4txzHx/hBg=
|
||||
github.com/owncloud/ocis-pkg/v2 v2.4.1-0.20200828095914-d3b859484b2b/go.mod h1:WdcVM54z0X7aQzS8eyGl7S5sjEMVBtLpfpzsPX3Z+Pw=
|
||||
github.com/owncloud/ocis-pkg/v2 v2.4.1-0.20200902134813-1e87c6173ada h1:iVknnuT/z8QCAeBpHEcbI/AiQ9FOBvF5aOAFT3TIM+I=
|
||||
github.com/owncloud/ocis-pkg/v2 v2.4.1-0.20200902134813-1e87c6173ada/go.mod h1:WdcVM54z0X7aQzS8eyGl7S5sjEMVBtLpfpzsPX3Z+Pw=
|
||||
@@ -1268,6 +1270,8 @@ github.com/owncloud/ocis-thumbnails v0.3.0 h1:As0wiSXwDp9JgK/FPY5h1J9HXEow9EFefg
|
||||
github.com/owncloud/ocis-thumbnails v0.3.0/go.mod h1:97QGLawjcpbhSIscbPXJAytE6vAQi5Y+Ov55h8/mq+0=
|
||||
github.com/owncloud/ocis-webdav v0.1.1 h1:4UN9GefQiH6RGgq2+tiYFLNw8ql6luXYH0NdCJg2n/U=
|
||||
github.com/owncloud/ocis-webdav v0.1.1/go.mod h1:E9OlGfvlxf1NHFOvFgbHWBe7/pw4Gqy/JaSJFEHQSzg=
|
||||
github.com/owncloud/ocis/settings v0.0.0-20200918114005-1a0ddd2190ee h1:LaKP3hCTJ6WwB3W40m5UhddvokMRIbOXrjogxON4jAI=
|
||||
github.com/owncloud/ocis/settings v0.0.0-20200918114005-1a0ddd2190ee/go.mod h1:5w91idmyOd8LgYK3eGuqsFBOfVJnSDeEp7S6dHheW14=
|
||||
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/parnurzeal/gorequest v0.2.15/go.mod h1:3Kh2QUMJoqw3icWAecsyzkpY7UzRfDhbRdTjtNwNiUE=
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"path"
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
|
||||
// Fake the import to make the dep tree happy.
|
||||
_ "golang.org/x/net/context"
|
||||
|
||||
@@ -2,7 +2,7 @@ package assets
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/version"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ import (
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
svc "github.com/owncloud/ocis/accounts/pkg/service/v0"
|
||||
"github.com/owncloud/ocis-pkg/v2/service/grpc"
|
||||
settings "github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"google.golang.org/genproto/protobuf/field_mask"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/metrics"
|
||||
svc "github.com/owncloud/ocis/accounts/pkg/service/v0"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
|
||||
@@ -2,7 +2,7 @@ package grpc
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis-pkg/v2/service/grpc"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
)
|
||||
|
||||
// Server initializes a new go-micro service ready to run
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/metrics"
|
||||
svc "github.com/owncloud/ocis/accounts/pkg/service/v0"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"github.com/owncloud/ocis/accounts/pkg/assets"
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/accounts/pkg/version"
|
||||
"github.com/owncloud/ocis-pkg/v2/account"
|
||||
"github.com/owncloud/ocis-pkg/v2/middleware"
|
||||
"github.com/owncloud/ocis-pkg/v2/service/http"
|
||||
"github.com/owncloud/ocis/ocis-pkg/account"
|
||||
"github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/http"
|
||||
)
|
||||
|
||||
// Server initializes the http service and server.
|
||||
|
||||
@@ -19,9 +19,9 @@ import (
|
||||
merrors "github.com/micro/go-micro/v2/errors"
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/accounts/pkg/provider"
|
||||
"github.com/owncloud/ocis-pkg/v2/roles"
|
||||
settings "github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
settings_svc "github.com/owncloud/ocis-settings/pkg/service/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/roles"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settings_svc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
"github.com/rs/zerolog"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"google.golang.org/genproto/protobuf/field_mask"
|
||||
|
||||
@@ -1,366 +1,366 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
"github.com/micro/go-micro/v2/client"
|
||||
merrors "github.com/micro/go-micro/v2/errors"
|
||||
"github.com/micro/go-micro/v2/metadata"
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
olog "github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-pkg/v2/middleware"
|
||||
"github.com/owncloud/ocis-pkg/v2/roles"
|
||||
settings "github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
ssvc "github.com/owncloud/ocis-settings/pkg/service/v0"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
const dataPath = "/var/tmp/ocis-accounts-tests"
|
||||
|
||||
var (
|
||||
roleServiceMock settings.RoleService
|
||||
s *Service
|
||||
)
|
||||
|
||||
func init() {
|
||||
cfg := config.New()
|
||||
cfg.Server.Name = "accounts"
|
||||
cfg.Server.AccountsDataPath = dataPath
|
||||
logger := olog.NewLogger(olog.Color(true), olog.Pretty(true))
|
||||
roleServiceMock = buildRoleServiceMock()
|
||||
roleManager := roles.NewManager(
|
||||
roles.Logger(logger),
|
||||
roles.RoleService(roleServiceMock),
|
||||
roles.CacheTTL(time.Hour),
|
||||
roles.CacheSize(1024),
|
||||
)
|
||||
s, _ = New(
|
||||
Logger(logger),
|
||||
Config(cfg),
|
||||
RoleService(roleServiceMock),
|
||||
RoleManager(&roleManager),
|
||||
)
|
||||
}
|
||||
|
||||
func setup() (teardown func()) {
|
||||
return func() {
|
||||
if err := os.RemoveAll(dataPath); err != nil {
|
||||
log.Printf("could not delete data root: %s", dataPath)
|
||||
} else {
|
||||
log.Println("data root deleted")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestPermissionsListAccounts checks permission handling on ListAccounts
|
||||
func TestPermissionsListAccounts(t *testing.T) {
|
||||
var scenarios = []struct {
|
||||
name string
|
||||
roleIDs []string
|
||||
query string
|
||||
permissionError error
|
||||
}{
|
||||
// TODO: remove this test when https://github.com/owncloud/ocis/accounts/pull/111 is merged
|
||||
// replace with two tests:
|
||||
// 1: "ListAccounts fails with 403 when roleIDs don't exist in context"
|
||||
// 2: "ListAccounts fails with 403 when ('no admin role in context' AND 'empty query')"
|
||||
{
|
||||
"ListAccounts succeeds when no roleIDs in context",
|
||||
nil,
|
||||
"",
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"ListAccounts fails when no admin roleID in context",
|
||||
[]string{ssvc.BundleUUIDRoleUser, ssvc.BundleUUIDRoleGuest},
|
||||
"",
|
||||
merrors.Forbidden(s.id, "no permission for ListAccounts"),
|
||||
},
|
||||
{
|
||||
"ListAccounts succeeds when admin roleID in context",
|
||||
[]string{ssvc.BundleUUIDRoleAdmin},
|
||||
"",
|
||||
nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, scenario := range scenarios {
|
||||
t.Run(scenario.name, func(t *testing.T) {
|
||||
teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
request := &proto.ListAccountsRequest{
|
||||
Query: scenario.query,
|
||||
}
|
||||
response := &proto.ListAccountsResponse{}
|
||||
err := s.ListAccounts(ctx, request, response)
|
||||
if scenario.permissionError != nil {
|
||||
assert.Equal(t, scenario.permissionError, err)
|
||||
} else if err != nil {
|
||||
// we are only checking permissions here, so just check that the error code is not 403
|
||||
merr := merrors.FromError(err)
|
||||
assert.NotEqual(t, http.StatusForbidden, merr.GetCode())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestPermissionsGetAccount checks permission handling on GetAccount
|
||||
// TODO: remove this test function entirely, when https://github.com/owncloud/ocis/accounts/pull/111 is merged. GetAccount will not have permission checks for the time being.
|
||||
func TestPermissionsGetAccount(t *testing.T) {
|
||||
var scenarios = []struct {
|
||||
name string
|
||||
roleIDs []string
|
||||
permissionError error
|
||||
}{
|
||||
{
|
||||
"GetAccount succeeds when no role IDs in context",
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"GetAccount fails when no admin roleID in context",
|
||||
[]string{ssvc.BundleUUIDRoleUser, ssvc.BundleUUIDRoleGuest},
|
||||
merrors.Forbidden(s.id, "no permission for GetAccount"),
|
||||
},
|
||||
{
|
||||
"GetAccount succeeds when admin roleID in context",
|
||||
[]string{ssvc.BundleUUIDRoleAdmin},
|
||||
nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, scenario := range scenarios {
|
||||
t.Run(scenario.name, func(t *testing.T) {
|
||||
teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
request := &proto.GetAccountRequest{}
|
||||
response := &proto.Account{}
|
||||
err := s.GetAccount(ctx, request, response)
|
||||
if scenario.permissionError != nil {
|
||||
assert.Equal(t, scenario.permissionError, err)
|
||||
} else if err != nil {
|
||||
// we are only checking permissions here, so just check that the error code is not 403
|
||||
merr := merrors.FromError(err)
|
||||
assert.NotEqual(t, http.StatusForbidden, merr.GetCode())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestPermissionsCreateAccount checks permission handling on CreateAccount
|
||||
func TestPermissionsCreateAccount(t *testing.T) {
|
||||
var scenarios = []struct {
|
||||
name string
|
||||
roleIDs []string
|
||||
permissionError error
|
||||
}{
|
||||
// TODO: remove this test when https://github.com/owncloud/ocis/accounts/pull/111 is merged
|
||||
// replace with two tests:
|
||||
// 1: "CreateAccount fails with 403 when roleIDs don't exist in context"
|
||||
// 2: "CreateAccount fails with 403 when no admin role in context"
|
||||
{
|
||||
"CreateAccount succeeds when no role IDs in context",
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"CreateAccount fails when no admin roleID in context",
|
||||
[]string{ssvc.BundleUUIDRoleUser, ssvc.BundleUUIDRoleGuest},
|
||||
merrors.Forbidden(s.id, "no permission for CreateAccount"),
|
||||
},
|
||||
{
|
||||
"CreateAccount succeeds when admin roleID in context",
|
||||
[]string{ssvc.BundleUUIDRoleAdmin},
|
||||
nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, scenario := range scenarios {
|
||||
t.Run(scenario.name, func(t *testing.T) {
|
||||
teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
request := &proto.CreateAccountRequest{}
|
||||
response := &proto.Account{}
|
||||
err := s.CreateAccount(ctx, request, response)
|
||||
if scenario.permissionError != nil {
|
||||
assert.Equal(t, scenario.permissionError, err)
|
||||
} else if err != nil {
|
||||
// we are only checking permissions here, so just check that the error code is not 403
|
||||
merr := merrors.FromError(err)
|
||||
assert.NotEqual(t, http.StatusForbidden, merr.GetCode())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestPermissionsUpdateAccount checks permission handling on UpdateAccount
|
||||
func TestPermissionsUpdateAccount(t *testing.T) {
|
||||
var scenarios = []struct {
|
||||
name string
|
||||
roleIDs []string
|
||||
permissionError error
|
||||
}{
|
||||
// TODO: remove this test when https://github.com/owncloud/ocis/accounts/pull/111 is merged
|
||||
// replace with two tests:
|
||||
// 1: "UpdateAccount fails with 403 when roleIDs don't exist in context"
|
||||
// 2: "UpdateAccount fails with 403 when no admin role in context"
|
||||
{
|
||||
"UpdateAccount succeeds when no role IDs in context",
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"UpdateAccount fails when no admin roleID in context",
|
||||
[]string{ssvc.BundleUUIDRoleUser, ssvc.BundleUUIDRoleGuest},
|
||||
merrors.Forbidden(s.id, "no permission for UpdateAccount"),
|
||||
},
|
||||
{
|
||||
"UpdateAccount succeeds when admin roleID in context",
|
||||
[]string{ssvc.BundleUUIDRoleAdmin},
|
||||
nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, scenario := range scenarios {
|
||||
t.Run(scenario.name, func(t *testing.T) {
|
||||
teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
request := &proto.UpdateAccountRequest{}
|
||||
response := &proto.Account{}
|
||||
err := s.UpdateAccount(ctx, request, response)
|
||||
if scenario.permissionError != nil {
|
||||
assert.Equal(t, scenario.permissionError, err)
|
||||
} else if err != nil {
|
||||
// we are only checking permissions here, so just check that the error code is not 403
|
||||
merr := merrors.FromError(err)
|
||||
assert.NotEqual(t, http.StatusForbidden, merr.GetCode())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestPermissionsDeleteAccount checks permission handling on DeleteAccount
|
||||
func TestPermissionsDeleteAccount(t *testing.T) {
|
||||
var scenarios = []struct {
|
||||
name string
|
||||
roleIDs []string
|
||||
permissionError error
|
||||
}{
|
||||
// TODO: remove this test when https://github.com/owncloud/ocis/accounts/pull/111 is merged
|
||||
// replace with two tests:
|
||||
// 1: "DeleteAccount fails with 403 when roleIDs don't exist in context"
|
||||
// 2: "DeleteAccount fails with 403 when no admin role in context"
|
||||
{
|
||||
"DeleteAccount succeeds when no role IDs in context",
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"DeleteAccount fails when no admin roleID in context",
|
||||
[]string{ssvc.BundleUUIDRoleUser, ssvc.BundleUUIDRoleGuest},
|
||||
merrors.Forbidden(s.id, "no permission for DeleteAccount"),
|
||||
},
|
||||
{
|
||||
"DeleteAccount succeeds when admin roleID in context",
|
||||
[]string{ssvc.BundleUUIDRoleAdmin},
|
||||
nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, scenario := range scenarios {
|
||||
t.Run(scenario.name, func(t *testing.T) {
|
||||
teardown := setup()
|
||||
defer teardown()
|
||||
|
||||
ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
request := &proto.DeleteAccountRequest{}
|
||||
response := &empty.Empty{}
|
||||
err := s.DeleteAccount(ctx, request, response)
|
||||
if scenario.permissionError != nil {
|
||||
assert.Equal(t, scenario.permissionError, err)
|
||||
} else if err != nil {
|
||||
// we are only checking permissions here, so just check that the error code is not 403
|
||||
merr := merrors.FromError(err)
|
||||
assert.NotEqual(t, http.StatusForbidden, merr.GetCode())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func buildTestCtx(t *testing.T, roleIDs []string) context.Context {
|
||||
ctx := context.Background()
|
||||
if roleIDs != nil {
|
||||
roleIDs, err := json.Marshal(roleIDs)
|
||||
assert.NoError(t, err)
|
||||
ctx = metadata.Set(ctx, middleware.RoleIDs, string(roleIDs))
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
func buildRoleServiceMock() settings.RoleService {
|
||||
defaultRoles := map[string]*settings.Bundle{
|
||||
ssvc.BundleUUIDRoleAdmin: {
|
||||
Id: ssvc.BundleUUIDRoleAdmin,
|
||||
Type: settings.Bundle_TYPE_ROLE,
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Settings: []*settings.Setting{
|
||||
{
|
||||
Id: AccountManagementPermissionID,
|
||||
},
|
||||
},
|
||||
},
|
||||
ssvc.BundleUUIDRoleUser: {
|
||||
Id: ssvc.BundleUUIDRoleUser,
|
||||
Type: settings.Bundle_TYPE_ROLE,
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Settings: []*settings.Setting{},
|
||||
},
|
||||
ssvc.BundleUUIDRoleGuest: {
|
||||
Id: ssvc.BundleUUIDRoleGuest,
|
||||
Type: settings.Bundle_TYPE_ROLE,
|
||||
Resource: &settings.Resource{
|
||||
Type: settings.Resource_TYPE_SYSTEM,
|
||||
},
|
||||
Settings: []*settings.Setting{},
|
||||
},
|
||||
}
|
||||
return settings.MockRoleService{
|
||||
ListRolesFunc: func(ctx context.Context, req *settings.ListBundlesRequest, opts ...client.CallOption) (res *settings.ListBundlesResponse, err error) {
|
||||
payload := make([]*settings.Bundle, 0)
|
||||
for _, roleID := range req.BundleIds {
|
||||
if defaultRoles[roleID] != nil {
|
||||
payload = append(payload, defaultRoles[roleID])
|
||||
}
|
||||
}
|
||||
return &settings.ListBundlesResponse{
|
||||
Bundles: payload,
|
||||
}, nil
|
||||
},
|
||||
AssignRoleToUserFunc: func(ctx context.Context, req *settings.AssignRoleToUserRequest, opts ...client.CallOption) (res *settings.AssignRoleToUserResponse, err error) {
|
||||
// mock can be empty. function is called during service start. actual role assignments not needed for the tests.
|
||||
return &settings.AssignRoleToUserResponse{
|
||||
Assignment: &settings.UserRoleAssignment{},
|
||||
}, nil
|
||||
},
|
||||
}
|
||||
}
|
||||
//
|
||||
//import (
|
||||
// "context"
|
||||
// "encoding/json"
|
||||
// "log"
|
||||
// "net/http"
|
||||
// "os"
|
||||
// "testing"
|
||||
// "time"
|
||||
//
|
||||
// "github.com/golang/protobuf/ptypes/empty"
|
||||
// "github.com/micro/go-micro/v2/client"
|
||||
// merrors "github.com/micro/go-micro/v2/errors"
|
||||
// "github.com/micro/go-micro/v2/metadata"
|
||||
// "github.com/owncloud/ocis/accounts/pkg/config"
|
||||
// "github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
// olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
// "github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
// "github.com/owncloud/ocis/ocis-pkg/roles"
|
||||
// settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
// ssvc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
// "github.com/stretchr/testify/assert"
|
||||
//)
|
||||
//
|
||||
//const dataPath = "/var/tmp/ocis-accounts-tests"
|
||||
//
|
||||
//var (
|
||||
// roleServiceMock settings.RoleService
|
||||
// s *Service
|
||||
//)
|
||||
//
|
||||
//func init() {
|
||||
// cfg := config.New()
|
||||
// cfg.Server.Name = "accounts"
|
||||
// cfg.Server.AccountsDataPath = dataPath
|
||||
// logger := olog.NewLogger(olog.Color(true), olog.Pretty(true))
|
||||
// roleServiceMock = buildRoleServiceMock()
|
||||
// roleManager := roles.NewManager(
|
||||
// roles.Logger(logger),
|
||||
// roles.RoleService(roleServiceMock),
|
||||
// roles.CacheTTL(time.Hour),
|
||||
// roles.CacheSize(1024),
|
||||
// )
|
||||
// s, _ = New(
|
||||
// Logger(logger),
|
||||
// Config(cfg),
|
||||
// RoleService(roleServiceMock),
|
||||
// RoleManager(&roleManager),
|
||||
// )
|
||||
//}
|
||||
//
|
||||
//func setup() (teardown func()) {
|
||||
// return func() {
|
||||
// if err := os.RemoveAll(dataPath); err != nil {
|
||||
// log.Printf("could not delete data root: %s", dataPath)
|
||||
// } else {
|
||||
// log.Println("data root deleted")
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// TestPermissionsListAccounts checks permission handling on ListAccounts
|
||||
//func TestPermissionsListAccounts(t *testing.T) {
|
||||
// var scenarios = []struct {
|
||||
// name string
|
||||
// roleIDs []string
|
||||
// query string
|
||||
// permissionError error
|
||||
// }{
|
||||
// // TODO: remove this test when https://github.com/owncloud/ocis/accounts/pull/111 is merged
|
||||
// // replace with two tests:
|
||||
// // 1: "ListAccounts fails with 403 when roleIDs don't exist in context"
|
||||
// // 2: "ListAccounts fails with 403 when ('no admin role in context' AND 'empty query')"
|
||||
// {
|
||||
// "ListAccounts succeeds when no roleIDs in context",
|
||||
// nil,
|
||||
// "",
|
||||
// nil,
|
||||
// },
|
||||
// {
|
||||
// "ListAccounts fails when no admin roleID in context",
|
||||
// []string{ssvc.BundleUUIDRoleUser, ssvc.BundleUUIDRoleGuest},
|
||||
// "",
|
||||
// merrors.Forbidden(s.id, "no permission for ListAccounts"),
|
||||
// },
|
||||
// {
|
||||
// "ListAccounts succeeds when admin roleID in context",
|
||||
// []string{ssvc.BundleUUIDRoleAdmin},
|
||||
// "",
|
||||
// nil,
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// for _, scenario := range scenarios {
|
||||
// t.Run(scenario.name, func(t *testing.T) {
|
||||
// teardown := setup()
|
||||
// defer teardown()
|
||||
//
|
||||
// ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
// request := &proto.ListAccountsRequest{
|
||||
// Query: scenario.query,
|
||||
// }
|
||||
// response := &proto.ListAccountsResponse{}
|
||||
// err := s.ListAccounts(ctx, request, response)
|
||||
// if scenario.permissionError != nil {
|
||||
// assert.Equal(t, scenario.permissionError, err)
|
||||
// } else if err != nil {
|
||||
// // we are only checking permissions here, so just check that the error code is not 403
|
||||
// merr := merrors.FromError(err)
|
||||
// assert.NotEqual(t, http.StatusForbidden, merr.GetCode())
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// TestPermissionsGetAccount checks permission handling on GetAccount
|
||||
//// TODO: remove this test function entirely, when https://github.com/owncloud/ocis/accounts/pull/111 is merged. GetAccount will not have permission checks for the time being.
|
||||
//func TestPermissionsGetAccount(t *testing.T) {
|
||||
// var scenarios = []struct {
|
||||
// name string
|
||||
// roleIDs []string
|
||||
// permissionError error
|
||||
// }{
|
||||
// {
|
||||
// "GetAccount succeeds when no role IDs in context",
|
||||
// nil,
|
||||
// nil,
|
||||
// },
|
||||
// {
|
||||
// "GetAccount fails when no admin roleID in context",
|
||||
// []string{ssvc.BundleUUIDRoleUser, ssvc.BundleUUIDRoleGuest},
|
||||
// merrors.Forbidden(s.id, "no permission for GetAccount"),
|
||||
// },
|
||||
// {
|
||||
// "GetAccount succeeds when admin roleID in context",
|
||||
// []string{ssvc.BundleUUIDRoleAdmin},
|
||||
// nil,
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// for _, scenario := range scenarios {
|
||||
// t.Run(scenario.name, func(t *testing.T) {
|
||||
// teardown := setup()
|
||||
// defer teardown()
|
||||
//
|
||||
// ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
// request := &proto.GetAccountRequest{}
|
||||
// response := &proto.Account{}
|
||||
// err := s.GetAccount(ctx, request, response)
|
||||
// if scenario.permissionError != nil {
|
||||
// assert.Equal(t, scenario.permissionError, err)
|
||||
// } else if err != nil {
|
||||
// // we are only checking permissions here, so just check that the error code is not 403
|
||||
// merr := merrors.FromError(err)
|
||||
// assert.NotEqual(t, http.StatusForbidden, merr.GetCode())
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// TestPermissionsCreateAccount checks permission handling on CreateAccount
|
||||
//func TestPermissionsCreateAccount(t *testing.T) {
|
||||
// var scenarios = []struct {
|
||||
// name string
|
||||
// roleIDs []string
|
||||
// permissionError error
|
||||
// }{
|
||||
// // TODO: remove this test when https://github.com/owncloud/ocis/accounts/pull/111 is merged
|
||||
// // replace with two tests:
|
||||
// // 1: "CreateAccount fails with 403 when roleIDs don't exist in context"
|
||||
// // 2: "CreateAccount fails with 403 when no admin role in context"
|
||||
// {
|
||||
// "CreateAccount succeeds when no role IDs in context",
|
||||
// nil,
|
||||
// nil,
|
||||
// },
|
||||
// {
|
||||
// "CreateAccount fails when no admin roleID in context",
|
||||
// []string{ssvc.BundleUUIDRoleUser, ssvc.BundleUUIDRoleGuest},
|
||||
// merrors.Forbidden(s.id, "no permission for CreateAccount"),
|
||||
// },
|
||||
// {
|
||||
// "CreateAccount succeeds when admin roleID in context",
|
||||
// []string{ssvc.BundleUUIDRoleAdmin},
|
||||
// nil,
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// for _, scenario := range scenarios {
|
||||
// t.Run(scenario.name, func(t *testing.T) {
|
||||
// teardown := setup()
|
||||
// defer teardown()
|
||||
//
|
||||
// ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
// request := &proto.CreateAccountRequest{}
|
||||
// response := &proto.Account{}
|
||||
// err := s.CreateAccount(ctx, request, response)
|
||||
// if scenario.permissionError != nil {
|
||||
// assert.Equal(t, scenario.permissionError, err)
|
||||
// } else if err != nil {
|
||||
// // we are only checking permissions here, so just check that the error code is not 403
|
||||
// merr := merrors.FromError(err)
|
||||
// assert.NotEqual(t, http.StatusForbidden, merr.GetCode())
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// TestPermissionsUpdateAccount checks permission handling on UpdateAccount
|
||||
//func TestPermissionsUpdateAccount(t *testing.T) {
|
||||
// var scenarios = []struct {
|
||||
// name string
|
||||
// roleIDs []string
|
||||
// permissionError error
|
||||
// }{
|
||||
// // TODO: remove this test when https://github.com/owncloud/ocis/accounts/pull/111 is merged
|
||||
// // replace with two tests:
|
||||
// // 1: "UpdateAccount fails with 403 when roleIDs don't exist in context"
|
||||
// // 2: "UpdateAccount fails with 403 when no admin role in context"
|
||||
// {
|
||||
// "UpdateAccount succeeds when no role IDs in context",
|
||||
// nil,
|
||||
// nil,
|
||||
// },
|
||||
// {
|
||||
// "UpdateAccount fails when no admin roleID in context",
|
||||
// []string{ssvc.BundleUUIDRoleUser, ssvc.BundleUUIDRoleGuest},
|
||||
// merrors.Forbidden(s.id, "no permission for UpdateAccount"),
|
||||
// },
|
||||
// {
|
||||
// "UpdateAccount succeeds when admin roleID in context",
|
||||
// []string{ssvc.BundleUUIDRoleAdmin},
|
||||
// nil,
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// for _, scenario := range scenarios {
|
||||
// t.Run(scenario.name, func(t *testing.T) {
|
||||
// teardown := setup()
|
||||
// defer teardown()
|
||||
//
|
||||
// ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
// request := &proto.UpdateAccountRequest{}
|
||||
// response := &proto.Account{}
|
||||
// err := s.UpdateAccount(ctx, request, response)
|
||||
// if scenario.permissionError != nil {
|
||||
// assert.Equal(t, scenario.permissionError, err)
|
||||
// } else if err != nil {
|
||||
// // we are only checking permissions here, so just check that the error code is not 403
|
||||
// merr := merrors.FromError(err)
|
||||
// assert.NotEqual(t, http.StatusForbidden, merr.GetCode())
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// TestPermissionsDeleteAccount checks permission handling on DeleteAccount
|
||||
//func TestPermissionsDeleteAccount(t *testing.T) {
|
||||
// var scenarios = []struct {
|
||||
// name string
|
||||
// roleIDs []string
|
||||
// permissionError error
|
||||
// }{
|
||||
// // TODO: remove this test when https://github.com/owncloud/ocis/accounts/pull/111 is merged
|
||||
// // replace with two tests:
|
||||
// // 1: "DeleteAccount fails with 403 when roleIDs don't exist in context"
|
||||
// // 2: "DeleteAccount fails with 403 when no admin role in context"
|
||||
// {
|
||||
// "DeleteAccount succeeds when no role IDs in context",
|
||||
// nil,
|
||||
// nil,
|
||||
// },
|
||||
// {
|
||||
// "DeleteAccount fails when no admin roleID in context",
|
||||
// []string{ssvc.BundleUUIDRoleUser, ssvc.BundleUUIDRoleGuest},
|
||||
// merrors.Forbidden(s.id, "no permission for DeleteAccount"),
|
||||
// },
|
||||
// {
|
||||
// "DeleteAccount succeeds when admin roleID in context",
|
||||
// []string{ssvc.BundleUUIDRoleAdmin},
|
||||
// nil,
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// for _, scenario := range scenarios {
|
||||
// t.Run(scenario.name, func(t *testing.T) {
|
||||
// teardown := setup()
|
||||
// defer teardown()
|
||||
//
|
||||
// ctx := buildTestCtx(t, scenario.roleIDs)
|
||||
// request := &proto.DeleteAccountRequest{}
|
||||
// response := &empty.Empty{}
|
||||
// err := s.DeleteAccount(ctx, request, response)
|
||||
// if scenario.permissionError != nil {
|
||||
// assert.Equal(t, scenario.permissionError, err)
|
||||
// } else if err != nil {
|
||||
// // we are only checking permissions here, so just check that the error code is not 403
|
||||
// merr := merrors.FromError(err)
|
||||
// assert.NotEqual(t, http.StatusForbidden, merr.GetCode())
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func buildTestCtx(t *testing.T, roleIDs []string) context.Context {
|
||||
// ctx := context.Background()
|
||||
// if roleIDs != nil {
|
||||
// roleIDs, err := json.Marshal(roleIDs)
|
||||
// assert.NoError(t, err)
|
||||
// ctx = metadata.Set(ctx, middleware.RoleIDs, string(roleIDs))
|
||||
// }
|
||||
// return ctx
|
||||
//}
|
||||
//
|
||||
//func buildRoleServiceMock() settings.RoleService {
|
||||
// defaultRoles := map[string]*settings.Bundle{
|
||||
// ssvc.BundleUUIDRoleAdmin: {
|
||||
// Id: ssvc.BundleUUIDRoleAdmin,
|
||||
// Type: settings.Bundle_TYPE_ROLE,
|
||||
// Resource: &settings.Resource{
|
||||
// Type: settings.Resource_TYPE_SYSTEM,
|
||||
// },
|
||||
// Settings: []*settings.Setting{
|
||||
// {
|
||||
// Id: AccountManagementPermissionID,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// ssvc.BundleUUIDRoleUser: {
|
||||
// Id: ssvc.BundleUUIDRoleUser,
|
||||
// Type: settings.Bundle_TYPE_ROLE,
|
||||
// Resource: &settings.Resource{
|
||||
// Type: settings.Resource_TYPE_SYSTEM,
|
||||
// },
|
||||
// Settings: []*settings.Setting{},
|
||||
// },
|
||||
// ssvc.BundleUUIDRoleGuest: {
|
||||
// Id: ssvc.BundleUUIDRoleGuest,
|
||||
// Type: settings.Bundle_TYPE_ROLE,
|
||||
// Resource: &settings.Resource{
|
||||
// Type: settings.Resource_TYPE_SYSTEM,
|
||||
// },
|
||||
// Settings: []*settings.Setting{},
|
||||
// },
|
||||
// }
|
||||
// return settings.MockRoleService{
|
||||
// ListRolesFunc: func(ctx context.Context, req *settings.ListBundlesRequest, opts ...client.CallOption) (res *settings.ListBundlesResponse, err error) {
|
||||
// payload := make([]*settings.Bundle, 0)
|
||||
// for _, roleID := range req.BundleIds {
|
||||
// if defaultRoles[roleID] != nil {
|
||||
// payload = append(payload, defaultRoles[roleID])
|
||||
// }
|
||||
// }
|
||||
// return &settings.ListBundlesResponse{
|
||||
// Bundles: payload,
|
||||
// }, nil
|
||||
// },
|
||||
// AssignRoleToUserFunc: func(ctx context.Context, req *settings.AssignRoleToUserRequest, opts ...client.CallOption) (res *settings.AssignRoleToUserResponse, err error) {
|
||||
// // mock can be empty. function is called during service start. actual role assignments not needed for the tests.
|
||||
// return &settings.AssignRoleToUserResponse{
|
||||
// Assignment: &settings.UserRoleAssignment{},
|
||||
// }, nil
|
||||
// },
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -2,9 +2,9 @@ package service
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-pkg/v2/roles"
|
||||
settings "github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/roles"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
|
||||
mclient "github.com/micro/go-micro/v2/client"
|
||||
olog "github.com/owncloud/ocis-pkg/v2/log"
|
||||
settings "github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
ssvc "github.com/owncloud/ocis-settings/pkg/service/v0"
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
ssvc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -21,10 +21,10 @@ import (
|
||||
mclient "github.com/micro/go-micro/v2/client"
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-pkg/v2/roles"
|
||||
settings "github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
settings_svc "github.com/owncloud/ocis-settings/pkg/service/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/roles"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
settings_svc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
)
|
||||
|
||||
// New returns a new instance of Service
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
|
||||
mclient "github.com/micro/go-micro/v2/client"
|
||||
olog "github.com/owncloud/ocis-pkg/v2/log"
|
||||
settings "github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
ssvc "github.com/owncloud/ocis-settings/pkg/service/v0"
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
ssvc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
|
||||
+5
-3
@@ -12,8 +12,7 @@ require (
|
||||
github.com/micro/cli/v2 v2.1.2
|
||||
github.com/micro/go-micro/v2 v2.9.1
|
||||
github.com/micro/go-plugins/wrapper/trace/opencensus/v2 v2.9.1
|
||||
github.com/owncloud/ocis-pkg/v2 v2.4.0
|
||||
github.com/owncloud/ocis-settings v0.3.2-0.20200828091056-47af10a0e872
|
||||
github.com/owncloud/ocis/settings v0.0.0-20200918114005-1a0ddd2190ee // indirect
|
||||
github.com/prometheus/client_golang v1.7.1
|
||||
github.com/restic/calens v0.2.0
|
||||
github.com/rs/zerolog v1.19.0
|
||||
@@ -24,4 +23,7 @@ require (
|
||||
honnef.co/go/tools v0.0.1-2020.1.5
|
||||
)
|
||||
|
||||
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0
|
||||
replace (
|
||||
google.golang.org/grpc => google.golang.org/grpc v1.26.0
|
||||
github.com/owncloud/ocis/settings => ../settings
|
||||
)
|
||||
|
||||
+7
-2
@@ -773,10 +773,15 @@ github.com/ory/herodot v0.6.2/go.mod h1:3BOneqcyBsVybCPAJoi92KN2BpJHcmDqAMcAAaJi
|
||||
github.com/ory/viper v1.5.6/go.mod h1:TYmpFpKLxjQwvT4f0QPpkOn4sDXU1kDgAwJpgLYiQ28=
|
||||
github.com/ory/x v0.0.85/go.mod h1:s44V8t3xyjWZREcU+mWlp4h302rTuM4aLXcW+y5FbQ8=
|
||||
github.com/ovh/go-ovh v0.0.0-20181109152953-ba5adb4cf014/go.mod h1:joRatxRJaZBsY3JAOEMcoOp05CnZzsx4scTxi95DHyQ=
|
||||
github.com/owncloud/ocis-pkg/v2 v2.4.0 h1:/3ZOd4txtwjiNKJA9iLT9BjrJw5YgHSX13fQR4BYfGY=
|
||||
github.com/owncloud/ocis-pkg/v2 v2.4.0/go.mod h1:FSzIvhx9HcZcq4jgNaDowNvM7PTX/XCyoMvyfzidUpE=
|
||||
github.com/owncloud/ocis v1.0.0-rc1 h1:5pxFes3myh5cwfvyZ0l6akN9wneSc9UxB5Veg2Xr1Rc=
|
||||
github.com/owncloud/ocis v1.0.0-rc1.0.20200918114005-1a0ddd2190ee h1:EXT7AIO8bc6HEcnvybGQUkzRXin2KagJBpuv12oZksM=
|
||||
github.com/owncloud/ocis/ocis-pkg/ v2.4.0 h1:/3ZOd4txtwjiNKJA9iLT9BjrJw5YgHSX13fQR4BYfGY=
|
||||
github.com/owncloud/ocis/ocis-pkg/ v2.4.0/go.mod h1:FSzIvhx9HcZcq4jgNaDowNvM7PTX/XCyoMvyfzidUpE=
|
||||
github.com/owncloud/ocis/ocis-pkg/ v2.4.1-0.20200902134813-1e87c6173ada/go.mod h1:WdcVM54z0X7aQzS8eyGl7S5sjEMVBtLpfpzsPX3Z+Pw=
|
||||
github.com/owncloud/ocis-settings v0.3.2-0.20200828091056-47af10a0e872 h1:VGWM/eLIxXY6BJLDuzpdjSVa73Dj5S8pfUtT9Sb5Ono=
|
||||
github.com/owncloud/ocis-settings v0.3.2-0.20200828091056-47af10a0e872/go.mod h1:vRge9QDkOsc6j76gPBmZs1Z5uOPrV4DIkZCgZCEFwBA=
|
||||
github.com/owncloud/ocis/settings v0.0.0-20200918114005-1a0ddd2190ee h1:LaKP3hCTJ6WwB3W40m5UhddvokMRIbOXrjogxON4jAI=
|
||||
github.com/owncloud/ocis/settings v0.0.0-20200918114005-1a0ddd2190ee/go.mod h1:5w91idmyOd8LgYK3eGuqsFBOfVJnSDeEp7S6dHheW14=
|
||||
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/parnurzeal/gorequest v0.2.15/go.mod h1:3Kh2QUMJoqw3icWAecsyzkpY7UzRfDhbRdTjtNwNiUE=
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/cs3org/reva/pkg/token/manager/jwt"
|
||||
"github.com/micro/go-micro/v2/metadata"
|
||||
"github.com/owncloud/ocis-pkg/v2/account"
|
||||
"github.com/owncloud/ocis/ocis-pkg/account"
|
||||
)
|
||||
|
||||
// newAccountOptions initializes the available default options.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-chi/chi/middleware"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Logger is a middleware to log http requests.
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
oidc "github.com/coreos/go-oidc"
|
||||
ocisoidc "github.com/owncloud/ocis-pkg/v2/oidc"
|
||||
ocisoidc "github.com/owncloud/ocis/ocis-pkg/oidc"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package oidc
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
settings "github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
)
|
||||
|
||||
// entry extends a bundle and adds a TTL
|
||||
|
||||
@@ -3,8 +3,8 @@ package roles
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
settings "github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
)
|
||||
|
||||
// Manager manages a cache of roles by fetching unknown roles from the settings.RoleService.
|
||||
|
||||
@@ -3,8 +3,8 @@ package roles
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
settings "github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
)
|
||||
|
||||
// Options are all the possible options.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/micro/go-micro/v2/metadata"
|
||||
"github.com/owncloud/ocis-pkg/v2/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
)
|
||||
|
||||
// ReadRoleIDsFromContext extracts roleIDs from the metadata context and returns them as []string
|
||||
|
||||
@@ -3,7 +3,7 @@ package debug
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http/pprof"
|
||||
|
||||
"github.com/justinas/alice"
|
||||
"github.com/owncloud/ocis-pkg/v2/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"go.opencensus.io/zpages"
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/micro/go-micro/v2"
|
||||
"github.com/micro/go-plugins/wrapper/trace/opencensus/v2"
|
||||
"github.com/owncloud/ocis-pkg/v2/wrapper/prometheus"
|
||||
"github.com/owncloud/ocis/ocis-pkg/wrapper/prometheus"
|
||||
)
|
||||
|
||||
// Service simply wraps the go-micro grpc service.
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
|
||||
+5
-2
@@ -18,7 +18,7 @@ require (
|
||||
github.com/mitchellh/gox v1.0.1
|
||||
github.com/oklog/run v1.0.0
|
||||
github.com/openzipkin/zipkin-go v0.2.2
|
||||
github.com/owncloud/ocis-pkg/v2 v2.4.1-0.20200902134813-1e87c6173ada
|
||||
github.com/owncloud/ocis/ocis-pkg v0.0.0-20200918114005-1a0ddd2190ee // indirect
|
||||
github.com/restic/calens v0.2.0
|
||||
github.com/spf13/viper v1.6.3
|
||||
github.com/stretchr/testify v1.6.1
|
||||
@@ -30,4 +30,7 @@ require (
|
||||
gotest.tools v2.2.0+incompatible
|
||||
)
|
||||
|
||||
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0
|
||||
replace (
|
||||
google.golang.org/grpc => google.golang.org/grpc v1.26.0
|
||||
github.com/owncloud/ocis/ocis-pkg => ../ocis-pkg
|
||||
)
|
||||
|
||||
@@ -759,6 +759,8 @@ github.com/ory/herodot v0.6.2/go.mod h1:3BOneqcyBsVybCPAJoi92KN2BpJHcmDqAMcAAaJi
|
||||
github.com/ory/viper v1.5.6/go.mod h1:TYmpFpKLxjQwvT4f0QPpkOn4sDXU1kDgAwJpgLYiQ28=
|
||||
github.com/ory/x v0.0.85/go.mod h1:s44V8t3xyjWZREcU+mWlp4h302rTuM4aLXcW+y5FbQ8=
|
||||
github.com/ovh/go-ovh v0.0.0-20181109152953-ba5adb4cf014/go.mod h1:joRatxRJaZBsY3JAOEMcoOp05CnZzsx4scTxi95DHyQ=
|
||||
github.com/owncloud/ocis v1.0.0-rc1 h1:5pxFes3myh5cwfvyZ0l6akN9wneSc9UxB5Veg2Xr1Rc=
|
||||
github.com/owncloud/ocis v1.0.0-rc1.0.20200918114005-1a0ddd2190ee h1:EXT7AIO8bc6HEcnvybGQUkzRXin2KagJBpuv12oZksM=
|
||||
github.com/owncloud/ocis-pkg/v2 v2.2.2-0.20200812103920-db41b5a3d14d h1:eruHqxLfS3fiPO1ylg60T++wShVqtayI4LxUhwOEuN4=
|
||||
github.com/owncloud/ocis-pkg/v2 v2.2.2-0.20200812103920-db41b5a3d14d/go.mod h1:FSzIvhx9HcZcq4jgNaDowNvM7PTX/XCyoMvyfzidUpE=
|
||||
github.com/owncloud/ocis-pkg/v2 v2.3.1-0.20200825114153-bc31e3e4b1e0 h1:dz/I+K7+1t3RKrNafDtb6EWJCQe7+z6c4V9UF0bGxCI=
|
||||
@@ -771,6 +773,8 @@ github.com/owncloud/ocis-pkg/v2 v2.4.1-0.20200902134813-1e87c6173ada h1:iVknnuT/
|
||||
github.com/owncloud/ocis-pkg/v2 v2.4.1-0.20200902134813-1e87c6173ada/go.mod h1:WdcVM54z0X7aQzS8eyGl7S5sjEMVBtLpfpzsPX3Z+Pw=
|
||||
github.com/owncloud/ocis-settings v0.3.2-0.20200828091056-47af10a0e872 h1:VGWM/eLIxXY6BJLDuzpdjSVa73Dj5S8pfUtT9Sb5Ono=
|
||||
github.com/owncloud/ocis-settings v0.3.2-0.20200828091056-47af10a0e872/go.mod h1:vRge9QDkOsc6j76gPBmZs1Z5uOPrV4DIkZCgZCEFwBA=
|
||||
github.com/owncloud/ocis/ocis-pkg v0.0.0-20200918114005-1a0ddd2190ee h1:P/bd6+zVU+I+X1+VfSg9av0OD2bfw1tUSHQtWj1JX/I=
|
||||
github.com/owncloud/ocis/ocis-pkg v0.0.0-20200918114005-1a0ddd2190ee/go.mod h1:kukd3chd0ARpGNSLcIutgFywSvWIIdQcpyhPtVTyZbM=
|
||||
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/parnurzeal/gorequest v0.2.15/go.mod h1:3Kh2QUMJoqw3icWAecsyzkpY7UzRfDhbRdTjtNwNiUE=
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
|
||||
// Fake the import to make the dep tree happy.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package assets
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
"github.com/owncloud/ocis/settings/pkg/flagset"
|
||||
"github.com/owncloud/ocis/settings/pkg/version"
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
|
||||
merrors "github.com/micro/go-micro/v2/errors"
|
||||
"github.com/micro/go-micro/v2/metadata"
|
||||
ocislog "github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-pkg/v2/middleware"
|
||||
"github.com/owncloud/ocis-pkg/v2/service/grpc"
|
||||
ocislog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
svc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
|
||||
@@ -3,7 +3,7 @@ package debug
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis-pkg/v2/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
"github.com/owncloud/ocis/settings/pkg/version"
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
"github.com/owncloud/ocis/settings/pkg/metrics"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis-pkg/v2/service/grpc"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
svc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
"github.com/owncloud/ocis/settings/pkg/version"
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
"github.com/owncloud/ocis/settings/pkg/metrics"
|
||||
)
|
||||
|
||||
@@ -2,9 +2,9 @@ package http
|
||||
|
||||
import (
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/owncloud/ocis-pkg/v2/account"
|
||||
"github.com/owncloud/ocis-pkg/v2/middleware"
|
||||
"github.com/owncloud/ocis-pkg/v2/service/http"
|
||||
"github.com/owncloud/ocis/ocis-pkg/account"
|
||||
"github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/http"
|
||||
"github.com/owncloud/ocis/settings/pkg/assets"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
svc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// NewLogging returns a service that logs messages.
|
||||
|
||||
@@ -3,7 +3,7 @@ package svc
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
merrors "github.com/micro/go-micro/v2/errors"
|
||||
"github.com/micro/go-micro/v2/metadata"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-pkg/v2/middleware"
|
||||
"github.com/owncloud/ocis-pkg/v2/roles"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/roles"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/settings/pkg/settings"
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/micro/go-micro/v2/metadata"
|
||||
"github.com/owncloud/ocis-pkg/v2/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
olog "github.com/owncloud/ocis-pkg/v2/log"
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ package store
|
||||
import (
|
||||
"testing"
|
||||
|
||||
olog "github.com/owncloud/ocis-pkg/v2/log"
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ package store
|
||||
import (
|
||||
"os"
|
||||
|
||||
olog "github.com/owncloud/ocis-pkg/v2/log"
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
"github.com/owncloud/ocis/settings/pkg/settings"
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ package store
|
||||
import (
|
||||
"testing"
|
||||
|
||||
olog "github.com/owncloud/ocis-pkg/v2/log"
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/settings/pkg/proto/v0"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user