Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add restrictor for import_preview #781

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ The Service uses the following environment variables:
* `METRIC_INTERVAL`: Time in how often the metrics are gathered. Zero disables the metrics. The default is `5m`.
* `METRIC_SAVE_INTERVAL`: Interval, how often the metric should be saved to redis. Redis will ignore entries, that are twice at old then the save interval. The default is `5m`.
* `DISABLE_CONNECTION_COUNT`: Do not count connections. The default is `false`.
* `ENABLE_PROFILE_ROUTES`: Activate development routes for profiling. The default is `false`.
1 change: 1 addition & 0 deletions internal/restrict/collection/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ var collectionMap = map[string]Restricter{
ChatMessage{}.Name(): ChatMessage{},
Committee{}.Name(): Committee{},
Group{}.Name(): Group{},
ImportPreview{}.Name(): ImportPreview{},
Mediafile{}.Name(): Mediafile{},
Meeting{}.Name(): Meeting{},
MeetingUser{}.Name(): MeetingUser{},
Expand Down
31 changes: 31 additions & 0 deletions internal/restrict/collection/import_preview.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package collection

import (
"context"

"github.com/OpenSlides/openslides-autoupdate-service/pkg/datastore/dsfetch"
)

// ImportPreview handels restrictions of the collection import_preview.
//
// Noone can see the import_preview
type ImportPreview struct{}

// Name returns the collection name.
func (i ImportPreview) Name() string {
return "import_preview"
}

// MeetingID returns the meetingID for the object.
func (i ImportPreview) MeetingID(ctx context.Context, ds *dsfetch.Fetch, id int) (int, bool, error) {
return 0, false, nil
}

// Modes returns the field restricters for the collection.
func (i ImportPreview) Modes(mode string) FieldRestricter {
switch mode {
case "A":
return never
}
return nil
}
29 changes: 29 additions & 0 deletions internal/restrict/collection/import_preview_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package collection_test

import (
"testing"

"github.com/OpenSlides/openslides-autoupdate-service/internal/restrict/collection"
)

func TestImportPreviewModeA(t *testing.T) {
var i collection.ImportPreview

testCase(
"no perms",
t,
i.Modes("A"),
false,
``,
)

testCase(
"organization manager",
t,
i.Modes("A"),
false,
`---
user/1/organization_management_level: can_manage_organization
`,
)
}
7 changes: 7 additions & 0 deletions internal/restrict/field_def.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/restrict/restrict.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,4 +577,5 @@ var collectionOrder = map[string]int{
"user": 38,
"meeting_user": 39,
"action_worker": 40,
"import_preview": 41,
}
45 changes: 45 additions & 0 deletions pkg/datastore/dsfetch/fields_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading