From 12c1b96f6f5957580aea3094b80ba22ce135ed43 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 12 Aug 2020 14:21:31 +0200 Subject: [PATCH] Allow any user id format The user id / account UUID should allow any format as in some cases a regular user name could be used there. --- .gitignore | 1 + .../unreleased/remove-uuid-validation.md | 6 ++++ pkg/proto/v0/settings.pb.micro_test.go | 36 ------------------- pkg/service/v0/validator.go | 5 --- 4 files changed, 7 insertions(+), 41 deletions(-) create mode 100644 changelog/unreleased/remove-uuid-validation.md diff --git a/.gitignore b/.gitignore index 962cdb643..9674b762c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ coverage.out /node_modules /assets /ocis-settings-store +pkg/proto/v0/ocis-settings-store/ diff --git a/changelog/unreleased/remove-uuid-validation.md b/changelog/unreleased/remove-uuid-validation.md new file mode 100644 index 000000000..a337ec11f --- /dev/null +++ b/changelog/unreleased/remove-uuid-validation.md @@ -0,0 +1,6 @@ +Bugfix: Allow any user id format + +The user id / account UUID should allow any format as in some cases a regular user name +could be used there. + +https://github.com/owncloud/ocis-settings/issues/41 diff --git a/pkg/proto/v0/settings.pb.micro_test.go b/pkg/proto/v0/settings.pb.micro_test.go index 7ff238665..9df0e4b57 100644 --- a/pkg/proto/v0/settings.pb.micro_test.go +++ b/pkg/proto/v0/settings.pb.micro_test.go @@ -1173,42 +1173,6 @@ func TestSaveGetListSettingsValues(t *testing.T) { Status: "Internal Server Error", }, }, - { - testDataName: "../ in account uuid", - SettingsValue: proto.SettingsValue{ - Identifier: &proto.Identifier{ - Extension: "great-extension", - BundleKey: "bobs-bundle", - AccountUuid: "../123e4567-e89b-12d3-a456-426652340000", - SettingKey: "should-not-be-possible", - }, - Value: &proto.SettingsValue_BoolValue{BoolValue: false}, - }, - expectedError: CustomError{ - ID: "go.micro.client", - Code: 500, - Detail: "account_uuid: must be a valid UUID.", - Status: "Internal Server Error", - }, - }, - { - testDataName: "\\ in fields that are used to create folder and file names", - SettingsValue: proto.SettingsValue{ - Identifier: &proto.Identifier{ - Extension: "\\-extension", - BundleKey: "\\-bundle", - AccountUuid: "\\123e4567-e89b-12d3-a456-426652340000", - SettingKey: "should-not-be-possible", - }, - Value: &proto.SettingsValue_BoolValue{BoolValue: false}, - }, - expectedError: CustomError{ - ID: "go.micro.client", - Code: 500, - Detail: "account_uuid: must be a valid UUID; bundle_key: must be in a valid format; extension: must be in a valid format.", - Status: "Internal Server Error", - }, - }, } client := service.Client() cl := proto.NewValueService("com.owncloud.api.settings", client) diff --git a/pkg/service/v0/validator.go b/pkg/service/v0/validator.go index 005efaa12..b2c7e899c 100644 --- a/pkg/service/v0/validator.go +++ b/pkg/service/v0/validator.go @@ -19,10 +19,6 @@ var ( validation.Required, validation.Match(regexForKeys), } - accountUUIDRule = []validation.Rule{ - validation.Required, - is.UUID, - } ) func validateSaveSettingsBundle(req *proto.SaveSettingsBundleRequest) error { @@ -82,6 +78,5 @@ func validateValueIdentifier(identifier *proto.Identifier) error { validation.Field(&identifier.Extension, keyRule...), validation.Field(&identifier.BundleKey, keyRule...), validation.Field(&identifier.SettingKey, settingKeyRule...), - validation.Field(&identifier.AccountUuid, accountUUIDRule...), ) }