fix: preserve SSO identities and polish sharing interface
This commit is contained in:
1 parent
2e3b56f250
commit
bd9bf33bc9
22 files changed
+430
-106
No files matched your search
@@ -11,6 +11,35 @@ import (
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
||||
func TestPartialUserUpdatePreservesIdentityIndex(t *testing.T) {
|
||||
db, err := storm.Open(filepath.Join(t.TempDir(), "db"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = db.Close() })
|
||||
st, err := NewStorage(db)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
u := &users.User{Username: "sso:stable-subject", Password: "!sso-disabled", Scope: "/", Locale: "en"}
|
||||
if err = st.Users.Save(u); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// The session/API uses a presentation name and may omit other fields.
|
||||
for _, presentation := range []string{"Alice", "", "Alice Renamed"} {
|
||||
if err = st.Users.Update(&users.User{ID: u.ID, Username: presentation, Locale: "ru"}, "Locale"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, err := st.Users.Get("", false, "sso:stable-subject")
|
||||
if err != nil {
|
||||
t.Fatalf("identity lookup lost after preference update: %v", err)
|
||||
}
|
||||
if got.ID != u.ID || got.Username != u.Username || got.Locale != "ru" {
|
||||
t.Fatalf("unexpected user: %+v", got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GetByScope must match case-insensitively: on a case-insensitive filesystem
|
||||
// two scopes that differ only in case resolve to the same home directory, so
|
||||
// the provisioning collision check has to treat them as the same scope.
|
||||
|
||||
Reference in new issue
Block a user