Add profile 3D preferences and adapt DICOM preview resolution to memory budget

This commit is contained in:
SantaSpeen committed 2026-10-22 22:29:28 +03:00
1 parent 705762d57c
commit 7fd7ae6733
22 files changed
+500 -68

No files matched your search

+34
View File
@@ -12,6 +12,40 @@ import (
"github.com/gorilla/mux"
)
func TestDicom3DPreferencesAreSelfEditableAndValidated(t *testing.T) {
st := scopedUserStorage(t, t.TempDir(), users.Permissions{}, []byte("key"))
for _, test := range []struct {
body string
status int
}{
{`{"what":"user","which":["dicom3D"],"data":{"id":1,"dicom3D":{"memoryMiB":512,"quality":"auto","opacity":50}}}`, 200},
{`{"what":"user","which":["dicom3D"],"data":{"id":1,"dicom3D":{"memoryMiB":2048,"quality":"auto","opacity":50}}}`, 400},
{`{"what":"user","which":["dicom3D"],"data":{"id":1,"dicom3D":{"quality":"invalid"}}}`, 400},
} {
r := mux.SetURLVars(httptest.NewRequest("PUT", "/users/1", strings.NewReader(test.body)), map[string]string{"id": "1"})
r = authorizeTestRequest(r, testSession(1, "u", false))
w := httptest.NewRecorder()
handle(userPutHandler, "", st, &settings.Server{}).ServeHTTP(w, r)
if w.Code != test.status {
t.Fatalf("status %d, want %d: %s", w.Code, test.status, w.Body.String())
}
}
u, err := st.Users.Get("", false, uint(1))
if err != nil {
t.Fatal(err)
}
if u.Dicom3D.MemoryMiB != 512 || u.Dicom3D.Opacity != 50 || u.Dicom3D.Quality != "auto" {
t.Fatalf("settings not persisted: %+v", u.Dicom3D)
}
if u.Perm.Admin {
t.Fatal("preferences changed permissions")
}
// Check the same profile representation returned on subsequent SSO sessions.
if ssoUserInfo(u).Dicom3D != u.Dicom3D {
t.Fatal("session profile lost preferences")
}
}
func TestLocalAdminCannotOverrideSSORole(t *testing.T) {
st := scopedUserStorage(t, t.TempDir(), users.Permissions{Admin: true}, []byte("key"))
r := authorizeTestRequest(httptest.NewRequest("GET", "/", nil), testSession(1, "u", false))