MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / TestCanAccessWithReadPermissions

Function TestCanAccessWithReadPermissions

server/common/check_test.go:498–593  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

496}
497
498func TestCanAccessWithReadPermissions(t *testing.T) {
499 tests := []struct {
500 name string
501 user *model.User
502 meta *model.Meta
503 reqPath string
504 password string
505 want bool
506 reason string
507 }{
508 {
509 name: "user with read permission and correct password",
510 user: &model.User{
511 ID: 1,
512 Role: model.GENERAL,
513 Permission: 0,
514 },
515 meta: &model.Meta{
516 Path: "/folder",
517 ReadUsers: []uint{1, 2},
518 ReadUsersSub: true,
519 Password: "secret",
520 PSub: true,
521 },
522 reqPath: "/folder/file.txt",
523 password: "secret",
524 want: true,
525 reason: "user in ReadUsers list with correct password",
526 },
527 {
528 name: "user without read permission even with correct password",
529 user: &model.User{
530 ID: 5,
531 Role: model.GENERAL,
532 Permission: 0,
533 },
534 meta: &model.Meta{
535 Path: "/folder",
536 ReadUsers: []uint{1, 2},
537 ReadUsersSub: true,
538 Password: "secret",
539 PSub: true,
540 },
541 reqPath: "/folder/file.txt",
542 password: "secret",
543 want: false,
544 reason: "user not in ReadUsers list, should be denied before password check",
545 },
546 {
547 name: "user with read permission but wrong password",
548 user: &model.User{
549 ID: 1,
550 Role: model.GENERAL,
551 Permission: 0,
552 },
553 meta: &model.Meta{
554 Path: "/folder",
555 ReadUsers: []uint{1, 2},

Callers

nothing calls this directly

Calls 2

CanAccessFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected