From fcca9faa81c855d55d39582930b8c180d0d1f2ce Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Fri, 18 Sep 2020 14:51:07 +0200 Subject: [PATCH] accounts running --- accounts/CHANGELOG.md | 2 +- .../adapt-to-settings-data-model.md | 2 +- accounts/go.mod | 10 +- accounts/go.sum | 4 + accounts/pkg/assets/assets.go | 2 +- accounts/pkg/assets/option.go | 2 +- accounts/pkg/command/root.go | 2 +- .../pkg/proto/v0/accounts.pb.micro_test.go | 4 +- accounts/pkg/server/grpc/option.go | 2 +- accounts/pkg/server/grpc/server.go | 2 +- accounts/pkg/server/http/option.go | 2 +- accounts/pkg/server/http/server.go | 6 +- accounts/pkg/service/v0/accounts.go | 6 +- .../service/v0/accounts_permission_test.go | 730 +++++++++--------- accounts/pkg/service/v0/option.go | 6 +- accounts/pkg/service/v0/permissions.go | 6 +- accounts/pkg/service/v0/service.go | 8 +- accounts/pkg/service/v0/settings.go | 6 +- ocis-pkg/account/option.go | 2 +- ocis-pkg/go.mod | 8 +- ocis-pkg/go.sum | 9 +- ocis-pkg/middleware/account.go | 2 +- ocis-pkg/middleware/logger.go | 2 +- ocis-pkg/middleware/openidconnect.go | 2 +- ocis-pkg/oidc/option.go | 2 +- ocis-pkg/roles/cache.go | 2 +- ocis-pkg/roles/manager.go | 4 +- ocis-pkg/roles/option.go | 4 +- ocis-pkg/roles/util.go | 2 +- ocis-pkg/service/debug/option.go | 2 +- ocis-pkg/service/debug/service.go | 2 +- ocis-pkg/service/grpc/option.go | 2 +- ocis-pkg/service/grpc/service.go | 2 +- ocis-pkg/service/http/option.go | 2 +- settings/go.mod | 7 +- settings/go.sum | 4 + settings/pkg/assets/assets.go | 2 +- settings/pkg/assets/option.go | 2 +- settings/pkg/command/root.go | 2 +- .../pkg/proto/v0/settings.pb.micro_test.go | 6 +- settings/pkg/server/debug/option.go | 2 +- settings/pkg/server/debug/server.go | 2 +- settings/pkg/server/grpc/option.go | 2 +- settings/pkg/server/grpc/server.go | 2 +- settings/pkg/server/http/option.go | 2 +- settings/pkg/server/http/server.go | 6 +- settings/pkg/service/v0/logging.go | 2 +- settings/pkg/service/v0/option.go | 2 +- settings/pkg/service/v0/service.go | 6 +- settings/pkg/service/v0/service_test.go | 2 +- .../pkg/store/filesystem/assignments_test.go | 2 +- settings/pkg/store/filesystem/bundles_test.go | 2 +- settings/pkg/store/filesystem/store.go | 2 +- settings/pkg/store/filesystem/values_test.go | 2 +- 54 files changed, 466 insertions(+), 444 deletions(-) diff --git a/accounts/CHANGELOG.md b/accounts/CHANGELOG.md index 165548afe..fa6d2cf79 100644 --- a/accounts/CHANGELOG.md +++ b/accounts/CHANGELOG.md @@ -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) diff --git a/accounts/changelog/0.3.0_2020-08-20/adapt-to-settings-data-model.md b/accounts/changelog/0.3.0_2020-08-20/adapt-to-settings-data-model.md index 16c4ac980..ee57d3781 100644 --- a/accounts/changelog/0.3.0_2020-08-20/adapt-to-settings-data-model.md +++ b/accounts/changelog/0.3.0_2020-08-20/adapt-to-settings-data-model.md @@ -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 diff --git a/accounts/go.mod b/accounts/go.mod index a102c4564..06d45489d 100644 --- a/accounts/go.mod +++ b/accounts/go.mod @@ -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 +) diff --git a/accounts/go.sum b/accounts/go.sum index 00aa5f379..da2ea3919 100644 --- a/accounts/go.sum +++ b/accounts/go.sum @@ -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= diff --git a/accounts/pkg/assets/assets.go b/accounts/pkg/assets/assets.go index dfd3d1774..aaf0dfdcc 100644 --- a/accounts/pkg/assets/assets.go +++ b/accounts/pkg/assets/assets.go @@ -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" diff --git a/accounts/pkg/assets/option.go b/accounts/pkg/assets/option.go index cab6cc505..0ebcdba1d 100644 --- a/accounts/pkg/assets/option.go +++ b/accounts/pkg/assets/option.go @@ -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. diff --git a/accounts/pkg/command/root.go b/accounts/pkg/command/root.go index bd3ed9492..2234e91c3 100644 --- a/accounts/pkg/command/root.go +++ b/accounts/pkg/command/root.go @@ -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" ) diff --git a/accounts/pkg/proto/v0/accounts.pb.micro_test.go b/accounts/pkg/proto/v0/accounts.pb.micro_test.go index 0333cdb21..02775d65d 100644 --- a/accounts/pkg/proto/v0/accounts.pb.micro_test.go +++ b/accounts/pkg/proto/v0/accounts.pb.micro_test.go @@ -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" diff --git a/accounts/pkg/server/grpc/option.go b/accounts/pkg/server/grpc/option.go index 050ea2d1e..86d158f6f 100644 --- a/accounts/pkg/server/grpc/option.go +++ b/accounts/pkg/server/grpc/option.go @@ -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. diff --git a/accounts/pkg/server/grpc/server.go b/accounts/pkg/server/grpc/server.go index e6dd28b14..13f7c2e8d 100644 --- a/accounts/pkg/server/grpc/server.go +++ b/accounts/pkg/server/grpc/server.go @@ -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 diff --git a/accounts/pkg/server/http/option.go b/accounts/pkg/server/http/option.go index e95bafe88..664a2cdfe 100644 --- a/accounts/pkg/server/http/option.go +++ b/accounts/pkg/server/http/option.go @@ -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. diff --git a/accounts/pkg/server/http/server.go b/accounts/pkg/server/http/server.go index 9a2b6350d..1b420390d 100644 --- a/accounts/pkg/server/http/server.go +++ b/accounts/pkg/server/http/server.go @@ -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. diff --git a/accounts/pkg/service/v0/accounts.go b/accounts/pkg/service/v0/accounts.go index 55d716666..a6a342927 100644 --- a/accounts/pkg/service/v0/accounts.go +++ b/accounts/pkg/service/v0/accounts.go @@ -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" diff --git a/accounts/pkg/service/v0/accounts_permission_test.go b/accounts/pkg/service/v0/accounts_permission_test.go index 13dacb2c2..5d2c66aba 100644 --- a/accounts/pkg/service/v0/accounts_permission_test.go +++ b/accounts/pkg/service/v0/accounts_permission_test.go @@ -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 +// }, +// } +//} diff --git a/accounts/pkg/service/v0/option.go b/accounts/pkg/service/v0/option.go index b4d19bbd5..387ff7b35 100644 --- a/accounts/pkg/service/v0/option.go +++ b/accounts/pkg/service/v0/option.go @@ -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. diff --git a/accounts/pkg/service/v0/permissions.go b/accounts/pkg/service/v0/permissions.go index ca20de8b8..30730659f 100644 --- a/accounts/pkg/service/v0/permissions.go +++ b/accounts/pkg/service/v0/permissions.go @@ -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 ( diff --git a/accounts/pkg/service/v0/service.go b/accounts/pkg/service/v0/service.go index 46f0b8955..d3f3b8c76 100644 --- a/accounts/pkg/service/v0/service.go +++ b/accounts/pkg/service/v0/service.go @@ -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 diff --git a/accounts/pkg/service/v0/settings.go b/accounts/pkg/service/v0/settings.go index 09d2baf7c..c2c2990c5 100644 --- a/accounts/pkg/service/v0/settings.go +++ b/accounts/pkg/service/v0/settings.go @@ -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 ( diff --git a/ocis-pkg/account/option.go b/ocis-pkg/account/option.go index 0e32dafe3..9a5bfa55f 100644 --- a/ocis-pkg/account/option.go +++ b/ocis-pkg/account/option.go @@ -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. diff --git a/ocis-pkg/go.mod b/ocis-pkg/go.mod index abaa800e8..a1ef52bc9 100644 --- a/ocis-pkg/go.mod +++ b/ocis-pkg/go.mod @@ -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 + ) diff --git a/ocis-pkg/go.sum b/ocis-pkg/go.sum index a4fc0c28e..ee542190c 100644 --- a/ocis-pkg/go.sum +++ b/ocis-pkg/go.sum @@ -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= diff --git a/ocis-pkg/middleware/account.go b/ocis-pkg/middleware/account.go index db30ac290..754db161f 100644 --- a/ocis-pkg/middleware/account.go +++ b/ocis-pkg/middleware/account.go @@ -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. diff --git a/ocis-pkg/middleware/logger.go b/ocis-pkg/middleware/logger.go index 0a7198b63..66a71a5ad 100644 --- a/ocis-pkg/middleware/logger.go +++ b/ocis-pkg/middleware/logger.go @@ -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. diff --git a/ocis-pkg/middleware/openidconnect.go b/ocis-pkg/middleware/openidconnect.go index fa60a091c..20998d5ad 100644 --- a/ocis-pkg/middleware/openidconnect.go +++ b/ocis-pkg/middleware/openidconnect.go @@ -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" ) diff --git a/ocis-pkg/oidc/option.go b/ocis-pkg/oidc/option.go index c0a3d1175..d477f9d75 100644 --- a/ocis-pkg/oidc/option.go +++ b/ocis-pkg/oidc/option.go @@ -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. diff --git a/ocis-pkg/roles/cache.go b/ocis-pkg/roles/cache.go index 4de4ea1a7..343c18e01 100644 --- a/ocis-pkg/roles/cache.go +++ b/ocis-pkg/roles/cache.go @@ -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 diff --git a/ocis-pkg/roles/manager.go b/ocis-pkg/roles/manager.go index 253bdfd43..040310d9f 100644 --- a/ocis-pkg/roles/manager.go +++ b/ocis-pkg/roles/manager.go @@ -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. diff --git a/ocis-pkg/roles/option.go b/ocis-pkg/roles/option.go index 20f2be31f..13e939953 100644 --- a/ocis-pkg/roles/option.go +++ b/ocis-pkg/roles/option.go @@ -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. diff --git a/ocis-pkg/roles/util.go b/ocis-pkg/roles/util.go index b3d3c01e9..0f9b3eb5b 100644 --- a/ocis-pkg/roles/util.go +++ b/ocis-pkg/roles/util.go @@ -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 diff --git a/ocis-pkg/service/debug/option.go b/ocis-pkg/service/debug/option.go index bdbef00f6..700df6f58 100644 --- a/ocis-pkg/service/debug/option.go +++ b/ocis-pkg/service/debug/option.go @@ -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. diff --git a/ocis-pkg/service/debug/service.go b/ocis-pkg/service/debug/service.go index 52b2d545d..937ce8cba 100644 --- a/ocis-pkg/service/debug/service.go +++ b/ocis-pkg/service/debug/service.go @@ -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" ) diff --git a/ocis-pkg/service/grpc/option.go b/ocis-pkg/service/grpc/option.go index 6bc3005cb..88528416e 100644 --- a/ocis-pkg/service/grpc/option.go +++ b/ocis-pkg/service/grpc/option.go @@ -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. diff --git a/ocis-pkg/service/grpc/service.go b/ocis-pkg/service/grpc/service.go index 1dbf5c977..ed00090bf 100644 --- a/ocis-pkg/service/grpc/service.go +++ b/ocis-pkg/service/grpc/service.go @@ -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. diff --git a/ocis-pkg/service/http/option.go b/ocis-pkg/service/http/option.go index 2d7d3c7df..e61c46490 100644 --- a/ocis-pkg/service/http/option.go +++ b/ocis-pkg/service/http/option.go @@ -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. diff --git a/settings/go.mod b/settings/go.mod index cb90602de..e5e4efb4e 100644 --- a/settings/go.mod +++ b/settings/go.mod @@ -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 +) diff --git a/settings/go.sum b/settings/go.sum index 88e108027..0341423cc 100644 --- a/settings/go.sum +++ b/settings/go.sum @@ -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= diff --git a/settings/pkg/assets/assets.go b/settings/pkg/assets/assets.go index a9d972a36..8daf5e935 100644 --- a/settings/pkg/assets/assets.go +++ b/settings/pkg/assets/assets.go @@ -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. diff --git a/settings/pkg/assets/option.go b/settings/pkg/assets/option.go index 4b1a86ffc..592aa796f 100644 --- a/settings/pkg/assets/option.go +++ b/settings/pkg/assets/option.go @@ -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" ) diff --git a/settings/pkg/command/root.go b/settings/pkg/command/root.go index f868b72cc..25c2edb11 100644 --- a/settings/pkg/command/root.go +++ b/settings/pkg/command/root.go @@ -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" diff --git a/settings/pkg/proto/v0/settings.pb.micro_test.go b/settings/pkg/proto/v0/settings.pb.micro_test.go index a752c5add..7249fa8e4 100644 --- a/settings/pkg/proto/v0/settings.pb.micro_test.go +++ b/settings/pkg/proto/v0/settings.pb.micro_test.go @@ -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" diff --git a/settings/pkg/server/debug/option.go b/settings/pkg/server/debug/option.go index 11ea1a332..efcc12b6c 100644 --- a/settings/pkg/server/debug/option.go +++ b/settings/pkg/server/debug/option.go @@ -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" ) diff --git a/settings/pkg/server/debug/server.go b/settings/pkg/server/debug/server.go index 05d4a2e3b..836322dbf 100644 --- a/settings/pkg/server/debug/server.go +++ b/settings/pkg/server/debug/server.go @@ -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" ) diff --git a/settings/pkg/server/grpc/option.go b/settings/pkg/server/grpc/option.go index 6fb7fbf89..119e64f30 100644 --- a/settings/pkg/server/grpc/option.go +++ b/settings/pkg/server/grpc/option.go @@ -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" ) diff --git a/settings/pkg/server/grpc/server.go b/settings/pkg/server/grpc/server.go index 2ff032d6e..e5e751ed6 100644 --- a/settings/pkg/server/grpc/server.go +++ b/settings/pkg/server/grpc/server.go @@ -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" diff --git a/settings/pkg/server/http/option.go b/settings/pkg/server/http/option.go index 299e95520..980e1a1fe 100644 --- a/settings/pkg/server/http/option.go +++ b/settings/pkg/server/http/option.go @@ -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" ) diff --git a/settings/pkg/server/http/server.go b/settings/pkg/server/http/server.go index 4e6c436c4..0e87f69d3 100644 --- a/settings/pkg/server/http/server.go +++ b/settings/pkg/server/http/server.go @@ -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" diff --git a/settings/pkg/service/v0/logging.go b/settings/pkg/service/v0/logging.go index ffcca4f3a..5b6afe62c 100644 --- a/settings/pkg/service/v0/logging.go +++ b/settings/pkg/service/v0/logging.go @@ -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. diff --git a/settings/pkg/service/v0/option.go b/settings/pkg/service/v0/option.go index 403a07058..4c35d5790 100644 --- a/settings/pkg/service/v0/option.go +++ b/settings/pkg/service/v0/option.go @@ -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" ) diff --git a/settings/pkg/service/v0/service.go b/settings/pkg/service/v0/service.go index 26c514b97..fec0dea54 100644 --- a/settings/pkg/service/v0/service.go +++ b/settings/pkg/service/v0/service.go @@ -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" diff --git a/settings/pkg/service/v0/service_test.go b/settings/pkg/service/v0/service_test.go index 9ddc2e649..0cc2b5196 100644 --- a/settings/pkg/service/v0/service_test.go +++ b/settings/pkg/service/v0/service_test.go @@ -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" ) diff --git a/settings/pkg/store/filesystem/assignments_test.go b/settings/pkg/store/filesystem/assignments_test.go index 9f7f00512..b33782def 100644 --- a/settings/pkg/store/filesystem/assignments_test.go +++ b/settings/pkg/store/filesystem/assignments_test.go @@ -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" ) diff --git a/settings/pkg/store/filesystem/bundles_test.go b/settings/pkg/store/filesystem/bundles_test.go index c1a02b6b9..6539bf6ae 100644 --- a/settings/pkg/store/filesystem/bundles_test.go +++ b/settings/pkg/store/filesystem/bundles_test.go @@ -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" ) diff --git a/settings/pkg/store/filesystem/store.go b/settings/pkg/store/filesystem/store.go index aeb7abea5..ddccbe734 100644 --- a/settings/pkg/store/filesystem/store.go +++ b/settings/pkg/store/filesystem/store.go @@ -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" ) diff --git a/settings/pkg/store/filesystem/values_test.go b/settings/pkg/store/filesystem/values_test.go index eaadbb6ac..c6dbc0df6 100644 --- a/settings/pkg/store/filesystem/values_test.go +++ b/settings/pkg/store/filesystem/values_test.go @@ -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" )