ui
Some checks are pending
CI / test-control-plane (push) Waiting to run
CI / test-node-agent (push) Waiting to run
CI / build-web (push) Waiting to run

This commit is contained in:
Harivansh Rathi 2026-04-01 21:18:08 -04:00
parent 171a682f6a
commit f6069a024a
7 changed files with 675 additions and 120 deletions

View file

@ -56,8 +56,9 @@ func TestControlPlaneBinaryMountLoopIntegration(t *testing.T) {
mount := postJSONAuth[mountProfile](t, client, controlPlane.sessionToken, controlPlane.baseURL+"/api/v1/mount-profiles/issue", mountProfileRequest{
ExportID: export.ID,
})
if mount.MountURL != nodeAgent.baseURL+defaultWebDAVPath {
t.Fatalf("expected runtime mount URL %q, got %q", nodeAgent.baseURL+defaultWebDAVPath, mount.MountURL)
expectedMountURL := nodeAgent.baseURL + defaultWebDAVPath + runtimeUsername + "/"
if mount.MountURL != expectedMountURL {
t.Fatalf("expected runtime mount URL %q, got %q", expectedMountURL, mount.MountURL)
}
if mount.Credential.Mode != mountCredentialModeBasicAuth {
t.Fatalf("expected mount credential mode %q, got %q", mountCredentialModeBasicAuth, mount.Credential.Mode)
@ -103,11 +104,13 @@ func TestControlPlaneBinaryMultiExportProfilesStayDistinct(t *testing.T) {
if firstMount.MountURL == secondMount.MountURL {
t.Fatalf("expected distinct runtime mount URLs, got %q", firstMount.MountURL)
}
if firstMount.MountURL != nodeAgent.baseURL+firstMountPath {
t.Fatalf("expected first runtime mount URL %q, got %q", nodeAgent.baseURL+firstMountPath, firstMount.MountURL)
expectedFirstMountURL := nodeAgent.baseURL + firstMountPath + runtimeUsername + "/"
expectedSecondMountURL := nodeAgent.baseURL + secondMountPath + runtimeUsername + "/"
if firstMount.MountURL != expectedFirstMountURL {
t.Fatalf("expected first runtime mount URL %q, got %q", expectedFirstMountURL, firstMount.MountURL)
}
if secondMount.MountURL != nodeAgent.baseURL+secondMountPath {
t.Fatalf("expected second runtime mount URL %q, got %q", nodeAgent.baseURL+secondMountPath, secondMount.MountURL)
if secondMount.MountURL != expectedSecondMountURL {
t.Fatalf("expected second runtime mount URL %q, got %q", expectedSecondMountURL, secondMount.MountURL)
}
assertHTTPStatusWithBasicAuth(t, client, "PROPFIND", firstMount.MountURL, controlPlane.username, controlPlane.password, http.StatusMultiStatus)

View file

@ -218,7 +218,7 @@ func (a *app) handleMountProfileIssue(w http.ResponseWriter, r *http.Request) {
return
}
mountURL, err := buildMountURL(context)
mountURL, err := buildMountURL(context, currentUser.Username)
if err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return
@ -720,13 +720,17 @@ func hasConfiguredNextcloudBaseURL(baseURL string) bool {
return err == nil
}
func buildMountURL(context exportContext) (string, error) {
func buildMountURL(context exportContext, username string) (string, error) {
address, ok := firstAddress(context.node.DirectAddress, context.node.RelayAddress)
if !ok {
return "", errMountTargetUnavailable
}
mountURL, err := buildAbsoluteHTTPURLWithPath(address, mountProfilePathForExport(context.export.MountPath))
basePath := mountProfilePathForExport(context.export.MountPath)
// Append the username so Finder uses it as the volume name in the sidebar.
userScopedPath := path.Join(basePath, username) + "/"
mountURL, err := buildAbsoluteHTTPURLWithPath(address, userScopedPath)
if err != nil {
return "", errMountTargetUnavailable
}

View file

@ -162,8 +162,8 @@ func TestControlPlaneRegistrationProfilesAndHeartbeat(t *testing.T) {
if mount.DisplayName != "Photos" {
t.Fatalf("expected mount display name Photos, got %q", mount.DisplayName)
}
if mount.MountURL != "http://nas.local:8090/dav/" {
t.Fatalf("expected mount URL %q, got %q", "http://nas.local:8090/dav/", mount.MountURL)
if mount.MountURL != "http://nas.local:8090/dav/fixture/" {
t.Fatalf("expected mount URL %q, got %q", "http://nas.local:8090/dav/fixture/", mount.MountURL)
}
if mount.Readonly {
t.Fatal("expected mount profile to be read-write")
@ -415,11 +415,11 @@ func TestControlPlaneProfilesRemainExportSpecificForConfiguredMountPaths(t *test
if docsMount.MountURL == mediaMount.MountURL {
t.Fatalf("expected distinct mount URLs for configured export paths, got %q", docsMount.MountURL)
}
if docsMount.MountURL != "http://nas.local:8090/dav/exports/docs/" {
t.Fatalf("expected docs mount URL %q, got %q", "http://nas.local:8090/dav/exports/docs/", docsMount.MountURL)
if docsMount.MountURL != "http://nas.local:8090/dav/exports/docs/fixture/" {
t.Fatalf("expected docs mount URL %q, got %q", "http://nas.local:8090/dav/exports/docs/fixture/", docsMount.MountURL)
}
if mediaMount.MountURL != "http://nas.local:8090/dav/exports/media/" {
t.Fatalf("expected media mount URL %q, got %q", "http://nas.local:8090/dav/exports/media/", mediaMount.MountURL)
if mediaMount.MountURL != "http://nas.local:8090/dav/exports/media/fixture/" {
t.Fatalf("expected media mount URL %q, got %q", "http://nas.local:8090/dav/exports/media/fixture/", mediaMount.MountURL)
}
docsCloud := postJSONAuth[cloudProfile](t, server.Client(), testClientToken, server.URL+"/api/v1/cloud-profiles/issue", cloudProfileRequest{
@ -469,8 +469,8 @@ func TestControlPlaneMountProfilesUseRelayAndPreserveBasePath(t *testing.T) {
})
mount := postJSONAuth[mountProfile](t, server.Client(), testClientToken, server.URL+"/api/v1/mount-profiles/issue", mountProfileRequest{ExportID: "dev-export"})
if mount.MountURL != "https://nas.example.test/control/dav/relay/" {
t.Fatalf("expected relay mount URL %q, got %q", "https://nas.example.test/control/dav/relay/", mount.MountURL)
if mount.MountURL != "https://nas.example.test/control/dav/relay/fixture/" {
t.Fatalf("expected relay mount URL %q, got %q", "https://nas.example.test/control/dav/relay/fixture/", mount.MountURL)
}
registration = registerNode(t, server.Client(), server.URL+"/api/v1/nodes/register", testNodeBootstrapToken, nodeRegistrationRequest{
@ -648,8 +648,8 @@ func TestControlPlanePersistsRegistryAcrossAppRestart(t *testing.T) {
}
mount := postJSONAuth[mountProfile](t, secondServer.Client(), testClientToken, secondServer.URL+"/api/v1/mount-profiles/issue", mountProfileRequest{ExportID: exports[0].ID})
if mount.MountURL != "http://nas.local:8090/dav/persisted/" {
t.Fatalf("expected persisted mount URL %q, got %q", "http://nas.local:8090/dav/persisted/", mount.MountURL)
if mount.MountURL != "http://nas.local:8090/dav/persisted/fixture/" {
t.Fatalf("expected persisted mount URL %q, got %q", "http://nas.local:8090/dav/persisted/fixture/", mount.MountURL)
}
reRegistration := registerNode(t, secondServer.Client(), secondServer.URL+"/api/v1/nodes/register", registration.NodeToken, nodeRegistrationRequest{

View file

@ -102,8 +102,8 @@ func TestSQLiteRegistrationAndExports(t *testing.T) {
}
mount := postJSONAuth[mountProfile](t, server.Client(), testClientToken, server.URL+"/api/v1/mount-profiles/issue", mountProfileRequest{ExportID: "dev-export"})
if mount.MountURL != "http://nas.local:8090/dav/docs/" {
t.Fatalf("expected mount URL %q, got %q", "http://nas.local:8090/dav/docs/", mount.MountURL)
if mount.MountURL != "http://nas.local:8090/dav/docs/fixture/" {
t.Fatalf("expected mount URL %q, got %q", "http://nas.local:8090/dav/docs/fixture/", mount.MountURL)
}
}